Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | FlashPoint.c -- FlashPoint SCCB Manager for Linux |
| 4 | |
| 5 | This file contains the FlashPoint SCCB Manager from BusLogic's FlashPoint |
| 6 | Driver Developer's Kit, with minor modifications by Leonard N. Zubkoff for |
| 7 | Linux compatibility. It was provided by BusLogic in the form of 16 separate |
| 8 | source files, which would have unnecessarily cluttered the scsi directory, so |
| 9 | the individual files have been combined into this single file. |
| 10 | |
| 11 | Copyright 1995-1996 by Mylex Corporation. All Rights Reserved |
| 12 | |
| 13 | This file is available under both the GNU General Public License |
| 14 | and a BSD-style copyright; see LICENSE.FlashPoint for details. |
| 15 | |
| 16 | */ |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #ifndef CONFIG_SCSI_OMIT_FLASHPOINT |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #define MAX_CARDS 8 |
| 22 | #undef BUSTYPE_PCI |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #define CRCMASK 0xA001 |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #define FAILURE 0xFFFFFFFFL |
| 27 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 28 | #define BIT(x) ((unsigned char)(1<<(x))) /* single-bit mask in bit position x */ |
| 29 | #define BITW(x) ((unsigned short)(1<<(x))) /* single-bit mask in bit position x */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Alexey Dobriyan | 69eb2ea | 2006-03-08 00:14:29 -0800 | [diff] [blame] | 31 | struct sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 32 | typedef void (*CALL_BK_FN) (struct sccb *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Alexey Dobriyan | 7f10166 | 2006-03-08 00:14:30 -0800 | [diff] [blame] | 34 | struct sccb_mgr_info { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 35 | unsigned long si_baseaddr; |
| 36 | unsigned char si_present; |
| 37 | unsigned char si_intvect; |
| 38 | unsigned char si_id; |
| 39 | unsigned char si_lun; |
| 40 | unsigned short si_fw_revision; |
| 41 | unsigned short si_per_targ_init_sync; |
| 42 | unsigned short si_per_targ_fast_nego; |
| 43 | unsigned short si_per_targ_ultra_nego; |
| 44 | unsigned short si_per_targ_no_disc; |
| 45 | unsigned short si_per_targ_wide_nego; |
| 46 | unsigned short si_flags; |
| 47 | unsigned char si_card_family; |
| 48 | unsigned char si_bustype; |
| 49 | unsigned char si_card_model[3]; |
| 50 | unsigned char si_relative_cardnum; |
| 51 | unsigned char si_reserved[4]; |
| 52 | unsigned long si_OS_reserved; |
| 53 | unsigned char si_XlatInfo[4]; |
| 54 | unsigned long si_reserved2[5]; |
| 55 | unsigned long si_secondary_range; |
Alexey Dobriyan | 7f10166 | 2006-03-08 00:14:30 -0800 | [diff] [blame] | 56 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 58 | #define SCSI_PARITY_ENA 0x0001 |
| 59 | #define LOW_BYTE_TERM 0x0010 |
| 60 | #define HIGH_BYTE_TERM 0x0020 |
| 61 | #define BUSTYPE_PCI 0x3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | #define SUPPORT_16TAR_32LUN 0x0002 |
| 64 | #define SOFT_RESET 0x0004 |
| 65 | #define EXTENDED_TRANSLATION 0x0008 |
| 66 | #define POST_ALL_UNDERRRUNS 0x0040 |
| 67 | #define FLAG_SCAM_ENABLED 0x0080 |
| 68 | #define FLAG_SCAM_LEVEL2 0x0100 |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define HARPOON_FAMILY 0x02 |
| 71 | |
Alexey Dobriyan | 32357988 | 2006-01-15 02:12:54 +0100 | [diff] [blame] | 72 | /* SCCB struct used for both SCCB and UCB manager compiles! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | * The UCB Manager treats the SCCB as it's 'native hardware structure' |
| 74 | */ |
| 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | #pragma pack(1) |
Alexey Dobriyan | 69eb2ea | 2006-03-08 00:14:29 -0800 | [diff] [blame] | 77 | struct sccb { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 78 | unsigned char OperationCode; |
| 79 | unsigned char ControlByte; |
| 80 | unsigned char CdbLength; |
| 81 | unsigned char RequestSenseLength; |
| 82 | unsigned long DataLength; |
| 83 | unsigned long DataPointer; |
| 84 | unsigned char CcbRes[2]; |
| 85 | unsigned char HostStatus; |
| 86 | unsigned char TargetStatus; |
| 87 | unsigned char TargID; |
| 88 | unsigned char Lun; |
| 89 | unsigned char Cdb[12]; |
| 90 | unsigned char CcbRes1; |
| 91 | unsigned char Reserved1; |
| 92 | unsigned long Reserved2; |
| 93 | unsigned long SensePointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 95 | CALL_BK_FN SccbCallback; /* VOID (*SccbCallback)(); */ |
| 96 | unsigned long SccbIOPort; /* Identifies board base port */ |
| 97 | unsigned char SccbStatus; |
| 98 | unsigned char SCCBRes2; |
| 99 | unsigned short SccbOSFlags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 101 | unsigned long Sccb_XferCnt; /* actual transfer count */ |
| 102 | unsigned long Sccb_ATC; |
| 103 | unsigned long SccbVirtDataPtr; /* virtual addr for OS/2 */ |
| 104 | unsigned long Sccb_res1; |
| 105 | unsigned short Sccb_MGRFlags; |
| 106 | unsigned short Sccb_sgseg; |
| 107 | unsigned char Sccb_scsimsg; /* identify msg for selection */ |
| 108 | unsigned char Sccb_tag; |
| 109 | unsigned char Sccb_scsistat; |
| 110 | unsigned char Sccb_idmsg; /* image of last msg in */ |
| 111 | struct sccb *Sccb_forwardlink; |
| 112 | struct sccb *Sccb_backlink; |
| 113 | unsigned long Sccb_savedATC; |
| 114 | unsigned char Save_Cdb[6]; |
| 115 | unsigned char Save_CdbLen; |
| 116 | unsigned char Sccb_XferState; |
| 117 | unsigned long Sccb_SGoffset; |
| 118 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
| 120 | #pragma pack() |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | #define SCATTER_GATHER_COMMAND 0x02 |
| 123 | #define RESIDUAL_COMMAND 0x03 |
| 124 | #define RESIDUAL_SG_COMMAND 0x04 |
| 125 | #define RESET_COMMAND 0x81 |
| 126 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 127 | #define F_USE_CMD_Q 0x20 /*Inidcates TAGGED command. */ |
| 128 | #define TAG_TYPE_MASK 0xC0 /*Type of tag msg to send. */ |
| 129 | #define SCCB_DATA_XFER_OUT 0x10 /* Write */ |
| 130 | #define SCCB_DATA_XFER_IN 0x08 /* Read */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 132 | #define NO_AUTO_REQUEST_SENSE 0x01 /* No Request Sense Buffer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 134 | #define BUS_FREE_ST 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | #define SELECT_ST 1 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 136 | #define SELECT_BDR_ST 2 /* Select w\ Bus Device Reset */ |
| 137 | #define SELECT_SN_ST 3 /* Select w\ Sync Nego */ |
| 138 | #define SELECT_WN_ST 4 /* Select w\ Wide Data Nego */ |
| 139 | #define SELECT_Q_ST 5 /* Select w\ Tagged Q'ing */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | #define COMMAND_ST 6 |
| 141 | #define DATA_OUT_ST 7 |
| 142 | #define DATA_IN_ST 8 |
| 143 | #define DISCONNECT_ST 9 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | #define ABORT_ST 11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | #define F_HOST_XFER_DIR 0x01 |
| 147 | #define F_ALL_XFERRED 0x02 |
| 148 | #define F_SG_XFER 0x04 |
| 149 | #define F_AUTO_SENSE 0x08 |
| 150 | #define F_ODD_BALL_CNT 0x10 |
| 151 | #define F_NO_DATA_YET 0x80 |
| 152 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | #define F_STATUSLOADED 0x01 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | #define F_DEV_SELECTED 0x04 |
| 155 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 156 | #define SCCB_COMPLETE 0x00 /* SCCB completed without error */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | #define SCCB_DATA_UNDER_RUN 0x0C |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 158 | #define SCCB_SELECTION_TIMEOUT 0x11 /* Set SCSI selection timed out */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | #define SCCB_DATA_OVER_RUN 0x12 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 160 | #define SCCB_PHASE_SEQUENCE_FAIL 0x14 /* Target bus phase sequence failure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 162 | #define SCCB_GROSS_FW_ERR 0x27 /* Major problem! */ |
| 163 | #define SCCB_BM_ERR 0x30 /* BusMaster error. */ |
| 164 | #define SCCB_PARITY_ERR 0x34 /* SCSI parity error */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
| 166 | #define SCCB_IN_PROCESS 0x00 |
| 167 | #define SCCB_SUCCESS 0x01 |
| 168 | #define SCCB_ABORT 0x02 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | #define SCCB_ERROR 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | #define ORION_FW_REV 3110 |
| 172 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 173 | #define QUEUE_DEPTH 254+1 /*1 for Normal disconnect 32 for Q'ing. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 175 | #define MAX_MB_CARDS 4 /* Max. no of cards suppoerted on Mother Board */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 177 | #define MAX_SCSI_TAR 16 |
| 178 | #define MAX_LUN 32 |
| 179 | #define LUN_MASK 0x1f |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 181 | #define SG_BUF_CNT 16 /*Number of prefetched elements. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 183 | #define SG_ELEMENT_SIZE 8 /*Eight byte per element. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | |
Alexey Dobriyan | ad0e1d9 | 2006-03-08 00:14:28 -0800 | [diff] [blame] | 185 | #define RD_HARPOON(ioport) inb((u32)ioport) |
| 186 | #define RDW_HARPOON(ioport) inw((u32)ioport) |
| 187 | #define RD_HARP32(ioport,offset,data) (data = inl((u32)(ioport + offset))) |
| 188 | #define WR_HARPOON(ioport,val) outb((u8) val, (u32)ioport) |
| 189 | #define WRW_HARPOON(ioport,val) outw((u16)val, (u32)ioport) |
| 190 | #define WR_HARP32(ioport,offset,data) outl(data, (u32)(ioport + offset)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | #define TAR_SYNC_MASK (BIT(7)+BIT(6)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | #define SYNC_TRYING BIT(6) |
| 194 | #define SYNC_SUPPORTED (BIT(7)+BIT(6)) |
| 195 | |
| 196 | #define TAR_WIDE_MASK (BIT(5)+BIT(4)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | #define WIDE_ENABLED BIT(4) |
| 198 | #define WIDE_NEGOCIATED BIT(5) |
| 199 | |
| 200 | #define TAR_TAG_Q_MASK (BIT(3)+BIT(2)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | #define TAG_Q_TRYING BIT(2) |
| 202 | #define TAG_Q_REJECT BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | |
| 204 | #define TAR_ALLOW_DISC BIT(0) |
| 205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | #define EE_SYNC_MASK (BIT(0)+BIT(1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | #define EE_SYNC_5MB BIT(0) |
| 208 | #define EE_SYNC_10MB BIT(1) |
| 209 | #define EE_SYNC_20MB (BIT(0)+BIT(1)) |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | #define EE_WIDE_SCSI BIT(7) |
| 212 | |
Alexey Dobriyan | f31dc0cd | 2006-03-08 00:14:31 -0800 | [diff] [blame] | 213 | struct sccb_mgr_tar_info { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 215 | struct sccb *TarSelQ_Head; |
| 216 | struct sccb *TarSelQ_Tail; |
| 217 | unsigned char TarLUN_CA; /*Contingent Allgiance */ |
| 218 | unsigned char TarTagQ_Cnt; |
| 219 | unsigned char TarSelQ_Cnt; |
| 220 | unsigned char TarStatus; |
| 221 | unsigned char TarEEValue; |
| 222 | unsigned char TarSyncCtrl; |
| 223 | unsigned char TarReserved[2]; /* for alignment */ |
| 224 | unsigned char LunDiscQ_Idx[MAX_LUN]; |
| 225 | unsigned char TarLUNBusy[MAX_LUN]; |
Alexey Dobriyan | f31dc0cd | 2006-03-08 00:14:31 -0800 | [diff] [blame] | 226 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Alexey Dobriyan | 68d0c1a | 2006-03-08 00:14:33 -0800 | [diff] [blame] | 228 | struct nvram_info { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 229 | unsigned char niModel; /* Model No. of card */ |
| 230 | unsigned char niCardNo; /* Card no. */ |
| 231 | unsigned long niBaseAddr; /* Port Address of card */ |
| 232 | unsigned char niSysConf; /* Adapter Configuration byte - Byte 16 of eeprom map */ |
| 233 | unsigned char niScsiConf; /* SCSI Configuration byte - Byte 17 of eeprom map */ |
| 234 | unsigned char niScamConf; /* SCAM Configuration byte - Byte 20 of eeprom map */ |
| 235 | unsigned char niAdapId; /* Host Adapter ID - Byte 24 of eerpom map */ |
| 236 | unsigned char niSyncTbl[MAX_SCSI_TAR / 2]; /* Sync/Wide byte of targets */ |
| 237 | unsigned char niScamTbl[MAX_SCSI_TAR][4]; /* Compressed Scam name string of Targets */ |
Alexey Dobriyan | 68d0c1a | 2006-03-08 00:14:33 -0800 | [diff] [blame] | 238 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | #define MODEL_LT 1 |
| 241 | #define MODEL_DL 2 |
| 242 | #define MODEL_LW 3 |
| 243 | #define MODEL_DW 4 |
| 244 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 245 | struct sccb_card { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 246 | struct sccb *currentSCCB; |
| 247 | struct sccb_mgr_info *cardInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 249 | unsigned long ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 251 | unsigned short cmdCounter; |
| 252 | unsigned char discQCount; |
| 253 | unsigned char tagQ_Lst; |
| 254 | unsigned char cardIndex; |
| 255 | unsigned char scanIndex; |
| 256 | unsigned char globalFlags; |
| 257 | unsigned char ourId; |
| 258 | struct nvram_info *pNvRamInfo; |
| 259 | struct sccb *discQ_Tbl[QUEUE_DEPTH]; |
| 260 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 261 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | #define F_TAG_STARTED 0x01 |
| 264 | #define F_CONLUN_IO 0x02 |
| 265 | #define F_DO_RENEGO 0x04 |
| 266 | #define F_NO_FILTER 0x08 |
| 267 | #define F_GREEN_PC 0x10 |
| 268 | #define F_HOST_XFER_ACT 0x20 |
| 269 | #define F_NEW_SCCB_CMD 0x40 |
| 270 | #define F_UPDATE_EEPROM 0x80 |
| 271 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | #define ID_STRING_LENGTH 32 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 273 | #define TYPE_CODE0 0x63 /*Level2 Mstr (bits 7-6), */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 275 | #define SLV_TYPE_CODE0 0xA3 /*Priority Bit set (bits 7-6), */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
| 277 | #define ASSIGN_ID 0x00 |
| 278 | #define SET_P_FLAG 0x01 |
| 279 | #define CFG_CMPLT 0x03 |
| 280 | #define DOM_MSTR 0x0F |
| 281 | #define SYNC_PTRN 0x1F |
| 282 | |
| 283 | #define ID_0_7 0x18 |
| 284 | #define ID_8_F 0x11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | #define MISC_CODE 0x14 |
| 286 | #define CLR_P_FLAG 0x18 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | #define INIT_SELTD 0x01 |
| 289 | #define LEVEL2_TAR 0x02 |
| 290 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 291 | enum scam_id_st { ID0, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, ID9, ID10, ID11, |
| 292 | ID12, |
| 293 | ID13, ID14, ID15, ID_UNUSED, ID_UNASSIGNED, ID_ASSIGNED, LEGACY, |
| 294 | CLR_PRIORITY, NO_ID_AVAIL |
| 295 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | |
| 297 | typedef struct SCCBscam_info { |
| 298 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 299 | unsigned char id_string[ID_STRING_LENGTH]; |
| 300 | enum scam_id_st state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 302 | } SCCBSCAM_INFO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | #define SCSI_REQUEST_SENSE 0x03 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | #define SCSI_READ 0x08 |
| 306 | #define SCSI_WRITE 0x0A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | #define SCSI_START_STOP_UNIT 0x1B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | #define SCSI_READ_EXTENDED 0x28 |
| 309 | #define SCSI_WRITE_EXTENDED 0x2A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | #define SCSI_WRITE_AND_VERIFY 0x2E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | #define SSGOOD 0x00 |
| 313 | #define SSCHECK 0x02 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | #define SSQ_FULL 0x28 |
| 315 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | #define SMCMD_COMP 0x00 |
| 317 | #define SMEXT 0x01 |
| 318 | #define SMSAVE_DATA_PTR 0x02 |
| 319 | #define SMREST_DATA_PTR 0x03 |
| 320 | #define SMDISC 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | #define SMABORT 0x06 |
| 322 | #define SMREJECT 0x07 |
| 323 | #define SMNO_OP 0x08 |
| 324 | #define SMPARITY 0x09 |
| 325 | #define SMDEV_RESET 0x0C |
| 326 | #define SMABORT_TAG 0x0D |
| 327 | #define SMINIT_RECOVERY 0x0F |
| 328 | #define SMREL_RECOVERY 0x10 |
| 329 | |
| 330 | #define SMIDENT 0x80 |
| 331 | #define DISC_PRIV 0x40 |
| 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | #define SMSYNC 0x01 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | #define SMWDTR 0x03 |
| 335 | #define SM8BIT 0x00 |
| 336 | #define SM16BIT 0x01 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 337 | #define SMIGNORWR 0x23 /* Ignore Wide Residue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
| 339 | #define SIX_BYTE_CMD 0x06 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | #define TWELVE_BYTE_CMD 0x0C |
| 341 | |
| 342 | #define ASYNC 0x00 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 343 | #define MAX_OFFSET 0x0F /* Maxbyteoffset for Sync Xfers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
| 345 | #define EEPROM_WD_CNT 256 |
| 346 | |
| 347 | #define EEPROM_CHECK_SUM 0 |
| 348 | #define FW_SIGNATURE 2 |
| 349 | #define MODEL_NUMB_0 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | #define MODEL_NUMB_2 6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | #define MODEL_NUMB_4 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | #define SYSTEM_CONFIG 16 |
| 353 | #define SCSI_CONFIG 17 |
| 354 | #define BIOS_CONFIG 18 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | #define SCAM_CONFIG 20 |
| 356 | #define ADAPTER_SCSI_ID 24 |
| 357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | #define IGNORE_B_SCAN 32 |
| 359 | #define SEND_START_ENA 34 |
| 360 | #define DEVICE_ENABLE 36 |
| 361 | |
| 362 | #define SYNC_RATE_TBL 38 |
| 363 | #define SYNC_RATE_TBL01 38 |
| 364 | #define SYNC_RATE_TBL23 40 |
| 365 | #define SYNC_RATE_TBL45 42 |
| 366 | #define SYNC_RATE_TBL67 44 |
| 367 | #define SYNC_RATE_TBL89 46 |
| 368 | #define SYNC_RATE_TBLab 48 |
| 369 | #define SYNC_RATE_TBLcd 50 |
| 370 | #define SYNC_RATE_TBLef 52 |
| 371 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 372 | #define EE_SCAMBASE 256 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 374 | #define SCAM_ENABLED BIT(2) |
| 375 | #define SCAM_LEVEL2 BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 377 | #define RENEGO_ENA BITW(10) |
| 378 | #define CONNIO_ENA BITW(11) |
| 379 | #define GREEN_PC_ENA BITW(12) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 381 | #define AUTO_RATE_00 00 |
| 382 | #define AUTO_RATE_05 01 |
| 383 | #define AUTO_RATE_10 02 |
| 384 | #define AUTO_RATE_20 03 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 386 | #define WIDE_NEGO_BIT BIT(7) |
| 387 | #define DISC_ENABLE_BIT BIT(6) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 389 | #define hp_vendor_id_0 0x00 /* LSB */ |
| 390 | #define ORION_VEND_0 0x4B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 392 | #define hp_vendor_id_1 0x01 /* MSB */ |
| 393 | #define ORION_VEND_1 0x10 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 395 | #define hp_device_id_0 0x02 /* LSB */ |
| 396 | #define ORION_DEV_0 0x30 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 398 | #define hp_device_id_1 0x03 /* MSB */ |
| 399 | #define ORION_DEV_1 0x81 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | |
| 401 | /* Sub Vendor ID and Sub Device ID only available in |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 402 | Harpoon Version 2 and higher */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 404 | #define hp_sub_device_id_0 0x06 /* LSB */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 406 | #define hp_semaphore 0x0C |
| 407 | #define SCCB_MGR_ACTIVE BIT(0) |
| 408 | #define TICKLE_ME BIT(1) |
| 409 | #define SCCB_MGR_PRESENT BIT(3) |
| 410 | #define BIOS_IN_USE BIT(4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 412 | #define hp_sys_ctrl 0x0F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 414 | #define STOP_CLK BIT(0) /*Turn off BusMaster Clock */ |
| 415 | #define DRVR_RST BIT(1) /*Firmware Reset to 80C15 chip */ |
| 416 | #define HALT_MACH BIT(3) /*Halt State Machine */ |
| 417 | #define HARD_ABORT BIT(4) /*Hard Abort */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 419 | #define hp_host_blk_cnt 0x13 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 421 | #define XFER_BLK64 0x06 /* 1 1 0 64 byte per block */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 423 | #define BM_THRESHOLD 0x40 /* PCI mode can only xfer 16 bytes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 425 | #define hp_int_mask 0x17 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 427 | #define INT_CMD_COMPL BIT(0) /* DMA command complete */ |
| 428 | #define INT_EXT_STATUS BIT(1) /* Extended Status Set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 430 | #define hp_xfer_cnt_lo 0x18 |
| 431 | #define hp_xfer_cnt_hi 0x1A |
| 432 | #define hp_xfer_cmd 0x1B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 434 | #define XFER_HOST_DMA 0x00 /* 0 0 0 Transfer Host -> DMA */ |
| 435 | #define XFER_DMA_HOST 0x01 /* 0 0 1 Transfer DMA -> Host */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 437 | #define XFER_HOST_AUTO 0x00 /* 0 0 Auto Transfer Size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 439 | #define XFER_DMA_8BIT 0x20 /* 0 1 8 BIT Transfer Size */ |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 440 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 441 | #define DISABLE_INT BIT(7) /*Do not interrupt at end of cmd. */ |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 442 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 443 | #define HOST_WRT_CMD ((DISABLE_INT + XFER_HOST_DMA + XFER_HOST_AUTO + XFER_DMA_8BIT)) |
| 444 | #define HOST_RD_CMD ((DISABLE_INT + XFER_DMA_HOST + XFER_HOST_AUTO + XFER_DMA_8BIT)) |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 445 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 446 | #define hp_host_addr_lo 0x1C |
| 447 | #define hp_host_addr_hmi 0x1E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 449 | #define hp_ee_ctrl 0x22 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 451 | #define EXT_ARB_ACK BIT(7) |
| 452 | #define SCSI_TERM_ENA_H BIT(6) /* SCSI high byte terminator */ |
| 453 | #define SEE_MS BIT(5) |
| 454 | #define SEE_CS BIT(3) |
| 455 | #define SEE_CLK BIT(2) |
| 456 | #define SEE_DO BIT(1) |
| 457 | #define SEE_DI BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 459 | #define EE_READ 0x06 |
| 460 | #define EE_WRITE 0x05 |
| 461 | #define EWEN 0x04 |
| 462 | #define EWEN_ADDR 0x03C0 |
| 463 | #define EWDS 0x04 |
| 464 | #define EWDS_ADDR 0x0000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 466 | #define hp_bm_ctrl 0x26 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 468 | #define SCSI_TERM_ENA_L BIT(0) /*Enable/Disable external terminators */ |
| 469 | #define FLUSH_XFER_CNTR BIT(1) /*Flush transfer counter */ |
| 470 | #define FORCE1_XFER BIT(5) /*Always xfer one byte in byte mode */ |
| 471 | #define FAST_SINGLE BIT(6) /*?? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 473 | #define BMCTRL_DEFAULT (FORCE1_XFER|FAST_SINGLE|SCSI_TERM_ENA_L) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 475 | #define hp_sg_addr 0x28 |
| 476 | #define hp_page_ctrl 0x29 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 478 | #define SCATTER_EN BIT(0) |
| 479 | #define SGRAM_ARAM BIT(1) |
| 480 | #define G_INT_DISABLE BIT(3) /* Enable/Disable all Interrupts */ |
| 481 | #define NARROW_SCSI_CARD BIT(4) /* NARROW/WIDE SCSI config pin */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 483 | #define hp_pci_stat_cfg 0x2D |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 485 | #define REC_MASTER_ABORT BIT(5) /*received Master abort */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 487 | #define hp_rev_num 0x33 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 489 | #define hp_stack_data 0x34 |
| 490 | #define hp_stack_addr 0x35 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 492 | #define hp_ext_status 0x36 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 494 | #define BM_FORCE_OFF BIT(0) /*Bus Master is forced to get off */ |
| 495 | #define PCI_TGT_ABORT BIT(0) /*PCI bus master transaction aborted */ |
| 496 | #define PCI_DEV_TMOUT BIT(1) /*PCI Device Time out */ |
| 497 | #define CMD_ABORTED BIT(4) /*Command aborted */ |
| 498 | #define BM_PARITY_ERR BIT(5) /*parity error on data received */ |
| 499 | #define PIO_OVERRUN BIT(6) /*Slave data overrun */ |
| 500 | #define BM_CMD_BUSY BIT(7) /*Bus master transfer command busy */ |
| 501 | #define BAD_EXT_STATUS (BM_FORCE_OFF | PCI_DEV_TMOUT | CMD_ABORTED | \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | BM_PARITY_ERR | PIO_OVERRUN) |
| 503 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 504 | #define hp_int_status 0x37 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 506 | #define EXT_STATUS_ON BIT(1) /*Extended status is valid */ |
| 507 | #define SCSI_INTERRUPT BIT(2) /*Global indication of a SCSI int. */ |
| 508 | #define INT_ASSERTED BIT(5) /* */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 510 | #define hp_fifo_cnt 0x38 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 512 | #define hp_intena 0x40 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 514 | #define RESET BITW(7) |
| 515 | #define PROG_HLT BITW(6) |
| 516 | #define PARITY BITW(5) |
| 517 | #define FIFO BITW(4) |
| 518 | #define SEL BITW(3) |
| 519 | #define SCAM_SEL BITW(2) |
| 520 | #define RSEL BITW(1) |
| 521 | #define TIMEOUT BITW(0) |
| 522 | #define BUS_FREE BITW(15) |
| 523 | #define XFER_CNT_0 BITW(14) |
| 524 | #define PHASE BITW(13) |
| 525 | #define IUNKWN BITW(12) |
| 526 | #define ICMD_COMP BITW(11) |
| 527 | #define ITICKLE BITW(10) |
| 528 | #define IDO_STRT BITW(9) |
| 529 | #define ITAR_DISC BITW(8) |
| 530 | #define AUTO_INT (BITW(12)+BITW(11)+BITW(10)+BITW(9)+BITW(8)) |
| 531 | #define CLR_ALL_INT 0xFFFF |
| 532 | #define CLR_ALL_INT_1 0xFF00 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 534 | #define hp_intstat 0x42 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 536 | #define hp_scsisig 0x44 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 538 | #define SCSI_SEL BIT(7) |
| 539 | #define SCSI_BSY BIT(6) |
| 540 | #define SCSI_REQ BIT(5) |
| 541 | #define SCSI_ACK BIT(4) |
| 542 | #define SCSI_ATN BIT(3) |
| 543 | #define SCSI_CD BIT(2) |
| 544 | #define SCSI_MSG BIT(1) |
| 545 | #define SCSI_IOBIT BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 547 | #define S_SCSI_PHZ (BIT(2)+BIT(1)+BIT(0)) |
| 548 | #define S_MSGO_PH (BIT(2)+BIT(1) ) |
| 549 | #define S_MSGI_PH (BIT(2)+BIT(1)+BIT(0)) |
| 550 | #define S_DATAI_PH ( BIT(0)) |
| 551 | #define S_DATAO_PH 0x00 |
| 552 | #define S_ILL_PH ( BIT(1) ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 554 | #define hp_scsictrl_0 0x45 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 556 | #define SEL_TAR BIT(6) |
| 557 | #define ENA_ATN BIT(4) |
| 558 | #define ENA_RESEL BIT(2) |
| 559 | #define SCSI_RST BIT(1) |
| 560 | #define ENA_SCAM_SEL BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 562 | #define hp_portctrl_0 0x46 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 564 | #define SCSI_PORT BIT(7) |
| 565 | #define SCSI_INBIT BIT(6) |
| 566 | #define DMA_PORT BIT(5) |
| 567 | #define DMA_RD BIT(4) |
| 568 | #define HOST_PORT BIT(3) |
| 569 | #define HOST_WRT BIT(2) |
| 570 | #define SCSI_BUS_EN BIT(1) |
| 571 | #define START_TO BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 573 | #define hp_scsireset 0x47 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 575 | #define SCSI_INI BIT(6) |
| 576 | #define SCAM_EN BIT(5) |
| 577 | #define DMA_RESET BIT(3) |
| 578 | #define HPSCSI_RESET BIT(2) |
| 579 | #define PROG_RESET BIT(1) |
| 580 | #define FIFO_CLR BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 582 | #define hp_xfercnt_0 0x48 |
| 583 | #define hp_xfercnt_2 0x4A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 585 | #define hp_fifodata_0 0x4C |
| 586 | #define hp_addstat 0x4E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 588 | #define SCAM_TIMER BIT(7) |
| 589 | #define SCSI_MODE8 BIT(3) |
| 590 | #define SCSI_PAR_ERR BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 592 | #define hp_prgmcnt_0 0x4F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 594 | #define hp_selfid_0 0x50 |
| 595 | #define hp_selfid_1 0x51 |
| 596 | #define hp_arb_id 0x52 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 598 | #define hp_select_id 0x53 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 600 | #define hp_synctarg_base 0x54 |
| 601 | #define hp_synctarg_12 0x54 |
| 602 | #define hp_synctarg_13 0x55 |
| 603 | #define hp_synctarg_14 0x56 |
| 604 | #define hp_synctarg_15 0x57 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 606 | #define hp_synctarg_8 0x58 |
| 607 | #define hp_synctarg_9 0x59 |
| 608 | #define hp_synctarg_10 0x5A |
| 609 | #define hp_synctarg_11 0x5B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 611 | #define hp_synctarg_4 0x5C |
| 612 | #define hp_synctarg_5 0x5D |
| 613 | #define hp_synctarg_6 0x5E |
| 614 | #define hp_synctarg_7 0x5F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 616 | #define hp_synctarg_0 0x60 |
| 617 | #define hp_synctarg_1 0x61 |
| 618 | #define hp_synctarg_2 0x62 |
| 619 | #define hp_synctarg_3 0x63 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 621 | #define NARROW_SCSI BIT(4) |
| 622 | #define DEFAULT_OFFSET 0x0F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 624 | #define hp_autostart_0 0x64 |
| 625 | #define hp_autostart_1 0x65 |
| 626 | #define hp_autostart_3 0x67 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 628 | #define AUTO_IMMED BIT(5) |
| 629 | #define SELECT BIT(6) |
| 630 | #define END_DATA (BIT(7)+BIT(6)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 632 | #define hp_gp_reg_0 0x68 |
| 633 | #define hp_gp_reg_1 0x69 |
| 634 | #define hp_gp_reg_3 0x6B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 636 | #define hp_seltimeout 0x6C |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 638 | #define TO_4ms 0x67 /* 3.9959ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 640 | #define TO_5ms 0x03 /* 4.9152ms */ |
| 641 | #define TO_10ms 0x07 /* 11.xxxms */ |
| 642 | #define TO_250ms 0x99 /* 250.68ms */ |
| 643 | #define TO_290ms 0xB1 /* 289.99ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 645 | #define hp_clkctrl_0 0x6D |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 647 | #define PWR_DWN BIT(6) |
| 648 | #define ACTdeassert BIT(4) |
| 649 | #define CLK_40MHZ (BIT(1) + BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 651 | #define CLKCTRL_DEFAULT (ACTdeassert | CLK_40MHZ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 653 | #define hp_fiforead 0x6E |
| 654 | #define hp_fifowrite 0x6F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 656 | #define hp_offsetctr 0x70 |
| 657 | #define hp_xferstat 0x71 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 659 | #define FIFO_EMPTY BIT(6) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 661 | #define hp_portctrl_1 0x72 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 663 | #define CHK_SCSI_P BIT(3) |
| 664 | #define HOST_MODE8 BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 666 | #define hp_xfer_pad 0x73 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 668 | #define ID_UNLOCK BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 670 | #define hp_scsidata_0 0x74 |
| 671 | #define hp_scsidata_1 0x75 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 673 | #define hp_aramBase 0x80 |
| 674 | #define BIOS_DATA_OFFSET 0x60 |
| 675 | #define BIOS_RELATIVE_CARD 0x64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 677 | #define AR3 (BITW(9) + BITW(8)) |
| 678 | #define SDATA BITW(10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 680 | #define CRD_OP BITW(11) /* Cmp Reg. w/ Data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 682 | #define CRR_OP BITW(12) /* Cmp Reg. w. Reg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 684 | #define CPE_OP (BITW(14)+BITW(11)) /* Cmp SCSI phs & Branch EQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 686 | #define CPN_OP (BITW(14)+BITW(12)) /* Cmp SCSI phs & Branch NOT EQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 688 | #define ADATA_OUT 0x00 |
| 689 | #define ADATA_IN BITW(8) |
| 690 | #define ACOMMAND BITW(10) |
| 691 | #define ASTATUS (BITW(10)+BITW(8)) |
| 692 | #define AMSG_OUT (BITW(10)+BITW(9)) |
| 693 | #define AMSG_IN (BITW(10)+BITW(9)+BITW(8)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 695 | #define BRH_OP BITW(13) /* Branch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 697 | #define ALWAYS 0x00 |
| 698 | #define EQUAL BITW(8) |
| 699 | #define NOT_EQ BITW(9) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 701 | #define TCB_OP (BITW(13)+BITW(11)) /* Test condition & branch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 703 | #define FIFO_0 BITW(10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 705 | #define MPM_OP BITW(15) /* Match phase and move data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 707 | #define MRR_OP BITW(14) /* Move DReg. to Reg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 709 | #define S_IDREG (BIT(2)+BIT(1)+BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 711 | #define D_AR0 0x00 |
| 712 | #define D_AR1 BIT(0) |
| 713 | #define D_BUCKET (BIT(2) + BIT(1) + BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 715 | #define RAT_OP (BITW(14)+BITW(13)+BITW(11)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 717 | #define SSI_OP (BITW(15)+BITW(11)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 719 | #define SSI_ITAR_DISC (ITAR_DISC >> 8) |
| 720 | #define SSI_IDO_STRT (IDO_STRT >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 722 | #define SSI_ICMD_COMP (ICMD_COMP >> 8) |
| 723 | #define SSI_ITICKLE (ITICKLE >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 725 | #define SSI_IUNKWN (IUNKWN >> 8) |
| 726 | #define SSI_INO_CC (IUNKWN >> 8) |
| 727 | #define SSI_IRFAIL (IUNKWN >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 729 | #define NP 0x10 /*Next Phase */ |
| 730 | #define NTCMD 0x02 /*Non- Tagged Command start */ |
| 731 | #define CMDPZ 0x04 /*Command phase */ |
| 732 | #define DINT 0x12 /*Data Out/In interrupt */ |
| 733 | #define DI 0x13 /*Data Out */ |
| 734 | #define DC 0x19 /*Disconnect Message */ |
| 735 | #define ST 0x1D /*Status Phase */ |
| 736 | #define UNKNWN 0x24 /*Unknown bus action */ |
| 737 | #define CC 0x25 /*Command Completion failure */ |
| 738 | #define TICK 0x26 /*New target reselected us. */ |
| 739 | #define SELCHK 0x28 /*Select & Check SCSI ID latch reg */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 741 | #define ID_MSG_STRT hp_aramBase + 0x00 |
| 742 | #define NON_TAG_ID_MSG hp_aramBase + 0x06 |
| 743 | #define CMD_STRT hp_aramBase + 0x08 |
| 744 | #define SYNC_MSGS hp_aramBase + 0x08 |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 745 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 746 | #define TAG_STRT 0x00 |
| 747 | #define DISCONNECT_START 0x10/2 |
| 748 | #define END_DATA_START 0x14/2 |
| 749 | #define CMD_ONLY_STRT CMDPZ/2 |
| 750 | #define SELCHK_STRT SELCHK/2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | |
| 752 | #define GET_XFER_CNT(port, xfercnt) {RD_HARP32(port,hp_xfercnt_0,xfercnt); xfercnt &= 0xFFFFFF;} |
| 753 | /* #define GET_XFER_CNT(port, xfercnt) (xfercnt = RD_HARPOON(port+hp_xfercnt_2), \ |
| 754 | xfercnt <<= 16,\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 755 | xfercnt |= RDW_HARPOON((unsigned short)(port+hp_xfercnt_0))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | */ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 757 | #define HP_SETUP_ADDR_CNT(port,addr,count) (WRW_HARPOON((port+hp_host_addr_lo), (unsigned short)(addr & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | addr >>= 16,\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 759 | WRW_HARPOON((port+hp_host_addr_hmi), (unsigned short)(addr & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | WR_HARP32(port,hp_xfercnt_0,count),\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 761 | WRW_HARPOON((port+hp_xfer_cnt_lo), (unsigned short)(count & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | count >>= 16,\ |
| 763 | WR_HARPOON(port+hp_xfer_cnt_hi, (count & 0xFF))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | |
| 765 | #define ACCEPT_MSG(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\ |
| 766 | WR_HARPOON(port+hp_scsisig, S_ILL_PH);} |
| 767 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | #define ACCEPT_MSG_ATN(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\ |
| 769 | WR_HARPOON(port+hp_scsisig, (S_ILL_PH|SCSI_ATN));} |
| 770 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | #define DISABLE_AUTO(port) (WR_HARPOON(port+hp_scsireset, PROG_RESET),\ |
| 772 | WR_HARPOON(port+hp_scsireset, 0x00)) |
| 773 | |
| 774 | #define ARAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 775 | (RD_HARPOON(p_port+hp_page_ctrl) | SGRAM_ARAM))) |
| 776 | |
| 777 | #define SGRAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 778 | (RD_HARPOON(p_port+hp_page_ctrl) & ~SGRAM_ARAM))) |
| 779 | |
| 780 | #define MDISABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 781 | (RD_HARPOON(p_port+hp_page_ctrl) | G_INT_DISABLE))) |
| 782 | |
| 783 | #define MENABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 784 | (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE))) |
| 785 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 786 | static unsigned char FPT_sisyncn(unsigned long port, unsigned char p_card, |
| 787 | unsigned char syncFlag); |
| 788 | static void FPT_ssel(unsigned long port, unsigned char p_card); |
| 789 | static void FPT_sres(unsigned long port, unsigned char p_card, |
| 790 | struct sccb_card *pCurrCard); |
| 791 | static void FPT_shandem(unsigned long port, unsigned char p_card, |
| 792 | struct sccb *pCurrSCCB); |
| 793 | static void FPT_stsyncn(unsigned long port, unsigned char p_card); |
| 794 | static void FPT_sisyncr(unsigned long port, unsigned char sync_pulse, |
| 795 | unsigned char offset); |
| 796 | static void FPT_sssyncv(unsigned long p_port, unsigned char p_id, |
| 797 | unsigned char p_sync_value, |
| 798 | struct sccb_mgr_tar_info *currTar_Info); |
| 799 | static void FPT_sresb(unsigned long port, unsigned char p_card); |
| 800 | static void FPT_sxfrp(unsigned long p_port, unsigned char p_card); |
| 801 | static void FPT_schkdd(unsigned long port, unsigned char p_card); |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 802 | static unsigned char FPT_RdStack(unsigned long port, unsigned char index); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 803 | static void FPT_WrStack(unsigned long portBase, unsigned char index, |
| 804 | unsigned char data); |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 805 | static unsigned char FPT_ChkIfChipInitialized(unsigned long ioPort); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 807 | static void FPT_SendMsg(unsigned long port, unsigned char message); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 808 | static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg, |
| 809 | unsigned char error_code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 811 | static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card); |
| 812 | static void FPT_RNVRamData(struct nvram_info *pNvRamInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 814 | static unsigned char FPT_siwidn(unsigned long port, unsigned char p_card); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 815 | static void FPT_stwidn(unsigned long port, unsigned char p_card); |
| 816 | static void FPT_siwidr(unsigned long port, unsigned char width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 818 | static void FPT_queueSelectFail(struct sccb_card *pCurrCard, |
| 819 | unsigned char p_card); |
| 820 | static void FPT_queueDisconnect(struct sccb *p_SCCB, unsigned char p_card); |
| 821 | static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, |
| 822 | struct sccb *p_SCCB, unsigned char p_card); |
| 823 | static void FPT_queueSearchSelect(struct sccb_card *pCurrCard, |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 824 | unsigned char p_card); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 825 | static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code); |
| 826 | static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char card); |
| 827 | static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB, |
| 828 | unsigned char p_card); |
| 829 | static void FPT_utilUpdateResidual(struct sccb *p_SCCB); |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 830 | static unsigned short FPT_CalcCrc16(unsigned char buffer[]); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 831 | static unsigned char FPT_CalcLrc(unsigned char buffer[]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 833 | static void FPT_Wait1Second(unsigned long p_port); |
| 834 | static void FPT_Wait(unsigned long p_port, unsigned char p_delay); |
| 835 | static void FPT_utilEEWriteOnOff(unsigned long p_port, unsigned char p_mode); |
| 836 | static void FPT_utilEEWrite(unsigned long p_port, unsigned short ee_data, |
| 837 | unsigned short ee_addr); |
| 838 | static unsigned short FPT_utilEERead(unsigned long p_port, |
| 839 | unsigned short ee_addr); |
| 840 | static unsigned short FPT_utilEEReadOrg(unsigned long p_port, |
| 841 | unsigned short ee_addr); |
| 842 | static void FPT_utilEESendCmdAddr(unsigned long p_port, unsigned char ee_cmd, |
| 843 | unsigned short ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 845 | static void FPT_phaseDataOut(unsigned long port, unsigned char p_card); |
| 846 | static void FPT_phaseDataIn(unsigned long port, unsigned char p_card); |
| 847 | static void FPT_phaseCommand(unsigned long port, unsigned char p_card); |
| 848 | static void FPT_phaseStatus(unsigned long port, unsigned char p_card); |
| 849 | static void FPT_phaseMsgOut(unsigned long port, unsigned char p_card); |
| 850 | static void FPT_phaseMsgIn(unsigned long port, unsigned char p_card); |
| 851 | static void FPT_phaseIllegal(unsigned long port, unsigned char p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 853 | static void FPT_phaseDecode(unsigned long port, unsigned char p_card); |
| 854 | static void FPT_phaseChkFifo(unsigned long port, unsigned char p_card); |
| 855 | static void FPT_phaseBusFree(unsigned long p_port, unsigned char p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 857 | static void FPT_XbowInit(unsigned long port, unsigned char scamFlg); |
| 858 | static void FPT_BusMasterInit(unsigned long p_port); |
| 859 | static void FPT_DiagEEPROM(unsigned long p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 861 | static void FPT_dataXferProcessor(unsigned long port, |
| 862 | struct sccb_card *pCurrCard); |
| 863 | static void FPT_busMstrSGDataXferStart(unsigned long port, |
| 864 | struct sccb *pCurrSCCB); |
| 865 | static void FPT_busMstrDataXferStart(unsigned long port, |
| 866 | struct sccb *pCurrSCCB); |
| 867 | static void FPT_hostDataXferAbort(unsigned long port, unsigned char p_card, |
| 868 | struct sccb *pCurrSCCB); |
| 869 | static void FPT_hostDataXferRestart(struct sccb *currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 871 | static unsigned char FPT_SccbMgr_bad_isr(unsigned long p_port, |
| 872 | unsigned char p_card, |
| 873 | struct sccb_card *pCurrCard, |
| 874 | unsigned short p_int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 876 | static void FPT_SccbMgrTableInitAll(void); |
| 877 | static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard, |
| 878 | unsigned char p_card); |
| 879 | static void FPT_SccbMgrTableInitTarget(unsigned char p_card, |
| 880 | unsigned char target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 882 | static void FPT_scini(unsigned char p_card, unsigned char p_our_id, |
| 883 | unsigned char p_power_up); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 885 | static int FPT_scarb(unsigned long p_port, unsigned char p_sel_type); |
| 886 | static void FPT_scbusf(unsigned long p_port); |
| 887 | static void FPT_scsel(unsigned long p_port); |
| 888 | static void FPT_scasid(unsigned char p_card, unsigned long p_port); |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 889 | static unsigned char FPT_scxferc(unsigned long p_port, unsigned char p_data); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 890 | static unsigned char FPT_scsendi(unsigned long p_port, |
| 891 | unsigned char p_id_string[]); |
| 892 | static unsigned char FPT_sciso(unsigned long p_port, |
| 893 | unsigned char p_id_string[]); |
| 894 | static void FPT_scwirod(unsigned long p_port, unsigned char p_data_bit); |
| 895 | static void FPT_scwiros(unsigned long p_port, unsigned char p_data_bit); |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 896 | static unsigned char FPT_scvalq(unsigned char p_quintet); |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 897 | static unsigned char FPT_scsell(unsigned long p_port, unsigned char targ_id); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 898 | static void FPT_scwtsel(unsigned long p_port); |
| 899 | static void FPT_inisci(unsigned char p_card, unsigned long p_port, |
| 900 | unsigned char p_our_id); |
| 901 | static void FPT_scsavdi(unsigned char p_card, unsigned long p_port); |
| 902 | static unsigned char FPT_scmachid(unsigned char p_card, |
| 903 | unsigned char p_id_string[]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 905 | static void FPT_autoCmdCmplt(unsigned long p_port, unsigned char p_card); |
| 906 | static void FPT_autoLoadDefaultMap(unsigned long p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 908 | static struct sccb_mgr_tar_info FPT_sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR] = |
| 909 | { {{0}} }; |
| 910 | static struct sccb_card FPT_BL_Card[MAX_CARDS] = { {0} }; |
| 911 | static SCCBSCAM_INFO FPT_scamInfo[MAX_SCSI_TAR] = { {{0}} }; |
| 912 | static struct nvram_info FPT_nvRamInfo[MAX_MB_CARDS] = { {0} }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 914 | static unsigned char FPT_mbCards = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 915 | static unsigned char FPT_scamHAString[] = |
| 916 | { 0x63, 0x07, 'B', 'U', 'S', 'L', 'O', 'G', 'I', 'C', |
| 917 | ' ', 'B', 'T', '-', '9', '3', '0', |
| 918 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 919 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 |
| 920 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 922 | static unsigned short FPT_default_intena = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 924 | static void (*FPT_s_PhaseTbl[8]) (unsigned long, unsigned char) = { |
| 925 | 0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | |
| 927 | /*--------------------------------------------------------------------- |
| 928 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 929 | * Function: FlashPoint_ProbeHostAdapter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | * |
| 931 | * Description: Setup and/or Search for cards and return info to caller. |
| 932 | * |
| 933 | *---------------------------------------------------------------------*/ |
| 934 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 935 | static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 937 | static unsigned char first_time = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 939 | unsigned char i, j, id, ScamFlg; |
| 940 | unsigned short temp, temp2, temp3, temp4, temp5, temp6; |
| 941 | unsigned long ioport; |
| 942 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 944 | ioport = pCardInfo->si_baseaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 946 | if (RD_HARPOON(ioport + hp_vendor_id_0) != ORION_VEND_0) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 947 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 949 | if ((RD_HARPOON(ioport + hp_vendor_id_1) != ORION_VEND_1)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 950 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 952 | if ((RD_HARPOON(ioport + hp_device_id_0) != ORION_DEV_0)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 953 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 955 | if ((RD_HARPOON(ioport + hp_device_id_1) != ORION_DEV_1)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 956 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 958 | if (RD_HARPOON(ioport + hp_rev_num) != 0x0f) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | |
| 960 | /* For new Harpoon then check for sub_device ID LSB |
| 961 | the bits(0-3) must be all ZERO for compatible with |
| 962 | current version of SCCBMgr, else skip this Harpoon |
| 963 | device. */ |
| 964 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 965 | if (RD_HARPOON(ioport + hp_sub_device_id_0) & 0x0f) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 966 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | } |
| 968 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 969 | if (first_time) { |
| 970 | FPT_SccbMgrTableInitAll(); |
| 971 | first_time = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 972 | FPT_mbCards = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 973 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 975 | if (FPT_RdStack(ioport, 0) != 0x00) { |
| 976 | if (FPT_ChkIfChipInitialized(ioport) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | pCurrNvRam = NULL; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 978 | WR_HARPOON(ioport + hp_semaphore, 0x00); |
| 979 | FPT_XbowInit(ioport, 0); /*Must Init the SCSI before attempting */ |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 980 | FPT_DiagEEPROM(ioport); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 981 | } else { |
| 982 | if (FPT_mbCards < MAX_MB_CARDS) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 983 | pCurrNvRam = &FPT_nvRamInfo[FPT_mbCards]; |
| 984 | FPT_mbCards++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | pCurrNvRam->niBaseAddr = ioport; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 986 | FPT_RNVRamData(pCurrNvRam); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 987 | } else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 988 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 990 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | pCurrNvRam = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 993 | WR_HARPOON(ioport + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 994 | WR_HARPOON(ioport + hp_sys_ctrl, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 996 | if (pCurrNvRam) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | pCardInfo->si_id = pCurrNvRam->niAdapId; |
| 998 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 999 | pCardInfo->si_id = |
| 1000 | (unsigned |
| 1001 | char)(FPT_utilEERead(ioport, |
| 1002 | (ADAPTER_SCSI_ID / |
| 1003 | 2)) & (unsigned char)0x0FF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1005 | pCardInfo->si_lun = 0x00; |
| 1006 | pCardInfo->si_fw_revision = ORION_FW_REV; |
| 1007 | temp2 = 0x0000; |
| 1008 | temp3 = 0x0000; |
| 1009 | temp4 = 0x0000; |
| 1010 | temp5 = 0x0000; |
| 1011 | temp6 = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1013 | for (id = 0; id < (16 / 2); id++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1014 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1015 | if (pCurrNvRam) { |
| 1016 | temp = (unsigned short)pCurrNvRam->niSyncTbl[id]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) + |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1018 | (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000)); |
| 1019 | } else |
| 1020 | temp = |
| 1021 | FPT_utilEERead(ioport, |
| 1022 | (unsigned short)((SYNC_RATE_TBL / 2) |
| 1023 | + id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1025 | for (i = 0; i < 2; temp >>= 8, i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1027 | temp2 >>= 1; |
| 1028 | temp3 >>= 1; |
| 1029 | temp4 >>= 1; |
| 1030 | temp5 >>= 1; |
| 1031 | temp6 >>= 1; |
| 1032 | switch (temp & 0x3) { |
| 1033 | case AUTO_RATE_20: /* Synchronous, 20 mega-transfers/second */ |
| 1034 | temp6 |= 0x8000; /* Fall through */ |
| 1035 | case AUTO_RATE_10: /* Synchronous, 10 mega-transfers/second */ |
| 1036 | temp5 |= 0x8000; /* Fall through */ |
| 1037 | case AUTO_RATE_05: /* Synchronous, 5 mega-transfers/second */ |
| 1038 | temp2 |= 0x8000; /* Fall through */ |
| 1039 | case AUTO_RATE_00: /* Asynchronous */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | break; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | if (temp & DISC_ENABLE_BIT) |
| 1044 | temp3 |= 0x8000; |
| 1045 | |
| 1046 | if (temp & WIDE_NEGO_BIT) |
| 1047 | temp4 |= 0x8000; |
| 1048 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | } |
| 1051 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1052 | pCardInfo->si_per_targ_init_sync = temp2; |
| 1053 | pCardInfo->si_per_targ_no_disc = temp3; |
| 1054 | pCardInfo->si_per_targ_wide_nego = temp4; |
| 1055 | pCardInfo->si_per_targ_fast_nego = temp5; |
| 1056 | pCardInfo->si_per_targ_ultra_nego = temp6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1058 | if (pCurrNvRam) |
| 1059 | i = pCurrNvRam->niSysConf; |
| 1060 | else |
| 1061 | i = (unsigned |
| 1062 | char)(FPT_utilEERead(ioport, (SYSTEM_CONFIG / 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1064 | if (pCurrNvRam) |
| 1065 | ScamFlg = pCurrNvRam->niScamConf; |
| 1066 | else |
| 1067 | ScamFlg = |
| 1068 | (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1070 | pCardInfo->si_flags = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1072 | if (i & 0x01) |
| 1073 | pCardInfo->si_flags |= SCSI_PARITY_ENA; |
| 1074 | |
| 1075 | if (!(i & 0x02)) |
| 1076 | pCardInfo->si_flags |= SOFT_RESET; |
| 1077 | |
| 1078 | if (i & 0x10) |
| 1079 | pCardInfo->si_flags |= EXTENDED_TRANSLATION; |
| 1080 | |
| 1081 | if (ScamFlg & SCAM_ENABLED) |
| 1082 | pCardInfo->si_flags |= FLAG_SCAM_ENABLED; |
| 1083 | |
| 1084 | if (ScamFlg & SCAM_LEVEL2) |
| 1085 | pCardInfo->si_flags |= FLAG_SCAM_LEVEL2; |
| 1086 | |
| 1087 | j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L); |
| 1088 | if (i & 0x04) { |
| 1089 | j |= SCSI_TERM_ENA_L; |
| 1090 | } |
| 1091 | WR_HARPOON(ioport + hp_bm_ctrl, j); |
| 1092 | |
| 1093 | j = (RD_HARPOON(ioport + hp_ee_ctrl) & ~SCSI_TERM_ENA_H); |
| 1094 | if (i & 0x08) { |
| 1095 | j |= SCSI_TERM_ENA_H; |
| 1096 | } |
| 1097 | WR_HARPOON(ioport + hp_ee_ctrl, j); |
| 1098 | |
| 1099 | if (!(RD_HARPOON(ioport + hp_page_ctrl) & NARROW_SCSI_CARD)) |
| 1100 | |
| 1101 | pCardInfo->si_flags |= SUPPORT_16TAR_32LUN; |
| 1102 | |
| 1103 | pCardInfo->si_card_family = HARPOON_FAMILY; |
| 1104 | pCardInfo->si_bustype = BUSTYPE_PCI; |
| 1105 | |
| 1106 | if (pCurrNvRam) { |
| 1107 | pCardInfo->si_card_model[0] = '9'; |
| 1108 | switch (pCurrNvRam->niModel & 0x0f) { |
| 1109 | case MODEL_LT: |
| 1110 | pCardInfo->si_card_model[1] = '3'; |
| 1111 | pCardInfo->si_card_model[2] = '0'; |
| 1112 | break; |
| 1113 | case MODEL_LW: |
| 1114 | pCardInfo->si_card_model[1] = '5'; |
| 1115 | pCardInfo->si_card_model[2] = '0'; |
| 1116 | break; |
| 1117 | case MODEL_DL: |
| 1118 | pCardInfo->si_card_model[1] = '3'; |
| 1119 | pCardInfo->si_card_model[2] = '2'; |
| 1120 | break; |
| 1121 | case MODEL_DW: |
| 1122 | pCardInfo->si_card_model[1] = '5'; |
| 1123 | pCardInfo->si_card_model[2] = '2'; |
| 1124 | break; |
| 1125 | } |
| 1126 | } else { |
| 1127 | temp = FPT_utilEERead(ioport, (MODEL_NUMB_0 / 2)); |
| 1128 | pCardInfo->si_card_model[0] = (unsigned char)(temp >> 8); |
| 1129 | temp = FPT_utilEERead(ioport, (MODEL_NUMB_2 / 2)); |
| 1130 | |
| 1131 | pCardInfo->si_card_model[1] = (unsigned char)(temp & 0x00FF); |
| 1132 | pCardInfo->si_card_model[2] = (unsigned char)(temp >> 8); |
| 1133 | } |
| 1134 | |
| 1135 | if (pCardInfo->si_card_model[1] == '3') { |
| 1136 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1137 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1138 | } else if (pCardInfo->si_card_model[2] == '0') { |
| 1139 | temp = RD_HARPOON(ioport + hp_xfer_pad); |
| 1140 | WR_HARPOON(ioport + hp_xfer_pad, (temp & ~BIT(4))); |
| 1141 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1142 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1143 | WR_HARPOON(ioport + hp_xfer_pad, (temp | BIT(4))); |
| 1144 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1145 | pCardInfo->si_flags |= HIGH_BYTE_TERM; |
| 1146 | WR_HARPOON(ioport + hp_xfer_pad, temp); |
| 1147 | } else { |
| 1148 | temp = RD_HARPOON(ioport + hp_ee_ctrl); |
| 1149 | temp2 = RD_HARPOON(ioport + hp_xfer_pad); |
| 1150 | WR_HARPOON(ioport + hp_ee_ctrl, (temp | SEE_CS)); |
| 1151 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 | BIT(4))); |
| 1152 | temp3 = 0; |
| 1153 | for (i = 0; i < 8; i++) { |
| 1154 | temp3 <<= 1; |
| 1155 | if (!(RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))) |
| 1156 | temp3 |= 1; |
| 1157 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 & ~BIT(4))); |
| 1158 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 | BIT(4))); |
| 1159 | } |
| 1160 | WR_HARPOON(ioport + hp_ee_ctrl, temp); |
| 1161 | WR_HARPOON(ioport + hp_xfer_pad, temp2); |
| 1162 | if (!(temp3 & BIT(7))) |
| 1163 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1164 | if (!(temp3 & BIT(6))) |
| 1165 | pCardInfo->si_flags |= HIGH_BYTE_TERM; |
| 1166 | } |
| 1167 | |
| 1168 | ARAM_ACCESS(ioport); |
| 1169 | |
| 1170 | for (i = 0; i < 4; i++) { |
| 1171 | |
| 1172 | pCardInfo->si_XlatInfo[i] = |
| 1173 | RD_HARPOON(ioport + hp_aramBase + BIOS_DATA_OFFSET + i); |
| 1174 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | |
| 1176 | /* return with -1 if no sort, else return with |
| 1177 | logical card number sorted by BIOS (zero-based) */ |
| 1178 | |
| 1179 | pCardInfo->si_relative_cardnum = |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1180 | (unsigned |
| 1181 | char)(RD_HARPOON(ioport + hp_aramBase + BIOS_RELATIVE_CARD) - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1183 | SGRAM_ACCESS(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1184 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1185 | FPT_s_PhaseTbl[0] = FPT_phaseDataOut; |
| 1186 | FPT_s_PhaseTbl[1] = FPT_phaseDataIn; |
| 1187 | FPT_s_PhaseTbl[2] = FPT_phaseIllegal; |
| 1188 | FPT_s_PhaseTbl[3] = FPT_phaseIllegal; |
| 1189 | FPT_s_PhaseTbl[4] = FPT_phaseCommand; |
| 1190 | FPT_s_PhaseTbl[5] = FPT_phaseStatus; |
| 1191 | FPT_s_PhaseTbl[6] = FPT_phaseMsgOut; |
| 1192 | FPT_s_PhaseTbl[7] = FPT_phaseMsgIn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1194 | pCardInfo->si_present = 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1195 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1196 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | /*--------------------------------------------------------------------- |
| 1200 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1201 | * Function: FlashPoint_HardwareResetHostAdapter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | * |
| 1203 | * Description: Setup adapter for normal operation (hard reset). |
| 1204 | * |
| 1205 | *---------------------------------------------------------------------*/ |
| 1206 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1207 | static unsigned long FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info |
| 1208 | *pCardInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1210 | struct sccb_card *CurrCard = NULL; |
| 1211 | struct nvram_info *pCurrNvRam; |
| 1212 | unsigned char i, j, thisCard, ScamFlg; |
| 1213 | unsigned short temp, sync_bit_map, id; |
| 1214 | unsigned long ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1216 | ioport = pCardInfo->si_baseaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1218 | for (thisCard = 0; thisCard <= MAX_CARDS; thisCard++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1220 | if (thisCard == MAX_CARDS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1222 | return FAILURE; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1223 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1225 | if (FPT_BL_Card[thisCard].ioPort == ioport) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1227 | CurrCard = &FPT_BL_Card[thisCard]; |
| 1228 | FPT_SccbMgrTableInitCard(CurrCard, thisCard); |
| 1229 | break; |
| 1230 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1231 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1232 | else if (FPT_BL_Card[thisCard].ioPort == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1233 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1234 | FPT_BL_Card[thisCard].ioPort = ioport; |
| 1235 | CurrCard = &FPT_BL_Card[thisCard]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1236 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1237 | if (FPT_mbCards) |
| 1238 | for (i = 0; i < FPT_mbCards; i++) { |
| 1239 | if (CurrCard->ioPort == |
| 1240 | FPT_nvRamInfo[i].niBaseAddr) |
| 1241 | CurrCard->pNvRamInfo = |
| 1242 | &FPT_nvRamInfo[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1243 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1244 | FPT_SccbMgrTableInitCard(CurrCard, thisCard); |
| 1245 | CurrCard->cardIndex = thisCard; |
| 1246 | CurrCard->cardInfo = pCardInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1248 | break; |
| 1249 | } |
| 1250 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | |
| 1252 | pCurrNvRam = CurrCard->pNvRamInfo; |
| 1253 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1254 | if (pCurrNvRam) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | ScamFlg = pCurrNvRam->niScamConf; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1256 | } else { |
| 1257 | ScamFlg = |
| 1258 | (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | } |
| 1260 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1261 | FPT_BusMasterInit(ioport); |
| 1262 | FPT_XbowInit(ioport, ScamFlg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1264 | FPT_autoLoadDefaultMap(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1266 | for (i = 0, id = 0x01; i != pCardInfo->si_id; i++, id <<= 1) { |
| 1267 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1268 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1269 | WR_HARPOON(ioport + hp_selfid_0, id); |
| 1270 | WR_HARPOON(ioport + hp_selfid_1, 0x00); |
| 1271 | WR_HARPOON(ioport + hp_arb_id, pCardInfo->si_id); |
| 1272 | CurrCard->ourId = pCardInfo->si_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1274 | i = (unsigned char)pCardInfo->si_flags; |
| 1275 | if (i & SCSI_PARITY_ENA) |
| 1276 | WR_HARPOON(ioport + hp_portctrl_1, (HOST_MODE8 | CHK_SCSI_P)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1278 | j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L); |
| 1279 | if (i & LOW_BYTE_TERM) |
| 1280 | j |= SCSI_TERM_ENA_L; |
| 1281 | WR_HARPOON(ioport + hp_bm_ctrl, j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1283 | j = (RD_HARPOON(ioport + hp_ee_ctrl) & ~SCSI_TERM_ENA_H); |
| 1284 | if (i & HIGH_BYTE_TERM) |
| 1285 | j |= SCSI_TERM_ENA_H; |
| 1286 | WR_HARPOON(ioport + hp_ee_ctrl, j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1288 | if (!(pCardInfo->si_flags & SOFT_RESET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1290 | FPT_sresb(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1292 | FPT_scini(thisCard, pCardInfo->si_id, 0); |
| 1293 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1294 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1295 | if (pCardInfo->si_flags & POST_ALL_UNDERRRUNS) |
| 1296 | CurrCard->globalFlags |= F_NO_FILTER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1298 | if (pCurrNvRam) { |
| 1299 | if (pCurrNvRam->niSysConf & 0x10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1300 | CurrCard->globalFlags |= F_GREEN_PC; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1301 | } else { |
| 1302 | if (FPT_utilEERead(ioport, (SYSTEM_CONFIG / 2)) & GREEN_PC_ENA) |
| 1303 | CurrCard->globalFlags |= F_GREEN_PC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1304 | } |
| 1305 | |
| 1306 | /* Set global flag to indicate Re-Negotiation to be done on all |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1307 | ckeck condition */ |
| 1308 | if (pCurrNvRam) { |
| 1309 | if (pCurrNvRam->niScsiConf & 0x04) |
| 1310 | CurrCard->globalFlags |= F_DO_RENEGO; |
| 1311 | } else { |
| 1312 | if (FPT_utilEERead(ioport, (SCSI_CONFIG / 2)) & RENEGO_ENA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | CurrCard->globalFlags |= F_DO_RENEGO; |
| 1314 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1316 | if (pCurrNvRam) { |
| 1317 | if (pCurrNvRam->niScsiConf & 0x08) |
| 1318 | CurrCard->globalFlags |= F_CONLUN_IO; |
| 1319 | } else { |
| 1320 | if (FPT_utilEERead(ioport, (SCSI_CONFIG / 2)) & CONNIO_ENA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1321 | CurrCard->globalFlags |= F_CONLUN_IO; |
| 1322 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1323 | |
| 1324 | temp = pCardInfo->si_per_targ_no_disc; |
| 1325 | |
| 1326 | for (i = 0, id = 1; i < MAX_SCSI_TAR; i++, id <<= 1) { |
| 1327 | |
| 1328 | if (temp & id) |
| 1329 | FPT_sccbMgrTbl[thisCard][i].TarStatus |= TAR_ALLOW_DISC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | } |
| 1331 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1332 | sync_bit_map = 0x0001; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1334 | for (id = 0; id < (MAX_SCSI_TAR / 2); id++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1336 | if (pCurrNvRam) { |
| 1337 | temp = (unsigned short)pCurrNvRam->niSyncTbl[id]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) + |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1339 | (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000)); |
| 1340 | } else |
| 1341 | temp = |
| 1342 | FPT_utilEERead(ioport, |
| 1343 | (unsigned short)((SYNC_RATE_TBL / 2) |
| 1344 | + id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1346 | for (i = 0; i < 2; temp >>= 8, i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1348 | if (pCardInfo->si_per_targ_init_sync & sync_bit_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1349 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1350 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1351 | i].TarEEValue = |
| 1352 | (unsigned char)temp; |
| 1353 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1355 | else { |
| 1356 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1357 | i].TarStatus |= |
| 1358 | SYNC_SUPPORTED; |
| 1359 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1360 | i].TarEEValue = |
| 1361 | (unsigned char)(temp & ~EE_SYNC_MASK); |
| 1362 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | /* if ((pCardInfo->si_per_targ_wide_nego & sync_bit_map) || |
| 1365 | (id*2+i >= 8)){ |
| 1366 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1367 | if (pCardInfo->si_per_targ_wide_nego & sync_bit_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1369 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1370 | i].TarEEValue |= |
| 1371 | EE_WIDE_SCSI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1373 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1375 | else { /* NARROW SCSI */ |
| 1376 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1377 | i].TarStatus |= |
| 1378 | WIDE_NEGOCIATED; |
| 1379 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1381 | sync_bit_map <<= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1382 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1383 | } |
| 1384 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1386 | WR_HARPOON((ioport + hp_semaphore), |
| 1387 | (unsigned char)(RD_HARPOON((ioport + hp_semaphore)) | |
| 1388 | SCCB_MGR_PRESENT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1390 | return (unsigned long)CurrCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | } |
| 1392 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1393 | static void FlashPoint_ReleaseHostAdapter(unsigned long pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1395 | unsigned char i; |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1396 | unsigned long portBase; |
| 1397 | unsigned long regOffset; |
| 1398 | unsigned long scamData; |
| 1399 | unsigned long *pScamTbl; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1400 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1401 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1402 | pCurrNvRam = ((struct sccb_card *)pCurrCard)->pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1403 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1404 | if (pCurrNvRam) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 1405 | FPT_WrStack(pCurrNvRam->niBaseAddr, 0, pCurrNvRam->niModel); |
| 1406 | FPT_WrStack(pCurrNvRam->niBaseAddr, 1, pCurrNvRam->niSysConf); |
| 1407 | FPT_WrStack(pCurrNvRam->niBaseAddr, 2, pCurrNvRam->niScsiConf); |
| 1408 | FPT_WrStack(pCurrNvRam->niBaseAddr, 3, pCurrNvRam->niScamConf); |
| 1409 | FPT_WrStack(pCurrNvRam->niBaseAddr, 4, pCurrNvRam->niAdapId); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1410 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1411 | for (i = 0; i < MAX_SCSI_TAR / 2; i++) |
| 1412 | FPT_WrStack(pCurrNvRam->niBaseAddr, |
| 1413 | (unsigned char)(i + 5), |
| 1414 | pCurrNvRam->niSyncTbl[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1415 | |
| 1416 | portBase = pCurrNvRam->niBaseAddr; |
| 1417 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1418 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 1419 | regOffset = hp_aramBase + 64 + i * 4; |
| 1420 | pScamTbl = (unsigned long *)&pCurrNvRam->niScamTbl[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1421 | scamData = *pScamTbl; |
| 1422 | WR_HARP32(portBase, regOffset, scamData); |
| 1423 | } |
| 1424 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1425 | } else { |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1426 | FPT_WrStack(((struct sccb_card *)pCurrCard)->ioPort, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1427 | } |
| 1428 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1430 | static void FPT_RNVRamData(struct nvram_info *pNvRamInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1432 | unsigned char i; |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1433 | unsigned long portBase; |
| 1434 | unsigned long regOffset; |
| 1435 | unsigned long scamData; |
| 1436 | unsigned long *pScamTbl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1438 | pNvRamInfo->niModel = FPT_RdStack(pNvRamInfo->niBaseAddr, 0); |
| 1439 | pNvRamInfo->niSysConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 1); |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 1440 | pNvRamInfo->niScsiConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 2); |
| 1441 | pNvRamInfo->niScamConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 3); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1442 | pNvRamInfo->niAdapId = FPT_RdStack(pNvRamInfo->niBaseAddr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1443 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1444 | for (i = 0; i < MAX_SCSI_TAR / 2; i++) |
| 1445 | pNvRamInfo->niSyncTbl[i] = |
| 1446 | FPT_RdStack(pNvRamInfo->niBaseAddr, (unsigned char)(i + 5)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | |
| 1448 | portBase = pNvRamInfo->niBaseAddr; |
| 1449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1450 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 1451 | regOffset = hp_aramBase + 64 + i * 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1452 | RD_HARP32(portBase, regOffset, scamData); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1453 | pScamTbl = (unsigned long *)&pNvRamInfo->niScamTbl[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | *pScamTbl = scamData; |
| 1455 | } |
| 1456 | |
| 1457 | } |
| 1458 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1459 | static unsigned char FPT_RdStack(unsigned long portBase, unsigned char index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1460 | { |
| 1461 | WR_HARPOON(portBase + hp_stack_addr, index); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1462 | return RD_HARPOON(portBase + hp_stack_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1463 | } |
| 1464 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1465 | static void FPT_WrStack(unsigned long portBase, unsigned char index, |
| 1466 | unsigned char data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | { |
| 1468 | WR_HARPOON(portBase + hp_stack_addr, index); |
| 1469 | WR_HARPOON(portBase + hp_stack_data, data); |
| 1470 | } |
| 1471 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1472 | static unsigned char FPT_ChkIfChipInitialized(unsigned long ioPort) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1474 | if ((RD_HARPOON(ioPort + hp_arb_id) & 0x0f) != FPT_RdStack(ioPort, 4)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1475 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1476 | if ((RD_HARPOON(ioPort + hp_clkctrl_0) & CLKCTRL_DEFAULT) |
| 1477 | != CLKCTRL_DEFAULT) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1478 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1479 | if ((RD_HARPOON(ioPort + hp_seltimeout) == TO_250ms) || |
| 1480 | (RD_HARPOON(ioPort + hp_seltimeout) == TO_290ms)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1481 | return 1; |
| 1482 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | |
| 1484 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1485 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | /*--------------------------------------------------------------------- |
| 1487 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1488 | * Function: FlashPoint_StartCCB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | * |
| 1490 | * Description: Start a command pointed to by p_Sccb. When the |
| 1491 | * command is completed it will be returned via the |
| 1492 | * callback function. |
| 1493 | * |
| 1494 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1495 | static void FlashPoint_StartCCB(unsigned long pCurrCard, struct sccb *p_Sccb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1496 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1497 | unsigned long ioport; |
| 1498 | unsigned char thisCard, lun; |
| 1499 | struct sccb *pSaveSccb; |
| 1500 | CALL_BK_FN callback; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1502 | thisCard = ((struct sccb_card *)pCurrCard)->cardIndex; |
| 1503 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1505 | if ((p_Sccb->TargID > MAX_SCSI_TAR) || (p_Sccb->Lun > MAX_LUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | p_Sccb->HostStatus = SCCB_COMPLETE; |
| 1508 | p_Sccb->SccbStatus = SCCB_ERROR; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1509 | callback = (CALL_BK_FN) p_Sccb->SccbCallback; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | if (callback) |
| 1511 | callback(p_Sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1513 | return; |
| 1514 | } |
| 1515 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1516 | FPT_sinits(p_Sccb, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1518 | if (!((struct sccb_card *)pCurrCard)->cmdCounter) { |
| 1519 | WR_HARPOON(ioport + hp_semaphore, |
| 1520 | (RD_HARPOON(ioport + hp_semaphore) |
| 1521 | | SCCB_MGR_ACTIVE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1523 | if (((struct sccb_card *)pCurrCard)->globalFlags & F_GREEN_PC) { |
| 1524 | WR_HARPOON(ioport + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 1525 | WR_HARPOON(ioport + hp_sys_ctrl, 0x00); |
| 1526 | } |
| 1527 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1529 | ((struct sccb_card *)pCurrCard)->cmdCounter++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1531 | if (RD_HARPOON(ioport + hp_semaphore) & BIOS_IN_USE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1533 | WR_HARPOON(ioport + hp_semaphore, |
| 1534 | (RD_HARPOON(ioport + hp_semaphore) |
| 1535 | | TICKLE_ME)); |
| 1536 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1537 | pSaveSccb = |
| 1538 | ((struct sccb_card *)pCurrCard)->currentSCCB; |
| 1539 | ((struct sccb_card *)pCurrCard)->currentSCCB = p_Sccb; |
| 1540 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], thisCard); |
| 1541 | ((struct sccb_card *)pCurrCard)->currentSCCB = |
| 1542 | pSaveSccb; |
| 1543 | } else { |
| 1544 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1545 | } |
| 1546 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1548 | else if ((RD_HARPOON(ioport + hp_page_ctrl) & G_INT_DISABLE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1549 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1550 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1551 | pSaveSccb = |
| 1552 | ((struct sccb_card *)pCurrCard)->currentSCCB; |
| 1553 | ((struct sccb_card *)pCurrCard)->currentSCCB = p_Sccb; |
| 1554 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], thisCard); |
| 1555 | ((struct sccb_card *)pCurrCard)->currentSCCB = |
| 1556 | pSaveSccb; |
| 1557 | } else { |
| 1558 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1559 | } |
| 1560 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1562 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1564 | MDISABLE_INT(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1566 | if ((((struct sccb_card *)pCurrCard)->globalFlags & F_CONLUN_IO) |
| 1567 | && |
| 1568 | ((FPT_sccbMgrTbl[thisCard][p_Sccb->TargID]. |
| 1569 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1570 | lun = p_Sccb->Lun; |
| 1571 | else |
| 1572 | lun = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1573 | if ((((struct sccb_card *)pCurrCard)->currentSCCB == NULL) && |
| 1574 | (FPT_sccbMgrTbl[thisCard][p_Sccb->TargID].TarSelQ_Cnt == 0) |
| 1575 | && (FPT_sccbMgrTbl[thisCard][p_Sccb->TargID].TarLUNBusy[lun] |
| 1576 | == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1577 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1578 | ((struct sccb_card *)pCurrCard)->currentSCCB = p_Sccb; |
| 1579 | FPT_ssel(p_Sccb->SccbIOPort, thisCard); |
| 1580 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1581 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1582 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1583 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1584 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1585 | pSaveSccb = |
| 1586 | ((struct sccb_card *)pCurrCard)-> |
| 1587 | currentSCCB; |
| 1588 | ((struct sccb_card *)pCurrCard)->currentSCCB = |
| 1589 | p_Sccb; |
| 1590 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], |
| 1591 | thisCard); |
| 1592 | ((struct sccb_card *)pCurrCard)->currentSCCB = |
| 1593 | pSaveSccb; |
| 1594 | } else { |
| 1595 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1596 | } |
| 1597 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1598 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1599 | MENABLE_INT(ioport); |
| 1600 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1602 | } |
| 1603 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1604 | /*--------------------------------------------------------------------- |
| 1605 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1606 | * Function: FlashPoint_AbortCCB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | * |
| 1608 | * Description: Abort the command pointed to by p_Sccb. When the |
| 1609 | * command is completed it will be returned via the |
| 1610 | * callback function. |
| 1611 | * |
| 1612 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1613 | static int FlashPoint_AbortCCB(unsigned long pCurrCard, struct sccb *p_Sccb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | { |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1615 | unsigned long ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1616 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1617 | unsigned char thisCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1618 | CALL_BK_FN callback; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1619 | unsigned char TID; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1620 | struct sccb *pSaveSCCB; |
| 1621 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1622 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1623 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1624 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1625 | thisCard = ((struct sccb_card *)pCurrCard)->cardIndex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1626 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1627 | if (!(RD_HARPOON(ioport + hp_page_ctrl) & G_INT_DISABLE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1628 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1629 | if (FPT_queueFindSccb(p_Sccb, thisCard)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1631 | ((struct sccb_card *)pCurrCard)->cmdCounter--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1633 | if (!((struct sccb_card *)pCurrCard)->cmdCounter) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1634 | WR_HARPOON(ioport + hp_semaphore, |
| 1635 | (RD_HARPOON(ioport + hp_semaphore) |
| 1636 | & (unsigned |
| 1637 | char)(~(SCCB_MGR_ACTIVE | |
| 1638 | TICKLE_ME)))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | p_Sccb->SccbStatus = SCCB_ABORT; |
| 1641 | callback = p_Sccb->SccbCallback; |
| 1642 | callback(p_Sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1643 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1644 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1645 | } |
| 1646 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1647 | else { |
| 1648 | if (((struct sccb_card *)pCurrCard)->currentSCCB == |
| 1649 | p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1651 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | |
| 1653 | } |
| 1654 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1655 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1656 | |
| 1657 | TID = p_Sccb->TargID; |
| 1658 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1659 | if (p_Sccb->Sccb_tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | MDISABLE_INT(ioport); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1661 | if (((struct sccb_card *)pCurrCard)-> |
| 1662 | discQ_Tbl[p_Sccb->Sccb_tag] == |
| 1663 | p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1665 | p_Sccb->Sccb_scsistat = |
| 1666 | ABORT_ST; |
| 1667 | p_Sccb->Sccb_scsimsg = |
| 1668 | SMABORT_TAG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1670 | if (((struct sccb_card *) |
| 1671 | pCurrCard)->currentSCCB == |
| 1672 | NULL) { |
| 1673 | ((struct sccb_card *) |
| 1674 | pCurrCard)-> |
| 1675 | currentSCCB = p_Sccb; |
| 1676 | FPT_ssel(ioport, |
| 1677 | thisCard); |
| 1678 | } else { |
| 1679 | pSaveSCCB = |
| 1680 | ((struct sccb_card |
| 1681 | *)pCurrCard)-> |
| 1682 | currentSCCB; |
| 1683 | ((struct sccb_card *) |
| 1684 | pCurrCard)-> |
| 1685 | currentSCCB = p_Sccb; |
| 1686 | FPT_queueSelectFail((struct sccb_card *)pCurrCard, thisCard); |
| 1687 | ((struct sccb_card *) |
| 1688 | pCurrCard)-> |
| 1689 | currentSCCB = pSaveSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1690 | } |
| 1691 | } |
| 1692 | MENABLE_INT(ioport); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1693 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1694 | } else { |
| 1695 | currTar_Info = |
| 1696 | &FPT_sccbMgrTbl[thisCard][p_Sccb-> |
| 1697 | TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1698 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1699 | if (FPT_BL_Card[thisCard]. |
| 1700 | discQ_Tbl[currTar_Info-> |
| 1701 | LunDiscQ_Idx[p_Sccb->Lun]] |
| 1702 | == p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1704 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1705 | } |
| 1706 | } |
| 1707 | } |
| 1708 | } |
| 1709 | } |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1710 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | } |
| 1712 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | /*--------------------------------------------------------------------- |
| 1714 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1715 | * Function: FlashPoint_InterruptPending |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1716 | * |
| 1717 | * Description: Do a quick check to determine if there is a pending |
| 1718 | * interrupt for this card and disable the IRQ Pin if so. |
| 1719 | * |
| 1720 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1721 | static unsigned char FlashPoint_InterruptPending(unsigned long pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1722 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1723 | unsigned long ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1724 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1725 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1727 | if (RD_HARPOON(ioport + hp_int_status) & INT_ASSERTED) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1728 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1729 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1730 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1731 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1732 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1733 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1734 | } |
| 1735 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | /*--------------------------------------------------------------------- |
| 1737 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1738 | * Function: FlashPoint_HandleInterrupt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | * |
| 1740 | * Description: This is our entry point when an interrupt is generated |
| 1741 | * by the card and the upper level driver passes it on to |
| 1742 | * us. |
| 1743 | * |
| 1744 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1745 | static int FlashPoint_HandleInterrupt(unsigned long pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1746 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1747 | struct sccb *currSCCB; |
| 1748 | unsigned char thisCard, result, bm_status, bm_int_st; |
| 1749 | unsigned short hp_int; |
| 1750 | unsigned char i, target; |
| 1751 | unsigned long ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1752 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1753 | thisCard = ((struct sccb_card *)pCurrCard)->cardIndex; |
| 1754 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1755 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1756 | MDISABLE_INT(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1757 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1758 | if ((bm_int_st = RD_HARPOON(ioport + hp_int_status)) & EXT_STATUS_ON) |
| 1759 | bm_status = |
| 1760 | RD_HARPOON(ioport + |
| 1761 | hp_ext_status) & (unsigned char)BAD_EXT_STATUS; |
| 1762 | else |
| 1763 | bm_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1764 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1765 | WR_HARPOON(ioport + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1767 | while ((hp_int = |
| 1768 | RDW_HARPOON((ioport + |
| 1769 | hp_intstat)) & FPT_default_intena) | bm_status) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1770 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1771 | currSCCB = ((struct sccb_card *)pCurrCard)->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1772 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1773 | if (hp_int & (FIFO | TIMEOUT | RESET | SCAM_SEL) || bm_status) { |
| 1774 | result = |
| 1775 | FPT_SccbMgr_bad_isr(ioport, thisCard, |
| 1776 | ((struct sccb_card *)pCurrCard), |
| 1777 | hp_int); |
| 1778 | WRW_HARPOON((ioport + hp_intstat), |
| 1779 | (FIFO | TIMEOUT | RESET | SCAM_SEL)); |
| 1780 | bm_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1781 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1782 | if (result) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1783 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1784 | MENABLE_INT(ioport); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1785 | return result; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1786 | } |
| 1787 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1789 | else if (hp_int & ICMD_COMP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1790 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1791 | if (!(hp_int & BUS_FREE)) { |
| 1792 | /* Wait for the BusFree before starting a new command. We |
| 1793 | must also check for being reselected since the BusFree |
| 1794 | may not show up if another device reselects us in 1.5us or |
| 1795 | less. SRR Wednesday, 3/8/1995. |
| 1796 | */ |
| 1797 | while (! |
| 1798 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1799 | (BUS_FREE | RSEL))) ; |
| 1800 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1801 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1802 | if (((struct sccb_card *)pCurrCard)-> |
| 1803 | globalFlags & F_HOST_XFER_ACT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1804 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1805 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1806 | |
| 1807 | /* WRW_HARPOON((ioport+hp_intstat), |
| 1808 | (BUS_FREE | ICMD_COMP | ITAR_DISC | XFER_CNT_0)); |
| 1809 | */ |
| 1810 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1811 | WRW_HARPOON((ioport + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1812 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1813 | FPT_autoCmdCmplt(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1814 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1815 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1817 | else if (hp_int & ITAR_DISC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1818 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1819 | if (((struct sccb_card *)pCurrCard)-> |
| 1820 | globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1821 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1822 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1823 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | } |
| 1825 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1826 | if (RD_HARPOON(ioport + hp_gp_reg_1) == SMSAVE_DATA_PTR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1827 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1828 | WR_HARPOON(ioport + hp_gp_reg_1, 0x00); |
| 1829 | currSCCB->Sccb_XferState |= F_NO_DATA_YET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1830 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1831 | currSCCB->Sccb_savedATC = currSCCB->Sccb_ATC; |
| 1832 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1833 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1834 | currSCCB->Sccb_scsistat = DISCONNECT_ST; |
| 1835 | FPT_queueDisconnect(currSCCB, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1837 | /* Wait for the BusFree before starting a new command. We |
| 1838 | must also check for being reselected since the BusFree |
| 1839 | may not show up if another device reselects us in 1.5us or |
| 1840 | less. SRR Wednesday, 3/8/1995. |
| 1841 | */ |
| 1842 | while (! |
| 1843 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1844 | (BUS_FREE | RSEL)) |
| 1845 | && !((RDW_HARPOON((ioport + hp_intstat)) & PHASE) |
| 1846 | && RD_HARPOON((ioport + hp_scsisig)) == |
| 1847 | (SCSI_BSY | SCSI_REQ | SCSI_CD | SCSI_MSG | |
| 1848 | SCSI_IOBIT))) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1849 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1850 | /* |
| 1851 | The additional loop exit condition above detects a timing problem |
| 1852 | with the revision D/E harpoon chips. The caller should reset the |
| 1853 | host adapter to recover when 0xFE is returned. |
| 1854 | */ |
| 1855 | if (! |
| 1856 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1857 | (BUS_FREE | RSEL))) { |
| 1858 | MENABLE_INT(ioport); |
| 1859 | return 0xFE; |
| 1860 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1861 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1862 | WRW_HARPOON((ioport + hp_intstat), |
| 1863 | (BUS_FREE | ITAR_DISC)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1864 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1865 | ((struct sccb_card *)pCurrCard)->globalFlags |= |
| 1866 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1867 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1868 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1869 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1870 | else if (hp_int & RSEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1871 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1872 | WRW_HARPOON((ioport + hp_intstat), |
| 1873 | (PROG_HLT | RSEL | PHASE | BUS_FREE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1874 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1875 | if (RDW_HARPOON((ioport + hp_intstat)) & ITAR_DISC) { |
| 1876 | if (((struct sccb_card *)pCurrCard)-> |
| 1877 | globalFlags & F_HOST_XFER_ACT) { |
| 1878 | FPT_phaseChkFifo(ioport, thisCard); |
| 1879 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1880 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1881 | if (RD_HARPOON(ioport + hp_gp_reg_1) == |
| 1882 | SMSAVE_DATA_PTR) { |
| 1883 | WR_HARPOON(ioport + hp_gp_reg_1, 0x00); |
| 1884 | currSCCB->Sccb_XferState |= |
| 1885 | F_NO_DATA_YET; |
| 1886 | currSCCB->Sccb_savedATC = |
| 1887 | currSCCB->Sccb_ATC; |
| 1888 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1889 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1890 | WRW_HARPOON((ioport + hp_intstat), |
| 1891 | (BUS_FREE | ITAR_DISC)); |
| 1892 | currSCCB->Sccb_scsistat = DISCONNECT_ST; |
| 1893 | FPT_queueDisconnect(currSCCB, thisCard); |
| 1894 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1895 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1896 | FPT_sres(ioport, thisCard, |
| 1897 | ((struct sccb_card *)pCurrCard)); |
| 1898 | FPT_phaseDecode(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1899 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1900 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1901 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1902 | else if ((hp_int & IDO_STRT) && (!(hp_int & BUS_FREE))) { |
| 1903 | |
| 1904 | WRW_HARPOON((ioport + hp_intstat), |
| 1905 | (IDO_STRT | XFER_CNT_0)); |
| 1906 | FPT_phaseDecode(ioport, thisCard); |
| 1907 | |
| 1908 | } |
| 1909 | |
| 1910 | else if ((hp_int & IUNKWN) || (hp_int & PROG_HLT)) { |
| 1911 | WRW_HARPOON((ioport + hp_intstat), |
| 1912 | (PHASE | IUNKWN | PROG_HLT)); |
| 1913 | if ((RD_HARPOON(ioport + hp_prgmcnt_0) & (unsigned char) |
| 1914 | 0x3f) < (unsigned char)SELCHK) { |
| 1915 | FPT_phaseDecode(ioport, thisCard); |
| 1916 | } else { |
| 1917 | /* Harpoon problem some SCSI target device respond to selection |
| 1918 | with short BUSY pulse (<400ns) this will make the Harpoon is not able |
| 1919 | to latch the correct Target ID into reg. x53. |
| 1920 | The work around require to correct this reg. But when write to this |
| 1921 | reg. (0x53) also increment the FIFO write addr reg (0x6f), thus we |
| 1922 | need to read this reg first then restore it later. After update to 0x53 */ |
| 1923 | |
| 1924 | i = (unsigned |
| 1925 | char)(RD_HARPOON(ioport + hp_fifowrite)); |
| 1926 | target = |
| 1927 | (unsigned |
| 1928 | char)(RD_HARPOON(ioport + hp_gp_reg_3)); |
| 1929 | WR_HARPOON(ioport + hp_xfer_pad, |
| 1930 | (unsigned char)ID_UNLOCK); |
| 1931 | WR_HARPOON(ioport + hp_select_id, |
| 1932 | (unsigned char)(target | target << |
| 1933 | 4)); |
| 1934 | WR_HARPOON(ioport + hp_xfer_pad, |
| 1935 | (unsigned char)0x00); |
| 1936 | WR_HARPOON(ioport + hp_fifowrite, i); |
| 1937 | WR_HARPOON(ioport + hp_autostart_3, |
| 1938 | (AUTO_IMMED + TAG_STRT)); |
| 1939 | } |
| 1940 | } |
| 1941 | |
| 1942 | else if (hp_int & XFER_CNT_0) { |
| 1943 | |
| 1944 | WRW_HARPOON((ioport + hp_intstat), XFER_CNT_0); |
| 1945 | |
| 1946 | FPT_schkdd(ioport, thisCard); |
| 1947 | |
| 1948 | } |
| 1949 | |
| 1950 | else if (hp_int & BUS_FREE) { |
| 1951 | |
| 1952 | WRW_HARPOON((ioport + hp_intstat), BUS_FREE); |
| 1953 | |
| 1954 | if (((struct sccb_card *)pCurrCard)-> |
| 1955 | globalFlags & F_HOST_XFER_ACT) { |
| 1956 | |
| 1957 | FPT_hostDataXferAbort(ioport, thisCard, |
| 1958 | currSCCB); |
| 1959 | } |
| 1960 | |
| 1961 | FPT_phaseBusFree(ioport, thisCard); |
| 1962 | } |
| 1963 | |
| 1964 | else if (hp_int & ITICKLE) { |
| 1965 | |
| 1966 | WRW_HARPOON((ioport + hp_intstat), ITICKLE); |
| 1967 | ((struct sccb_card *)pCurrCard)->globalFlags |= |
| 1968 | F_NEW_SCCB_CMD; |
| 1969 | } |
| 1970 | |
| 1971 | if (((struct sccb_card *)pCurrCard)-> |
| 1972 | globalFlags & F_NEW_SCCB_CMD) { |
| 1973 | |
| 1974 | ((struct sccb_card *)pCurrCard)->globalFlags &= |
| 1975 | ~F_NEW_SCCB_CMD; |
| 1976 | |
| 1977 | if (((struct sccb_card *)pCurrCard)->currentSCCB == |
| 1978 | NULL) { |
| 1979 | |
| 1980 | FPT_queueSearchSelect(((struct sccb_card *) |
| 1981 | pCurrCard), thisCard); |
| 1982 | } |
| 1983 | |
| 1984 | if (((struct sccb_card *)pCurrCard)->currentSCCB != |
| 1985 | NULL) { |
| 1986 | ((struct sccb_card *)pCurrCard)->globalFlags &= |
| 1987 | ~F_NEW_SCCB_CMD; |
| 1988 | FPT_ssel(ioport, thisCard); |
| 1989 | } |
| 1990 | |
| 1991 | break; |
| 1992 | |
| 1993 | } |
| 1994 | |
| 1995 | } /*end while */ |
| 1996 | |
| 1997 | MENABLE_INT(ioport); |
| 1998 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1999 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | } |
| 2001 | |
| 2002 | /*--------------------------------------------------------------------- |
| 2003 | * |
| 2004 | * Function: Sccb_bad_isr |
| 2005 | * |
| 2006 | * Description: Some type of interrupt has occurred which is slightly |
| 2007 | * out of the ordinary. We will now decode it fully, in |
| 2008 | * this routine. This is broken up in an attempt to save |
| 2009 | * processing time. |
| 2010 | * |
| 2011 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2012 | static unsigned char FPT_SccbMgr_bad_isr(unsigned long p_port, |
| 2013 | unsigned char p_card, |
| 2014 | struct sccb_card *pCurrCard, |
| 2015 | unsigned short p_int) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2016 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2017 | unsigned char temp, ScamFlg; |
| 2018 | struct sccb_mgr_tar_info *currTar_Info; |
| 2019 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2020 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2021 | if (RD_HARPOON(p_port + hp_ext_status) & |
| 2022 | (BM_FORCE_OFF | PCI_DEV_TMOUT | BM_PARITY_ERR | PIO_OVERRUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2023 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2024 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2026 | FPT_hostDataXferAbort(p_port, p_card, |
| 2027 | pCurrCard->currentSCCB); |
| 2028 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2029 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2030 | if (RD_HARPOON(p_port + hp_pci_stat_cfg) & REC_MASTER_ABORT) |
| 2031 | { |
| 2032 | WR_HARPOON(p_port + hp_pci_stat_cfg, |
| 2033 | (RD_HARPOON(p_port + hp_pci_stat_cfg) & |
| 2034 | ~REC_MASTER_ABORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2035 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2036 | WR_HARPOON(p_port + hp_host_blk_cnt, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2037 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2038 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2039 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2040 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2041 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2042 | if (!pCurrCard->currentSCCB->HostStatus) |
| 2043 | pCurrCard->currentSCCB->HostStatus = |
| 2044 | SCCB_BM_ERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2045 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2046 | FPT_sxfrp(p_port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2048 | temp = (unsigned char)(RD_HARPOON(p_port + hp_ee_ctrl) & |
| 2049 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)); |
| 2050 | WR_HARPOON(p_port + hp_ee_ctrl, |
| 2051 | ((unsigned char)temp | SEE_MS | SEE_CS)); |
| 2052 | WR_HARPOON(p_port + hp_ee_ctrl, temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2053 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2054 | if (! |
| 2055 | (RDW_HARPOON((p_port + hp_intstat)) & |
| 2056 | (BUS_FREE | RESET))) { |
| 2057 | FPT_phaseDecode(p_port, p_card); |
| 2058 | } |
| 2059 | } |
| 2060 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2062 | else if (p_int & RESET) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2063 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2064 | WR_HARPOON(p_port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 2065 | WR_HARPOON(p_port + hp_sys_ctrl, 0x00); |
| 2066 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2067 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2068 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2070 | FPT_hostDataXferAbort(p_port, p_card, |
| 2071 | pCurrCard->currentSCCB); |
| 2072 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2073 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2074 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2076 | FPT_sresb(p_port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2078 | while (RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST) { |
| 2079 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2080 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2081 | pCurrNvRam = pCurrCard->pNvRamInfo; |
| 2082 | if (pCurrNvRam) { |
| 2083 | ScamFlg = pCurrNvRam->niScamConf; |
| 2084 | } else { |
| 2085 | ScamFlg = |
| 2086 | (unsigned char)FPT_utilEERead(p_port, |
| 2087 | SCAM_CONFIG / 2); |
| 2088 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2090 | FPT_XbowInit(p_port, ScamFlg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2092 | FPT_scini(p_card, pCurrCard->ourId, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2093 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2094 | return 0xFF; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2095 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2097 | else if (p_int & FIFO) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2098 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2099 | WRW_HARPOON((p_port + hp_intstat), FIFO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2101 | if (pCurrCard->currentSCCB != NULL) |
| 2102 | FPT_sxfrp(p_port, p_card); |
| 2103 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2104 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2105 | else if (p_int & TIMEOUT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2106 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2107 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2109 | WRW_HARPOON((p_port + hp_intstat), |
| 2110 | (PROG_HLT | TIMEOUT | SEL | BUS_FREE | PHASE | |
| 2111 | IUNKWN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2112 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2113 | pCurrCard->currentSCCB->HostStatus = SCCB_SELECTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2115 | currTar_Info = |
| 2116 | &FPT_sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID]; |
| 2117 | if ((pCurrCard->globalFlags & F_CONLUN_IO) |
| 2118 | && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 2119 | TAG_Q_TRYING)) |
| 2120 | currTar_Info->TarLUNBusy[pCurrCard->currentSCCB->Lun] = |
| 2121 | 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2123 | currTar_Info->TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2125 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 2126 | currTar_Info->TarSyncCtrl = 0; |
| 2127 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 2128 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2130 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 2131 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2132 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2133 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2134 | FPT_sssyncv(p_port, pCurrCard->currentSCCB->TargID, NARROW_SCSI, |
| 2135 | currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2136 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2137 | FPT_queueCmdComplete(pCurrCard, pCurrCard->currentSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2139 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2141 | else if (p_int & SCAM_SEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2142 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2143 | FPT_scarb(p_port, LEVEL2_TAR); |
| 2144 | FPT_scsel(p_port); |
| 2145 | FPT_scasid(p_card, p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2146 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2147 | FPT_scbusf(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2148 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2149 | WRW_HARPOON((p_port + hp_intstat), SCAM_SEL); |
| 2150 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2151 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2152 | return 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | } |
| 2154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2155 | /*--------------------------------------------------------------------- |
| 2156 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | * Function: SccbMgrTableInit |
| 2158 | * |
| 2159 | * Description: Initialize all Sccb manager data structures. |
| 2160 | * |
| 2161 | *---------------------------------------------------------------------*/ |
| 2162 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2163 | static void FPT_SccbMgrTableInitAll() |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2164 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2165 | unsigned char thisCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2166 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2167 | for (thisCard = 0; thisCard < MAX_CARDS; thisCard++) { |
| 2168 | FPT_SccbMgrTableInitCard(&FPT_BL_Card[thisCard], thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2169 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2170 | FPT_BL_Card[thisCard].ioPort = 0x00; |
| 2171 | FPT_BL_Card[thisCard].cardInfo = NULL; |
| 2172 | FPT_BL_Card[thisCard].cardIndex = 0xFF; |
| 2173 | FPT_BL_Card[thisCard].ourId = 0x00; |
| 2174 | FPT_BL_Card[thisCard].pNvRamInfo = NULL; |
| 2175 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | } |
| 2177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2178 | /*--------------------------------------------------------------------- |
| 2179 | * |
| 2180 | * Function: SccbMgrTableInit |
| 2181 | * |
| 2182 | * Description: Initialize all Sccb manager data structures. |
| 2183 | * |
| 2184 | *---------------------------------------------------------------------*/ |
| 2185 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2186 | static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard, |
| 2187 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2188 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2189 | unsigned char scsiID, qtag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2190 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2191 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2192 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2193 | } |
| 2194 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2195 | for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++) { |
| 2196 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus = 0; |
| 2197 | FPT_sccbMgrTbl[p_card][scsiID].TarEEValue = 0; |
| 2198 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 2199 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2201 | pCurrCard->scanIndex = 0x00; |
| 2202 | pCurrCard->currentSCCB = NULL; |
| 2203 | pCurrCard->globalFlags = 0x00; |
| 2204 | pCurrCard->cmdCounter = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2205 | pCurrCard->tagQ_Lst = 0x01; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2206 | pCurrCard->discQCount = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2207 | |
| 2208 | } |
| 2209 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2210 | /*--------------------------------------------------------------------- |
| 2211 | * |
| 2212 | * Function: SccbMgrTableInit |
| 2213 | * |
| 2214 | * Description: Initialize all Sccb manager data structures. |
| 2215 | * |
| 2216 | *---------------------------------------------------------------------*/ |
| 2217 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2218 | static void FPT_SccbMgrTableInitTarget(unsigned char p_card, |
| 2219 | unsigned char target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | { |
| 2221 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2222 | unsigned char lun, qtag; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2223 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2224 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2225 | currTar_Info = &FPT_sccbMgrTbl[p_card][target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2226 | |
| 2227 | currTar_Info->TarSelQ_Cnt = 0; |
| 2228 | currTar_Info->TarSyncCtrl = 0; |
| 2229 | |
| 2230 | currTar_Info->TarSelQ_Head = NULL; |
| 2231 | currTar_Info->TarSelQ_Tail = NULL; |
| 2232 | currTar_Info->TarTagQ_Cnt = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2233 | currTar_Info->TarLUN_CA = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2235 | for (lun = 0; lun < MAX_LUN; lun++) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2236 | currTar_Info->TarLUNBusy[lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | currTar_Info->LunDiscQ_Idx[lun] = 0; |
| 2238 | } |
| 2239 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2240 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
| 2241 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] != NULL) { |
| 2242 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == |
| 2243 | target) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2244 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 2245 | FPT_BL_Card[p_card].discQCount--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | } |
| 2247 | } |
| 2248 | } |
| 2249 | } |
| 2250 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | /*--------------------------------------------------------------------- |
| 2252 | * |
| 2253 | * Function: sfetm |
| 2254 | * |
| 2255 | * Description: Read in a message byte from the SCSI bus, and check |
| 2256 | * for a parity error. |
| 2257 | * |
| 2258 | *---------------------------------------------------------------------*/ |
| 2259 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2260 | static unsigned char FPT_sfm(unsigned long port, struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2261 | { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2262 | unsigned char message; |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 2263 | unsigned short TimeOutLoop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2264 | |
| 2265 | TimeOutLoop = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2266 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2267 | (TimeOutLoop++ < 20000)) { |
| 2268 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2269 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2270 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2272 | message = RD_HARPOON(port + hp_scsidata_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2274 | WR_HARPOON(port + hp_scsisig, SCSI_ACK + S_MSGI_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | |
| 2276 | if (TimeOutLoop > 20000) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2277 | message = 0x00; /* force message byte = 0 if Time Out on Req */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2278 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2279 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 2280 | (RD_HARPOON(port + hp_addstat) & SCSI_PAR_ERR)) { |
| 2281 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
| 2282 | WR_HARPOON(port + hp_xferstat, 0); |
| 2283 | WR_HARPOON(port + hp_fiforead, 0); |
| 2284 | WR_HARPOON(port + hp_fifowrite, 0); |
| 2285 | if (pCurrSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2286 | pCurrSCCB->Sccb_scsimsg = SMPARITY; |
| 2287 | } |
| 2288 | message = 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2289 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | ACCEPT_MSG_ATN(port); |
| 2291 | TimeOutLoop = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2292 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2293 | (TimeOutLoop++ < 20000)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2295 | if (TimeOutLoop > 20000) { |
| 2296 | WRW_HARPOON((port + hp_intstat), PARITY); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2297 | return message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2298 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2299 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) != |
| 2300 | S_MSGI_PH) { |
| 2301 | WRW_HARPOON((port + hp_intstat), PARITY); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2302 | return message; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2303 | } |
| 2304 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2305 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2306 | RD_HARPOON(port + hp_scsidata_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2308 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2309 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2310 | } while (1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | |
| 2312 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2313 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
| 2314 | WR_HARPOON(port + hp_xferstat, 0); |
| 2315 | WR_HARPOON(port + hp_fiforead, 0); |
| 2316 | WR_HARPOON(port + hp_fifowrite, 0); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2317 | return message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | } |
| 2319 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2320 | /*--------------------------------------------------------------------- |
| 2321 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2322 | * Function: FPT_ssel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | * |
| 2324 | * Description: Load up automation and select target device. |
| 2325 | * |
| 2326 | *---------------------------------------------------------------------*/ |
| 2327 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 2328 | static void FPT_ssel(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2329 | { |
| 2330 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2331 | unsigned char auto_loaded, i, target, *theCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2332 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2333 | unsigned long cdb_reg; |
| 2334 | struct sccb_card *CurrCard; |
| 2335 | struct sccb *currSCCB; |
| 2336 | struct sccb_mgr_tar_info *currTar_Info; |
| 2337 | unsigned char lastTag, lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2338 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2339 | CurrCard = &FPT_BL_Card[p_card]; |
| 2340 | currSCCB = CurrCard->currentSCCB; |
| 2341 | target = currSCCB->TargID; |
| 2342 | currTar_Info = &FPT_sccbMgrTbl[p_card][target]; |
| 2343 | lastTag = CurrCard->tagQ_Lst; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2345 | ARAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2346 | |
| 2347 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT) |
| 2348 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
| 2349 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2350 | if (((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2351 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2353 | lun = currSCCB->Lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2354 | else |
| 2355 | lun = 0; |
| 2356 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2357 | if (CurrCard->globalFlags & F_TAG_STARTED) { |
| 2358 | if (!(currSCCB->ControlByte & F_USE_CMD_Q)) { |
| 2359 | if ((currTar_Info->TarLUN_CA == 0) |
| 2360 | && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) |
| 2361 | == TAG_Q_TRYING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2363 | if (currTar_Info->TarTagQ_Cnt != 0) { |
| 2364 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2365 | FPT_queueSelectFail(CurrCard, p_card); |
| 2366 | SGRAM_ACCESS(port); |
| 2367 | return; |
| 2368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2369 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2370 | else { |
| 2371 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2372 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2374 | } |
| 2375 | /*End non-tagged */ |
| 2376 | else { |
| 2377 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2378 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2379 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2380 | } |
| 2381 | /*!Use cmd Q Tagged */ |
| 2382 | else { |
| 2383 | if (currTar_Info->TarLUN_CA == 1) { |
| 2384 | FPT_queueSelectFail(CurrCard, p_card); |
| 2385 | SGRAM_ACCESS(port); |
| 2386 | return; |
| 2387 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2389 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2390 | |
| 2391 | } /*else use cmd Q tagged */ |
| 2392 | |
| 2393 | } |
| 2394 | /*if glob tagged started */ |
| 2395 | else { |
| 2396 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2397 | } |
| 2398 | |
| 2399 | if ((((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2400 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 2401 | || (!(currSCCB->ControlByte & F_USE_CMD_Q)))) { |
| 2402 | if (CurrCard->discQCount >= QUEUE_DEPTH) { |
| 2403 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2404 | FPT_queueSelectFail(CurrCard, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 | SGRAM_ACCESS(port); |
| 2406 | return; |
| 2407 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2408 | for (i = 1; i < QUEUE_DEPTH; i++) { |
| 2409 | if (++lastTag >= QUEUE_DEPTH) |
| 2410 | lastTag = 1; |
| 2411 | if (CurrCard->discQ_Tbl[lastTag] == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2412 | CurrCard->tagQ_Lst = lastTag; |
| 2413 | currTar_Info->LunDiscQ_Idx[lun] = lastTag; |
| 2414 | CurrCard->discQ_Tbl[lastTag] = currSCCB; |
| 2415 | CurrCard->discQCount++; |
| 2416 | break; |
| 2417 | } |
| 2418 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2419 | if (i == QUEUE_DEPTH) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2420 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2421 | FPT_queueSelectFail(CurrCard, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2422 | SGRAM_ACCESS(port); |
| 2423 | return; |
| 2424 | } |
| 2425 | } |
| 2426 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2427 | auto_loaded = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2429 | WR_HARPOON(port + hp_select_id, target); |
| 2430 | WR_HARPOON(port + hp_gp_reg_3, target); /* Use by new automation logic */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2431 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2432 | if (currSCCB->OperationCode == RESET_COMMAND) { |
| 2433 | WRW_HARPOON((port + ID_MSG_STRT), (MPM_OP + AMSG_OUT + |
| 2434 | (currSCCB-> |
| 2435 | Sccb_idmsg & ~DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2437 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + NP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2439 | currSCCB->Sccb_scsimsg = SMDEV_RESET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2441 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
| 2442 | auto_loaded = 1; |
| 2443 | currSCCB->Sccb_scsistat = SELECT_BDR_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2444 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2445 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 2446 | currTar_Info->TarSyncCtrl = 0; |
| 2447 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2448 | } |
| 2449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2450 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 2451 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2452 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2453 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2454 | FPT_sssyncv(port, target, NARROW_SCSI, currTar_Info); |
| 2455 | FPT_SccbMgrTableInitTarget(p_card, target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2456 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2457 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2458 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2459 | else if (currSCCB->Sccb_scsistat == ABORT_ST) { |
| 2460 | WRW_HARPOON((port + ID_MSG_STRT), (MPM_OP + AMSG_OUT + |
| 2461 | (currSCCB-> |
| 2462 | Sccb_idmsg & ~DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2464 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2466 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + |
| 2467 | (((unsigned |
| 2468 | char)(currSCCB-> |
| 2469 | ControlByte & |
| 2470 | TAG_TYPE_MASK) |
| 2471 | >> 6) | (unsigned char) |
| 2472 | 0x20))); |
| 2473 | WRW_HARPOON((port + SYNC_MSGS + 2), |
| 2474 | (MPM_OP + AMSG_OUT + currSCCB->Sccb_tag)); |
| 2475 | WRW_HARPOON((port + SYNC_MSGS + 4), (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2476 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2477 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
| 2478 | auto_loaded = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2479 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2480 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2481 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2482 | else if (!(currTar_Info->TarStatus & WIDE_NEGOCIATED)) { |
| 2483 | auto_loaded = FPT_siwidn(port, p_card); |
| 2484 | currSCCB->Sccb_scsistat = SELECT_WN_ST; |
| 2485 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2486 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2487 | else if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) |
| 2488 | == SYNC_SUPPORTED)) { |
| 2489 | auto_loaded = FPT_sisyncn(port, p_card, 0); |
| 2490 | currSCCB->Sccb_scsistat = SELECT_SN_ST; |
| 2491 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2492 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2493 | if (!auto_loaded) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2494 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2495 | if (currSCCB->ControlByte & F_USE_CMD_Q) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2496 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2497 | CurrCard->globalFlags |= F_TAG_STARTED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2498 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2499 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) |
| 2500 | == TAG_Q_REJECT) { |
| 2501 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2503 | /* Fix up the start instruction with a jump to |
| 2504 | Non-Tag-CMD handling */ |
| 2505 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2506 | BRH_OP + ALWAYS + NTCMD); |
| 2507 | |
| 2508 | WRW_HARPOON((port + NON_TAG_ID_MSG), |
| 2509 | (MPM_OP + AMSG_OUT + |
| 2510 | currSCCB->Sccb_idmsg)); |
| 2511 | |
| 2512 | WR_HARPOON(port + hp_autostart_3, |
| 2513 | (SELECT + SELCHK_STRT)); |
| 2514 | |
| 2515 | /* Setup our STATE so we know what happend when |
| 2516 | the wheels fall off. */ |
| 2517 | currSCCB->Sccb_scsistat = SELECT_ST; |
| 2518 | |
| 2519 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2520 | } |
| 2521 | |
| 2522 | else { |
| 2523 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2524 | (MPM_OP + AMSG_OUT + |
| 2525 | currSCCB->Sccb_idmsg)); |
| 2526 | |
| 2527 | WRW_HARPOON((port + ID_MSG_STRT + 2), |
| 2528 | (MPM_OP + AMSG_OUT + |
| 2529 | (((unsigned char)(currSCCB-> |
| 2530 | ControlByte & |
| 2531 | TAG_TYPE_MASK) |
| 2532 | >> 6) | (unsigned char)0x20))); |
| 2533 | |
| 2534 | for (i = 1; i < QUEUE_DEPTH; i++) { |
| 2535 | if (++lastTag >= QUEUE_DEPTH) |
| 2536 | lastTag = 1; |
| 2537 | if (CurrCard->discQ_Tbl[lastTag] == |
| 2538 | NULL) { |
| 2539 | WRW_HARPOON((port + |
| 2540 | ID_MSG_STRT + 6), |
| 2541 | (MPM_OP + AMSG_OUT + |
| 2542 | lastTag)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2543 | CurrCard->tagQ_Lst = lastTag; |
| 2544 | currSCCB->Sccb_tag = lastTag; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2545 | CurrCard->discQ_Tbl[lastTag] = |
| 2546 | currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 | CurrCard->discQCount++; |
| 2548 | break; |
| 2549 | } |
| 2550 | } |
| 2551 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2552 | if (i == QUEUE_DEPTH) { |
| 2553 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2554 | FPT_queueSelectFail(CurrCard, p_card); |
| 2555 | SGRAM_ACCESS(port); |
| 2556 | return; |
| 2557 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2558 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2559 | currSCCB->Sccb_scsistat = SELECT_Q_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2560 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2561 | WR_HARPOON(port + hp_autostart_3, |
| 2562 | (SELECT + SELCHK_STRT)); |
| 2563 | } |
| 2564 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2565 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2566 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2567 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2568 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2569 | BRH_OP + ALWAYS + NTCMD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2570 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2571 | WRW_HARPOON((port + NON_TAG_ID_MSG), |
| 2572 | (MPM_OP + AMSG_OUT + currSCCB->Sccb_idmsg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2573 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2574 | currSCCB->Sccb_scsistat = SELECT_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2575 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2576 | WR_HARPOON(port + hp_autostart_3, |
| 2577 | (SELECT + SELCHK_STRT)); |
| 2578 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2580 | theCCB = (unsigned char *)&currSCCB->Cdb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2582 | cdb_reg = port + CMD_STRT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2583 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2584 | for (i = 0; i < currSCCB->CdbLength; i++) { |
| 2585 | WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + *theCCB)); |
| 2586 | cdb_reg += 2; |
| 2587 | theCCB++; |
| 2588 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2589 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2590 | if (currSCCB->CdbLength != TWELVE_BYTE_CMD) |
| 2591 | WRW_HARPOON(cdb_reg, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2592 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2593 | } |
| 2594 | /* auto_loaded */ |
| 2595 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
| 2596 | WR_HARPOON(port + hp_xferstat, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2597 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2598 | WRW_HARPOON((port + hp_intstat), (PROG_HLT | TIMEOUT | SEL | BUS_FREE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2599 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2600 | WR_HARPOON(port + hp_portctrl_0, (SCSI_PORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2601 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2602 | if (!(currSCCB->Sccb_MGRFlags & F_DEV_SELECTED)) { |
| 2603 | WR_HARPOON(port + hp_scsictrl_0, |
| 2604 | (SEL_TAR | ENA_ATN | ENA_RESEL | ENA_SCAM_SEL)); |
| 2605 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2606 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2607 | /* auto_loaded = (RD_HARPOON(port+hp_autostart_3) & (unsigned char)0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2608 | auto_loaded |= AUTO_IMMED; */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2609 | auto_loaded = AUTO_IMMED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2610 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2611 | DISABLE_AUTO(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2612 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2613 | WR_HARPOON(port + hp_autostart_3, auto_loaded); |
| 2614 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2615 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2616 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2617 | } |
| 2618 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2619 | /*--------------------------------------------------------------------- |
| 2620 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2621 | * Function: FPT_sres |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2622 | * |
| 2623 | * Description: Hookup the correct CCB and handle the incoming messages. |
| 2624 | * |
| 2625 | *---------------------------------------------------------------------*/ |
| 2626 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2627 | static void FPT_sres(unsigned long port, unsigned char p_card, |
| 2628 | struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | { |
| 2630 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2631 | unsigned char our_target, message, lun = 0, tag, msgRetryCount; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2632 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2633 | struct sccb_mgr_tar_info *currTar_Info; |
| 2634 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2635 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2636 | if (pCurrCard->currentSCCB != NULL) { |
| 2637 | currTar_Info = |
| 2638 | &FPT_sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2639 | DISABLE_AUTO(port); |
| 2640 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2641 | WR_HARPOON((port + hp_scsictrl_0), (ENA_RESEL | ENA_SCAM_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2642 | |
| 2643 | currSCCB = pCurrCard->currentSCCB; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2644 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2645 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2646 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
| 2647 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2648 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2649 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 2650 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
| 2651 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2652 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 2653 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 2654 | TAG_Q_TRYING))) { |
| 2655 | currTar_Info->TarLUNBusy[currSCCB->Lun] = 0; |
| 2656 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2657 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2658 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 2659 | LunDiscQ_Idx[currSCCB-> |
| 2660 | Lun]] |
| 2661 | = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2663 | } else { |
| 2664 | currTar_Info->TarLUNBusy[0] = 0; |
| 2665 | if (currSCCB->Sccb_tag) { |
| 2666 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2667 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2668 | pCurrCard->discQ_Tbl[currSCCB-> |
| 2669 | Sccb_tag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2671 | } else { |
| 2672 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2673 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2674 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 2675 | LunDiscQ_Idx[0]] = |
| 2676 | NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2677 | } |
| 2678 | } |
| 2679 | } |
| 2680 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2681 | FPT_queueSelectFail(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2682 | } |
| 2683 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2684 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2685 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2686 | our_target = (unsigned char)(RD_HARPOON(port + hp_select_id) >> 4); |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2687 | currTar_Info = &FPT_sccbMgrTbl[p_card][our_target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2688 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2689 | msgRetryCount = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2690 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2691 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2692 | currTar_Info = &FPT_sccbMgrTbl[p_card][our_target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2693 | tag = 0; |
| 2694 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2695 | while (!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) { |
| 2696 | if (!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2697 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2698 | WRW_HARPOON((port + hp_intstat), PHASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2699 | return; |
| 2700 | } |
| 2701 | } |
| 2702 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2703 | WRW_HARPOON((port + hp_intstat), PHASE); |
| 2704 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) == S_MSGI_PH) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2705 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2706 | message = FPT_sfm(port, pCurrCard->currentSCCB); |
| 2707 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2708 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2709 | if (message <= (0x80 | LUN_MASK)) { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2710 | lun = message & (unsigned char)LUN_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2711 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2712 | if ((currTar_Info-> |
| 2713 | TarStatus & TAR_TAG_Q_MASK) == |
| 2714 | TAG_Q_TRYING) { |
| 2715 | if (currTar_Info->TarTagQ_Cnt != |
| 2716 | 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2717 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2718 | if (! |
| 2719 | (currTar_Info-> |
| 2720 | TarLUN_CA)) { |
| 2721 | ACCEPT_MSG(port); /*Release the ACK for ID msg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2722 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2723 | message = |
| 2724 | FPT_sfm |
| 2725 | (port, |
| 2726 | pCurrCard-> |
| 2727 | currentSCCB); |
| 2728 | if (message) { |
| 2729 | ACCEPT_MSG |
| 2730 | (port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2731 | } |
| 2732 | |
| 2733 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2734 | message |
| 2735 | = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2736 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2737 | if (message != |
| 2738 | 0) { |
| 2739 | tag = |
| 2740 | FPT_sfm |
| 2741 | (port, |
| 2742 | pCurrCard-> |
| 2743 | currentSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2744 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2745 | if (! |
| 2746 | (tag)) |
| 2747 | message |
| 2748 | = |
| 2749 | 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2750 | } |
| 2751 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2752 | } |
| 2753 | /*C.A. exists! */ |
| 2754 | } |
| 2755 | /*End Q cnt != 0 */ |
| 2756 | } |
| 2757 | /*End Tag cmds supported! */ |
| 2758 | } |
| 2759 | /*End valid ID message. */ |
| 2760 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2761 | |
| 2762 | ACCEPT_MSG_ATN(port); |
| 2763 | } |
| 2764 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2765 | } |
| 2766 | /* End good id message. */ |
| 2767 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2768 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2769 | message = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2770 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2771 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2772 | ACCEPT_MSG_ATN(port); |
| 2773 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2774 | while (! |
| 2775 | (RDW_HARPOON((port + hp_intstat)) & |
| 2776 | (PHASE | RESET)) |
| 2777 | && !(RD_HARPOON(port + hp_scsisig) & SCSI_REQ) |
| 2778 | && (RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2779 | |
| 2780 | return; |
| 2781 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2782 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2783 | if (message == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2784 | msgRetryCount++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2785 | if (msgRetryCount == 1) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2786 | FPT_SendMsg(port, SMPARITY); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2787 | } else { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2788 | FPT_SendMsg(port, SMDEV_RESET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2789 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2790 | FPT_sssyncv(port, our_target, NARROW_SCSI, |
| 2791 | currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2792 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2793 | if (FPT_sccbMgrTbl[p_card][our_target]. |
| 2794 | TarEEValue & EE_SYNC_MASK) { |
| 2795 | |
| 2796 | FPT_sccbMgrTbl[p_card][our_target]. |
| 2797 | TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2798 | |
| 2799 | } |
| 2800 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2801 | if (FPT_sccbMgrTbl[p_card][our_target]. |
| 2802 | TarEEValue & EE_WIDE_SCSI) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2803 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2804 | FPT_sccbMgrTbl[p_card][our_target]. |
| 2805 | TarStatus &= ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2806 | } |
| 2807 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2808 | FPT_queueFlushTargSccb(p_card, our_target, |
| 2809 | SCCB_COMPLETE); |
| 2810 | FPT_SccbMgrTableInitTarget(p_card, our_target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2811 | return; |
| 2812 | } |
| 2813 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2814 | } while (message == 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2815 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2816 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 2817 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2818 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2819 | pCurrCard->currentSCCB = |
| 2820 | pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[lun]]; |
| 2821 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2822 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2823 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2824 | ACCEPT_MSG_ATN(port); |
| 2825 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2826 | } else { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2827 | currTar_Info->TarLUNBusy[0] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2828 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2829 | if (tag) { |
| 2830 | if (pCurrCard->discQ_Tbl[tag] != NULL) { |
| 2831 | pCurrCard->currentSCCB = |
| 2832 | pCurrCard->discQ_Tbl[tag]; |
| 2833 | currTar_Info->TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2834 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2835 | } else { |
| 2836 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2837 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2838 | } else { |
| 2839 | pCurrCard->currentSCCB = |
| 2840 | pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]]; |
| 2841 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2842 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2843 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2844 | ACCEPT_MSG_ATN(port); |
| 2845 | } |
| 2846 | } |
| 2847 | } |
| 2848 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2849 | if (pCurrCard->currentSCCB != NULL) { |
| 2850 | if (pCurrCard->currentSCCB->Sccb_scsistat == ABORT_ST) { |
| 2851 | /* During Abort Tag command, the target could have got re-selected |
| 2852 | and completed the command. Check the select Q and remove the CCB |
| 2853 | if it is in the Select Q */ |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2854 | FPT_queueFindSccb(pCurrCard->currentSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2855 | } |
| 2856 | } |
| 2857 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2858 | while (!(RDW_HARPOON((port + hp_intstat)) & (PHASE | RESET)) && |
| 2859 | !(RD_HARPOON(port + hp_scsisig) & SCSI_REQ) && |
| 2860 | (RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2861 | } |
| 2862 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 2863 | static void FPT_SendMsg(unsigned long port, unsigned char message) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2864 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2865 | while (!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) { |
| 2866 | if (!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2867 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2868 | WRW_HARPOON((port + hp_intstat), PHASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2869 | return; |
| 2870 | } |
| 2871 | } |
| 2872 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2873 | WRW_HARPOON((port + hp_intstat), PHASE); |
| 2874 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) == S_MSGO_PH) { |
| 2875 | WRW_HARPOON((port + hp_intstat), |
| 2876 | (BUS_FREE | PHASE | XFER_CNT_0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2877 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2878 | WR_HARPOON(port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2879 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2880 | WR_HARPOON(port + hp_scsidata_0, message); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2881 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2882 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2883 | |
| 2884 | ACCEPT_MSG(port); |
| 2885 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2886 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2887 | |
| 2888 | if ((message == SMABORT) || (message == SMDEV_RESET) || |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2889 | (message == SMABORT_TAG)) { |
| 2890 | while (! |
| 2891 | (RDW_HARPOON((port + hp_intstat)) & |
| 2892 | (BUS_FREE | PHASE))) { |
| 2893 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2894 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2895 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 2896 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2897 | } |
| 2898 | } |
| 2899 | } |
| 2900 | } |
| 2901 | |
| 2902 | /*--------------------------------------------------------------------- |
| 2903 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2904 | * Function: FPT_sdecm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2905 | * |
| 2906 | * Description: Determine the proper responce to the message from the |
| 2907 | * target device. |
| 2908 | * |
| 2909 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2910 | static void FPT_sdecm(unsigned char message, unsigned long port, |
| 2911 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2912 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2913 | struct sccb *currSCCB; |
| 2914 | struct sccb_card *CurrCard; |
| 2915 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2916 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2917 | CurrCard = &FPT_BL_Card[p_card]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2918 | currSCCB = CurrCard->currentSCCB; |
| 2919 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2920 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2921 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2922 | if (message == SMREST_DATA_PTR) { |
| 2923 | if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2924 | currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC; |
| 2925 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2926 | FPT_hostDataXferRestart(currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2927 | } |
| 2928 | |
| 2929 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2930 | WR_HARPOON(port + hp_autostart_1, |
| 2931 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2932 | } |
| 2933 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2934 | else if (message == SMCMD_COMP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2935 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2936 | if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { |
| 2937 | currTar_Info->TarStatus &= |
| 2938 | ~(unsigned char)TAR_TAG_Q_MASK; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2939 | currTar_Info->TarStatus |= (unsigned char)TAG_Q_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2940 | } |
| 2941 | |
| 2942 | ACCEPT_MSG(port); |
| 2943 | |
| 2944 | } |
| 2945 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2946 | else if ((message == SMNO_OP) || (message >= SMIDENT) |
| 2947 | || (message == SMINIT_RECOVERY) || (message == SMREL_RECOVERY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2948 | |
| 2949 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2950 | WR_HARPOON(port + hp_autostart_1, |
| 2951 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2952 | } |
| 2953 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2954 | else if (message == SMREJECT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2955 | |
| 2956 | if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) || |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2957 | (currSCCB->Sccb_scsistat == SELECT_WN_ST) || |
| 2958 | ((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING) |
| 2959 | || ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == |
| 2960 | TAG_Q_TRYING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2961 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2962 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2963 | |
| 2964 | ACCEPT_MSG(port); |
| 2965 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2966 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2967 | (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2968 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2969 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2970 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2971 | if (currSCCB->Lun == 0x00) { |
| 2972 | if ((currSCCB->Sccb_scsistat == SELECT_SN_ST)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2973 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2974 | currTar_Info->TarStatus |= |
| 2975 | (unsigned char)SYNC_SUPPORTED; |
| 2976 | |
| 2977 | currTar_Info->TarEEValue &= |
| 2978 | ~EE_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2979 | } |
| 2980 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2981 | else if ((currSCCB->Sccb_scsistat == |
| 2982 | SELECT_WN_ST)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2983 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2984 | currTar_Info->TarStatus = |
| 2985 | (currTar_Info-> |
| 2986 | TarStatus & ~WIDE_ENABLED) | |
| 2987 | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2988 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2989 | currTar_Info->TarEEValue &= |
| 2990 | ~EE_WIDE_SCSI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2991 | |
| 2992 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2993 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2994 | else if ((currTar_Info-> |
| 2995 | TarStatus & TAR_TAG_Q_MASK) == |
| 2996 | TAG_Q_TRYING) { |
| 2997 | currTar_Info->TarStatus = |
| 2998 | (currTar_Info-> |
| 2999 | TarStatus & ~(unsigned char) |
| 3000 | TAR_TAG_Q_MASK) | TAG_Q_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3001 | |
| 3002 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
| 3003 | CurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3004 | CurrCard->discQ_Tbl[currSCCB-> |
| 3005 | Sccb_tag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3006 | currSCCB->Sccb_tag = 0x00; |
| 3007 | |
| 3008 | } |
| 3009 | } |
| 3010 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3011 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3012 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3013 | if (currSCCB->Lun == 0x00) { |
| 3014 | WRW_HARPOON((port + hp_intstat), |
| 3015 | BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3016 | CurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 3017 | } |
| 3018 | } |
| 3019 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3020 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3021 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3022 | if ((CurrCard->globalFlags & F_CONLUN_IO) && |
| 3023 | ((currTar_Info-> |
| 3024 | TarStatus & TAR_TAG_Q_MASK) != |
| 3025 | TAG_Q_TRYING)) |
| 3026 | currTar_Info->TarLUNBusy[currSCCB-> |
| 3027 | Lun] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3028 | else |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3029 | currTar_Info->TarLUNBusy[0] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3030 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3031 | currSCCB->ControlByte &= |
| 3032 | ~(unsigned char)F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3033 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3034 | WR_HARPOON(port + hp_autostart_1, |
| 3035 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3036 | |
| 3037 | } |
| 3038 | } |
| 3039 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3040 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | ACCEPT_MSG(port); |
| 3042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3043 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 3044 | (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3045 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3046 | } |
| 3047 | |
| 3048 | if (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE)) { |
| 3049 | WR_HARPOON(port + hp_autostart_1, |
| 3050 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3051 | } |
| 3052 | } |
| 3053 | } |
| 3054 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3055 | else if (message == SMEXT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3056 | |
| 3057 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3058 | FPT_shandem(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3059 | } |
| 3060 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3061 | else if (message == SMIGNORWR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3062 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3063 | ACCEPT_MSG(port); /* ACK the RESIDUE MSG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3064 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3065 | message = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3066 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3067 | if (currSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3068 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3069 | WR_HARPOON(port + hp_autostart_1, |
| 3070 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3071 | } |
| 3072 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3073 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | |
| 3075 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 3076 | currSCCB->Sccb_scsimsg = SMREJECT; |
| 3077 | |
| 3078 | ACCEPT_MSG_ATN(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3079 | WR_HARPOON(port + hp_autostart_1, |
| 3080 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3081 | } |
| 3082 | } |
| 3083 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3084 | /*--------------------------------------------------------------------- |
| 3085 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3086 | * Function: FPT_shandem |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3087 | * |
| 3088 | * Description: Decide what to do with the extended message. |
| 3089 | * |
| 3090 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3091 | static void FPT_shandem(unsigned long port, unsigned char p_card, |
| 3092 | struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3093 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3094 | unsigned char length, message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3095 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3096 | length = FPT_sfm(port, pCurrSCCB); |
| 3097 | if (length) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3098 | |
| 3099 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3100 | message = FPT_sfm(port, pCurrSCCB); |
| 3101 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3102 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3103 | if (message == SMSYNC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3104 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3105 | if (length == 0x03) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3106 | |
| 3107 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3108 | FPT_stsyncn(port, p_card); |
| 3109 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3110 | |
| 3111 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3112 | ACCEPT_MSG_ATN(port); |
| 3113 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3114 | } else if (message == SMWDTR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3115 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3116 | if (length == 0x02) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3117 | |
| 3118 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3119 | FPT_stwidn(port, p_card); |
| 3120 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3121 | |
| 3122 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3123 | ACCEPT_MSG_ATN(port); |
| 3124 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3125 | WR_HARPOON(port + hp_autostart_1, |
| 3126 | (AUTO_IMMED + |
| 3127 | DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3128 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3129 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3130 | |
| 3131 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3132 | ACCEPT_MSG_ATN(port); |
| 3133 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3134 | WR_HARPOON(port + hp_autostart_1, |
| 3135 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3137 | } else { |
| 3138 | if (pCurrSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3139 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3140 | WR_HARPOON(port + hp_autostart_1, |
| 3141 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3142 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3143 | } else { |
| 3144 | if (pCurrSCCB->Sccb_scsimsg == SMPARITY) |
| 3145 | WR_HARPOON(port + hp_autostart_1, |
| 3146 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3147 | } |
| 3148 | } |
| 3149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3150 | /*--------------------------------------------------------------------- |
| 3151 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3152 | * Function: FPT_sisyncn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3153 | * |
| 3154 | * Description: Read in a message byte from the SCSI bus, and check |
| 3155 | * for a parity error. |
| 3156 | * |
| 3157 | *---------------------------------------------------------------------*/ |
| 3158 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3159 | static unsigned char FPT_sisyncn(unsigned long port, unsigned char p_card, |
| 3160 | unsigned char syncFlag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3161 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3162 | struct sccb *currSCCB; |
| 3163 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3164 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3165 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3166 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3167 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3168 | if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3169 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3170 | WRW_HARPOON((port + ID_MSG_STRT), |
| 3171 | (MPM_OP + AMSG_OUT + |
| 3172 | (currSCCB-> |
| 3173 | Sccb_idmsg & ~(unsigned char)DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3174 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3175 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3176 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3177 | WRW_HARPOON((port + SYNC_MSGS + 0), |
| 3178 | (MPM_OP + AMSG_OUT + SMEXT)); |
| 3179 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); |
| 3180 | WRW_HARPOON((port + SYNC_MSGS + 4), |
| 3181 | (MPM_OP + AMSG_OUT + SMSYNC)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3182 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3183 | if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3184 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3185 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3186 | (MPM_OP + AMSG_OUT + 12)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3187 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3188 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == |
| 3189 | EE_SYNC_10MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3190 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3191 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3192 | (MPM_OP + AMSG_OUT + 25)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3193 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3194 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == |
| 3195 | EE_SYNC_5MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3196 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3197 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3198 | (MPM_OP + AMSG_OUT + 50)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3200 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3201 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3202 | (MPM_OP + AMSG_OUT + 00)); |
| 3203 | |
| 3204 | WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); |
| 3205 | WRW_HARPOON((port + SYNC_MSGS + 10), |
| 3206 | (MPM_OP + AMSG_OUT + DEFAULT_OFFSET)); |
| 3207 | WRW_HARPOON((port + SYNC_MSGS + 12), (BRH_OP + ALWAYS + NP)); |
| 3208 | |
| 3209 | if (syncFlag == 0) { |
| 3210 | WR_HARPOON(port + hp_autostart_3, |
| 3211 | (SELECT + SELCHK_STRT)); |
| 3212 | currTar_Info->TarStatus = |
| 3213 | ((currTar_Info-> |
| 3214 | TarStatus & ~(unsigned char)TAR_SYNC_MASK) | |
| 3215 | (unsigned char)SYNC_TRYING); |
| 3216 | } else { |
| 3217 | WR_HARPOON(port + hp_autostart_3, |
| 3218 | (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3219 | } |
| 3220 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3221 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3222 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3223 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3224 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3226 | currTar_Info->TarStatus |= (unsigned char)SYNC_SUPPORTED; |
| 3227 | currTar_Info->TarEEValue &= ~EE_SYNC_MASK; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3228 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3229 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3230 | } |
| 3231 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3232 | /*--------------------------------------------------------------------- |
| 3233 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3234 | * Function: FPT_stsyncn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3235 | * |
| 3236 | * Description: The has sent us a Sync Nego message so handle it as |
| 3237 | * necessary. |
| 3238 | * |
| 3239 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3240 | static void FPT_stsyncn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3241 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3242 | unsigned char sync_msg, offset, sync_reg, our_sync_msg; |
| 3243 | struct sccb *currSCCB; |
| 3244 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3245 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3246 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3247 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3248 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3249 | sync_msg = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3250 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3251 | if ((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3252 | WR_HARPOON(port + hp_autostart_1, |
| 3253 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3254 | return; |
| 3255 | } |
| 3256 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3257 | ACCEPT_MSG(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3258 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3259 | offset = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3260 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3261 | if ((offset == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3262 | WR_HARPOON(port + hp_autostart_1, |
| 3263 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3264 | return; |
| 3265 | } |
| 3266 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3267 | if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3268 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3269 | our_sync_msg = 12; /* Setup our Message to 20mb/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3270 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3271 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_10MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3272 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3273 | our_sync_msg = 25; /* Setup our Message to 10mb/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3274 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3275 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_5MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3276 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3277 | our_sync_msg = 50; /* Setup our Message to 5mb/s */ |
| 3278 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3279 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3280 | our_sync_msg = 0; /* Message = Async */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3281 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3282 | if (sync_msg < our_sync_msg) { |
| 3283 | sync_msg = our_sync_msg; /*if faster, then set to max. */ |
| 3284 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3285 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3286 | if (offset == ASYNC) |
| 3287 | sync_msg = ASYNC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3288 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3289 | if (offset > MAX_OFFSET) |
| 3290 | offset = MAX_OFFSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3292 | sync_reg = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3293 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3294 | if (sync_msg > 12) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3295 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3296 | sync_reg = 0x20; /* Use 10MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3297 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3298 | if (sync_msg > 25) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3299 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3300 | sync_reg = 0x40; /* Use 6.6MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3301 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3302 | if (sync_msg > 38) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3303 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3304 | sync_reg = 0x60; /* Use 5MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3305 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3306 | if (sync_msg > 50) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3308 | sync_reg = 0x80; /* Use 4MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3309 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3310 | if (sync_msg > 62) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3311 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3312 | sync_reg = 0xA0; /* Use 3.33MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3313 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3314 | if (sync_msg > 75) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3315 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3316 | sync_reg = 0xC0; /* Use 2.85MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3317 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3318 | if (sync_msg > 87) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3319 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3320 | sync_reg = 0xE0; /* Use 2.5MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3321 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3322 | if (sync_msg > 100) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3323 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3324 | sync_reg = 0x00; /* Use ASYNC */ |
| 3325 | offset = 0x00; |
| 3326 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3327 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3328 | if (currTar_Info->TarStatus & WIDE_ENABLED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3329 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3330 | sync_reg |= offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3331 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3332 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3333 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3334 | sync_reg |= (offset | NARROW_SCSI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3336 | FPT_sssyncv(port, currSCCB->TargID, sync_reg, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3337 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3338 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3339 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3340 | ACCEPT_MSG(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3341 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3342 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3343 | ~(unsigned char)TAR_SYNC_MASK) | |
| 3344 | (unsigned char)SYNC_SUPPORTED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3345 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3346 | WR_HARPOON(port + hp_autostart_1, |
| 3347 | (AUTO_IMMED + DISCONNECT_START)); |
| 3348 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3349 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3350 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3351 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3352 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3353 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3354 | FPT_sisyncr(port, sync_msg, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3355 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3356 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3357 | ~(unsigned char)TAR_SYNC_MASK) | |
| 3358 | (unsigned char)SYNC_SUPPORTED); |
| 3359 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3360 | } |
| 3361 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3362 | /*--------------------------------------------------------------------- |
| 3363 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3364 | * Function: FPT_sisyncr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3365 | * |
| 3366 | * Description: Answer the targets sync message. |
| 3367 | * |
| 3368 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3369 | static void FPT_sisyncr(unsigned long port, unsigned char sync_pulse, |
| 3370 | unsigned char offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3371 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3372 | ARAM_ACCESS(port); |
| 3373 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); |
| 3374 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); |
| 3375 | WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMSYNC)); |
| 3376 | WRW_HARPOON((port + SYNC_MSGS + 6), (MPM_OP + AMSG_OUT + sync_pulse)); |
| 3377 | WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); |
| 3378 | WRW_HARPOON((port + SYNC_MSGS + 10), (MPM_OP + AMSG_OUT + offset)); |
| 3379 | WRW_HARPOON((port + SYNC_MSGS + 12), (BRH_OP + ALWAYS + NP)); |
| 3380 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3381 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3382 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
| 3383 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3384 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3385 | WR_HARPOON(port + hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3386 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3387 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | AUTO_INT))) { |
| 3388 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3389 | } |
| 3390 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3391 | /*--------------------------------------------------------------------- |
| 3392 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3393 | * Function: FPT_siwidn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3394 | * |
| 3395 | * Description: Read in a message byte from the SCSI bus, and check |
| 3396 | * for a parity error. |
| 3397 | * |
| 3398 | *---------------------------------------------------------------------*/ |
| 3399 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3400 | static unsigned char FPT_siwidn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3401 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3402 | struct sccb *currSCCB; |
| 3403 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3404 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3405 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3406 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3407 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3408 | if (!((currTar_Info->TarStatus & TAR_WIDE_MASK) == WIDE_NEGOCIATED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3409 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3410 | WRW_HARPOON((port + ID_MSG_STRT), |
| 3411 | (MPM_OP + AMSG_OUT + |
| 3412 | (currSCCB-> |
| 3413 | Sccb_idmsg & ~(unsigned char)DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3414 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3415 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3416 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3417 | WRW_HARPOON((port + SYNC_MSGS + 0), |
| 3418 | (MPM_OP + AMSG_OUT + SMEXT)); |
| 3419 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); |
| 3420 | WRW_HARPOON((port + SYNC_MSGS + 4), |
| 3421 | (MPM_OP + AMSG_OUT + SMWDTR)); |
| 3422 | WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); |
| 3423 | WRW_HARPOON((port + SYNC_MSGS + 8), |
| 3424 | (MPM_OP + AMSG_OUT + SM16BIT)); |
| 3425 | WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3426 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3427 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3429 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3430 | ~(unsigned char)TAR_WIDE_MASK) | |
| 3431 | (unsigned char)WIDE_ENABLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3432 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3433 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3434 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3435 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3436 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3438 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3439 | ~(unsigned char)TAR_WIDE_MASK) | |
| 3440 | WIDE_NEGOCIATED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3442 | currTar_Info->TarEEValue &= ~EE_WIDE_SCSI; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3443 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3444 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3445 | } |
| 3446 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3447 | /*--------------------------------------------------------------------- |
| 3448 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3449 | * Function: FPT_stwidn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3450 | * |
| 3451 | * Description: The has sent us a Wide Nego message so handle it as |
| 3452 | * necessary. |
| 3453 | * |
| 3454 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3455 | static void FPT_stwidn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3456 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3457 | unsigned char width; |
| 3458 | struct sccb *currSCCB; |
| 3459 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3460 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3461 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3462 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3464 | width = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3466 | if ((width == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3467 | WR_HARPOON(port + hp_autostart_1, |
| 3468 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3469 | return; |
| 3470 | } |
| 3471 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3472 | if (!(currTar_Info->TarEEValue & EE_WIDE_SCSI)) |
| 3473 | width = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3474 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3475 | if (width) { |
| 3476 | currTar_Info->TarStatus |= WIDE_ENABLED; |
| 3477 | width = 0; |
| 3478 | } else { |
| 3479 | width = NARROW_SCSI; |
| 3480 | currTar_Info->TarStatus &= ~WIDE_ENABLED; |
| 3481 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3482 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3483 | FPT_sssyncv(port, currSCCB->TargID, width, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3484 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3485 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3486 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3487 | currTar_Info->TarStatus |= WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3488 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3489 | if (! |
| 3490 | ((currTar_Info->TarStatus & TAR_SYNC_MASK) == |
| 3491 | SYNC_SUPPORTED)) { |
| 3492 | ACCEPT_MSG_ATN(port); |
| 3493 | ARAM_ACCESS(port); |
| 3494 | FPT_sisyncn(port, p_card, 1); |
| 3495 | currSCCB->Sccb_scsistat = SELECT_SN_ST; |
| 3496 | SGRAM_ACCESS(port); |
| 3497 | } else { |
| 3498 | ACCEPT_MSG(port); |
| 3499 | WR_HARPOON(port + hp_autostart_1, |
| 3500 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3501 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3502 | } |
| 3503 | |
| 3504 | else { |
| 3505 | |
| 3506 | ACCEPT_MSG_ATN(port); |
| 3507 | |
| 3508 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) |
| 3509 | width = SM16BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3510 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3511 | width = SM8BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3512 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3513 | FPT_siwidr(port, width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3514 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3515 | currTar_Info->TarStatus |= (WIDE_NEGOCIATED | WIDE_ENABLED); |
| 3516 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3517 | } |
| 3518 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3519 | /*--------------------------------------------------------------------- |
| 3520 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3521 | * Function: FPT_siwidr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3522 | * |
| 3523 | * Description: Answer the targets Wide nego message. |
| 3524 | * |
| 3525 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3526 | static void FPT_siwidr(unsigned long port, unsigned char width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3527 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3528 | ARAM_ACCESS(port); |
| 3529 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); |
| 3530 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); |
| 3531 | WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMWDTR)); |
| 3532 | WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); |
| 3533 | WRW_HARPOON((port + SYNC_MSGS + 8), (MPM_OP + AMSG_OUT + width)); |
| 3534 | WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); |
| 3535 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3537 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
| 3538 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3539 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3540 | WR_HARPOON(port + hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3541 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3542 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | AUTO_INT))) { |
| 3543 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3544 | } |
| 3545 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3546 | /*--------------------------------------------------------------------- |
| 3547 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3548 | * Function: FPT_sssyncv |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3549 | * |
| 3550 | * Description: Write the desired value to the Sync Register for the |
| 3551 | * ID specified. |
| 3552 | * |
| 3553 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3554 | static void FPT_sssyncv(unsigned long p_port, unsigned char p_id, |
| 3555 | unsigned char p_sync_value, |
| 3556 | struct sccb_mgr_tar_info *currTar_Info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3557 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3558 | unsigned char index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3559 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3560 | index = p_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3561 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3562 | switch (index) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3563 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3564 | case 0: |
| 3565 | index = 12; /* hp_synctarg_0 */ |
| 3566 | break; |
| 3567 | case 1: |
| 3568 | index = 13; /* hp_synctarg_1 */ |
| 3569 | break; |
| 3570 | case 2: |
| 3571 | index = 14; /* hp_synctarg_2 */ |
| 3572 | break; |
| 3573 | case 3: |
| 3574 | index = 15; /* hp_synctarg_3 */ |
| 3575 | break; |
| 3576 | case 4: |
| 3577 | index = 8; /* hp_synctarg_4 */ |
| 3578 | break; |
| 3579 | case 5: |
| 3580 | index = 9; /* hp_synctarg_5 */ |
| 3581 | break; |
| 3582 | case 6: |
| 3583 | index = 10; /* hp_synctarg_6 */ |
| 3584 | break; |
| 3585 | case 7: |
| 3586 | index = 11; /* hp_synctarg_7 */ |
| 3587 | break; |
| 3588 | case 8: |
| 3589 | index = 4; /* hp_synctarg_8 */ |
| 3590 | break; |
| 3591 | case 9: |
| 3592 | index = 5; /* hp_synctarg_9 */ |
| 3593 | break; |
| 3594 | case 10: |
| 3595 | index = 6; /* hp_synctarg_10 */ |
| 3596 | break; |
| 3597 | case 11: |
| 3598 | index = 7; /* hp_synctarg_11 */ |
| 3599 | break; |
| 3600 | case 12: |
| 3601 | index = 0; /* hp_synctarg_12 */ |
| 3602 | break; |
| 3603 | case 13: |
| 3604 | index = 1; /* hp_synctarg_13 */ |
| 3605 | break; |
| 3606 | case 14: |
| 3607 | index = 2; /* hp_synctarg_14 */ |
| 3608 | break; |
| 3609 | case 15: |
| 3610 | index = 3; /* hp_synctarg_15 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3611 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3612 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3613 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3614 | WR_HARPOON(p_port + hp_synctarg_base + index, p_sync_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3615 | |
| 3616 | currTar_Info->TarSyncCtrl = p_sync_value; |
| 3617 | } |
| 3618 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3619 | /*--------------------------------------------------------------------- |
| 3620 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3621 | * Function: FPT_sresb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3622 | * |
| 3623 | * Description: Reset the desired card's SCSI bus. |
| 3624 | * |
| 3625 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3626 | static void FPT_sresb(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3627 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3628 | unsigned char scsiID, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3629 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3630 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3631 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3632 | WR_HARPOON(port + hp_page_ctrl, |
| 3633 | (RD_HARPOON(port + hp_page_ctrl) | G_INT_DISABLE)); |
| 3634 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3635 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3636 | WR_HARPOON(port + hp_scsictrl_0, SCSI_RST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3637 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3638 | scsiID = RD_HARPOON(port + hp_seltimeout); |
| 3639 | WR_HARPOON(port + hp_seltimeout, TO_5ms); |
| 3640 | WRW_HARPOON((port + hp_intstat), TIMEOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3641 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3642 | WR_HARPOON(port + hp_portctrl_0, (SCSI_PORT | START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3643 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3644 | while (!(RDW_HARPOON((port + hp_intstat)) & TIMEOUT)) { |
| 3645 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3646 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3647 | WR_HARPOON(port + hp_seltimeout, scsiID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3648 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3649 | WR_HARPOON(port + hp_scsictrl_0, ENA_SCAM_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3650 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3651 | FPT_Wait(port, TO_5ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3652 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3653 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3654 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3655 | WR_HARPOON(port + hp_int_mask, (RD_HARPOON(port + hp_int_mask) | 0x00)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3656 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3657 | for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++) { |
| 3658 | currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3659 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3660 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 3661 | currTar_Info->TarSyncCtrl = 0; |
| 3662 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 3663 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3664 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3665 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 3666 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 3667 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3668 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3669 | FPT_sssyncv(port, scsiID, NARROW_SCSI, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3670 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3671 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 3672 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3673 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3674 | FPT_BL_Card[p_card].scanIndex = 0x00; |
| 3675 | FPT_BL_Card[p_card].currentSCCB = NULL; |
| 3676 | FPT_BL_Card[p_card].globalFlags &= ~(F_TAG_STARTED | F_HOST_XFER_ACT |
| 3677 | | F_NEW_SCCB_CMD); |
| 3678 | FPT_BL_Card[p_card].cmdCounter = 0x00; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3679 | FPT_BL_Card[p_card].discQCount = 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3680 | FPT_BL_Card[p_card].tagQ_Lst = 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3681 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3682 | for (i = 0; i < QUEUE_DEPTH; i++) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3683 | FPT_BL_Card[p_card].discQ_Tbl[i] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3684 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3685 | WR_HARPOON(port + hp_page_ctrl, |
| 3686 | (RD_HARPOON(port + hp_page_ctrl) & ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3687 | |
| 3688 | } |
| 3689 | |
| 3690 | /*--------------------------------------------------------------------- |
| 3691 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3692 | * Function: FPT_ssenss |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3693 | * |
| 3694 | * Description: Setup for the Auto Sense command. |
| 3695 | * |
| 3696 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3697 | static void FPT_ssenss(struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3698 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3699 | unsigned char i; |
| 3700 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3701 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3702 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3703 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3704 | currSCCB->Save_CdbLen = currSCCB->CdbLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3705 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3706 | for (i = 0; i < 6; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3707 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3708 | currSCCB->Save_Cdb[i] = currSCCB->Cdb[i]; |
| 3709 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3710 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3711 | currSCCB->CdbLength = SIX_BYTE_CMD; |
| 3712 | currSCCB->Cdb[0] = SCSI_REQUEST_SENSE; |
| 3713 | currSCCB->Cdb[1] = currSCCB->Cdb[1] & (unsigned char)0xE0; /*Keep LUN. */ |
| 3714 | currSCCB->Cdb[2] = 0x00; |
| 3715 | currSCCB->Cdb[3] = 0x00; |
| 3716 | currSCCB->Cdb[4] = currSCCB->RequestSenseLength; |
| 3717 | currSCCB->Cdb[5] = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3718 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3719 | currSCCB->Sccb_XferCnt = (unsigned long)currSCCB->RequestSenseLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3720 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3721 | currSCCB->Sccb_ATC = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3722 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3723 | currSCCB->Sccb_XferState |= F_AUTO_SENSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3724 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3725 | currSCCB->Sccb_XferState &= ~F_SG_XFER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3726 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3727 | currSCCB->Sccb_idmsg = currSCCB->Sccb_idmsg & ~(unsigned char)DISC_PRIV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3728 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3729 | currSCCB->ControlByte = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3730 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3731 | currSCCB->Sccb_MGRFlags &= F_STATUSLOADED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3732 | } |
| 3733 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3734 | /*--------------------------------------------------------------------- |
| 3735 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3736 | * Function: FPT_sxfrp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3737 | * |
| 3738 | * Description: Transfer data into the bit bucket until the device |
| 3739 | * decides to switch phase. |
| 3740 | * |
| 3741 | *---------------------------------------------------------------------*/ |
| 3742 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3743 | static void FPT_sxfrp(unsigned long p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3744 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3745 | unsigned char curr_phz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3746 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3747 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3748 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3749 | if (FPT_BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3750 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3751 | FPT_hostDataXferAbort(p_port, p_card, |
| 3752 | FPT_BL_Card[p_card].currentSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3753 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3754 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3755 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3756 | /* If the Automation handled the end of the transfer then do not |
| 3757 | match the phase or we will get out of sync with the ISR. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3758 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3759 | if (RDW_HARPOON((p_port + hp_intstat)) & |
| 3760 | (BUS_FREE | XFER_CNT_0 | AUTO_INT)) |
| 3761 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3762 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3763 | WR_HARPOON(p_port + hp_xfercnt_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3764 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3765 | curr_phz = RD_HARPOON(p_port + hp_scsisig) & (unsigned char)S_SCSI_PHZ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3766 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3767 | WRW_HARPOON((p_port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3768 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3769 | WR_HARPOON(p_port + hp_scsisig, curr_phz); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3770 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3771 | while (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET)) && |
| 3772 | (curr_phz == |
| 3773 | (RD_HARPOON(p_port + hp_scsisig) & (unsigned char)S_SCSI_PHZ))) |
| 3774 | { |
| 3775 | if (curr_phz & (unsigned char)SCSI_IOBIT) { |
| 3776 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3777 | (SCSI_PORT | HOST_PORT | SCSI_INBIT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3778 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3779 | if (!(RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY)) { |
| 3780 | RD_HARPOON(p_port + hp_fifodata_0); |
| 3781 | } |
| 3782 | } else { |
| 3783 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3784 | (SCSI_PORT | HOST_PORT | HOST_WRT)); |
| 3785 | if (RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY) { |
| 3786 | WR_HARPOON(p_port + hp_fifodata_0, 0xFA); |
| 3787 | } |
| 3788 | } |
| 3789 | } /* End of While loop for padding data I/O phase */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3791 | while (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET))) { |
| 3792 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_REQ) |
| 3793 | break; |
| 3794 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3795 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3796 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3797 | (SCSI_PORT | HOST_PORT | SCSI_INBIT)); |
| 3798 | while (!(RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY)) { |
| 3799 | RD_HARPOON(p_port + hp_fifodata_0); |
| 3800 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3801 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3802 | if (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET))) { |
| 3803 | WR_HARPOON(p_port + hp_autostart_0, |
| 3804 | (AUTO_IMMED + DISCONNECT_START)); |
| 3805 | while (!(RDW_HARPOON((p_port + hp_intstat)) & AUTO_INT)) { |
| 3806 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3807 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3808 | if (RDW_HARPOON((p_port + hp_intstat)) & |
| 3809 | (ICMD_COMP | ITAR_DISC)) |
| 3810 | while (! |
| 3811 | (RDW_HARPOON((p_port + hp_intstat)) & |
| 3812 | (BUS_FREE | RSEL))) ; |
| 3813 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3814 | } |
| 3815 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3816 | /*--------------------------------------------------------------------- |
| 3817 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3818 | * Function: FPT_schkdd |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3819 | * |
| 3820 | * Description: Make sure data has been flushed from both FIFOs and abort |
| 3821 | * the operations if necessary. |
| 3822 | * |
| 3823 | *---------------------------------------------------------------------*/ |
| 3824 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3825 | static void FPT_schkdd(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3826 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3827 | unsigned short TimeOutLoop; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 3828 | unsigned char sPhase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3829 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3830 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3831 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3832 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3833 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3834 | if ((currSCCB->Sccb_scsistat != DATA_OUT_ST) && |
| 3835 | (currSCCB->Sccb_scsistat != DATA_IN_ST)) { |
| 3836 | return; |
| 3837 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3838 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3839 | if (currSCCB->Sccb_XferState & F_ODD_BALL_CNT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3840 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3841 | currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3843 | currSCCB->Sccb_XferCnt = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3844 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3845 | currSCCB->Sccb_XferState &= ~F_ODD_BALL_CNT; |
| 3846 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
| 3847 | WR_HARPOON(port + hp_xferstat, 0x00); |
| 3848 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3849 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3850 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3851 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3852 | currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3853 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3854 | currSCCB->Sccb_XferCnt = 0; |
| 3855 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3856 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3857 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 3858 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3859 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3860 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 3861 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 3862 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3863 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3864 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3865 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3866 | while (RD_HARPOON(port + hp_scsisig) & SCSI_ACK) { |
| 3867 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3868 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3869 | TimeOutLoop = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3870 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3871 | while (RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY) { |
| 3872 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 3873 | return; |
| 3874 | } |
| 3875 | if (RD_HARPOON(port + hp_offsetctr) & (unsigned char)0x1F) { |
| 3876 | break; |
| 3877 | } |
| 3878 | if (RDW_HARPOON((port + hp_intstat)) & RESET) { |
| 3879 | return; |
| 3880 | } |
| 3881 | if ((RD_HARPOON(port + hp_scsisig) & SCSI_REQ) |
| 3882 | || (TimeOutLoop++ > 0x3000)) |
| 3883 | break; |
| 3884 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3885 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3886 | sPhase = RD_HARPOON(port + hp_scsisig) & (SCSI_BSY | S_SCSI_PHZ); |
| 3887 | if ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) || |
| 3888 | (RD_HARPOON(port + hp_offsetctr) & (unsigned char)0x1F) || |
| 3889 | (sPhase == (SCSI_BSY | S_DATAO_PH)) || |
| 3890 | (sPhase == (SCSI_BSY | S_DATAI_PH))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3891 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3892 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3893 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3894 | if (!(currSCCB->Sccb_XferState & F_ALL_XFERRED)) { |
| 3895 | if (currSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
| 3896 | FPT_phaseDataIn(port, p_card); |
| 3897 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3898 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3899 | else { |
| 3900 | FPT_phaseDataOut(port, p_card); |
| 3901 | } |
| 3902 | } else { |
| 3903 | FPT_sxfrp(port, p_card); |
| 3904 | if (!(RDW_HARPOON((port + hp_intstat)) & |
| 3905 | (BUS_FREE | ICMD_COMP | ITAR_DISC | RESET))) { |
| 3906 | WRW_HARPOON((port + hp_intstat), AUTO_INT); |
| 3907 | FPT_phaseDecode(port, p_card); |
| 3908 | } |
| 3909 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3910 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3911 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3912 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3913 | else { |
| 3914 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
| 3915 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3916 | } |
| 3917 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3918 | /*--------------------------------------------------------------------- |
| 3919 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3920 | * Function: FPT_sinits |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3921 | * |
| 3922 | * Description: Setup SCCB manager fields in this SCCB. |
| 3923 | * |
| 3924 | *---------------------------------------------------------------------*/ |
| 3925 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3926 | static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3927 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3928 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3929 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3930 | if ((p_sccb->TargID > MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3931 | return; |
| 3932 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3933 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3934 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3935 | p_sccb->Sccb_XferState = 0x00; |
| 3936 | p_sccb->Sccb_XferCnt = p_sccb->DataLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3937 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3938 | if ((p_sccb->OperationCode == SCATTER_GATHER_COMMAND) || |
| 3939 | (p_sccb->OperationCode == RESIDUAL_SG_COMMAND)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3940 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3941 | p_sccb->Sccb_SGoffset = 0; |
| 3942 | p_sccb->Sccb_XferState = F_SG_XFER; |
| 3943 | p_sccb->Sccb_XferCnt = 0x00; |
| 3944 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3945 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3946 | if (p_sccb->DataLength == 0x00) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3947 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3948 | p_sccb->Sccb_XferState |= F_ALL_XFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3949 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3950 | if (p_sccb->ControlByte & F_USE_CMD_Q) { |
| 3951 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT) |
| 3952 | p_sccb->ControlByte &= ~F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3953 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3954 | else |
| 3955 | currTar_Info->TarStatus |= TAG_Q_TRYING; |
| 3956 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3957 | |
| 3958 | /* For !single SCSI device in system & device allow Disconnect |
| 3959 | or command is tag_q type then send Cmd with Disconnect Enable |
| 3960 | else send Cmd with Disconnect Disable */ |
| 3961 | |
| 3962 | /* |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3963 | if (((!(FPT_BL_Card[p_card].globalFlags & F_SINGLE_DEVICE)) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3964 | (currTar_Info->TarStatus & TAR_ALLOW_DISC)) || |
| 3965 | (currTar_Info->TarStatus & TAG_Q_TRYING)) { |
| 3966 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3967 | if ((currTar_Info->TarStatus & TAR_ALLOW_DISC) || |
| 3968 | (currTar_Info->TarStatus & TAG_Q_TRYING)) { |
| 3969 | p_sccb->Sccb_idmsg = |
| 3970 | (unsigned char)(SMIDENT | DISC_PRIV) | p_sccb->Lun; |
| 3971 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3972 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3973 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3974 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3975 | p_sccb->Sccb_idmsg = (unsigned char)SMIDENT | p_sccb->Lun; |
| 3976 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3977 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3978 | p_sccb->HostStatus = 0x00; |
| 3979 | p_sccb->TargetStatus = 0x00; |
| 3980 | p_sccb->Sccb_tag = 0x00; |
| 3981 | p_sccb->Sccb_MGRFlags = 0x00; |
| 3982 | p_sccb->Sccb_sgseg = 0x00; |
| 3983 | p_sccb->Sccb_ATC = 0x00; |
| 3984 | p_sccb->Sccb_savedATC = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3985 | /* |
| 3986 | p_sccb->SccbVirtDataPtr = 0x00; |
| 3987 | p_sccb->Sccb_forwardlink = NULL; |
| 3988 | p_sccb->Sccb_backlink = NULL; |
| 3989 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3990 | p_sccb->Sccb_scsistat = BUS_FREE_ST; |
| 3991 | p_sccb->SccbStatus = SCCB_IN_PROCESS; |
| 3992 | p_sccb->Sccb_scsimsg = SMNO_OP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3993 | |
| 3994 | } |
| 3995 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3996 | /*--------------------------------------------------------------------- |
| 3997 | * |
| 3998 | * Function: Phase Decode |
| 3999 | * |
| 4000 | * Description: Determine the phase and call the appropriate function. |
| 4001 | * |
| 4002 | *---------------------------------------------------------------------*/ |
| 4003 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4004 | static void FPT_phaseDecode(unsigned long p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4005 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4006 | unsigned char phase_ref; |
| 4007 | void (*phase) (unsigned long, unsigned char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4008 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4009 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4010 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4011 | phase_ref = |
| 4012 | (unsigned char)(RD_HARPOON(p_port + hp_scsisig) & S_SCSI_PHZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4013 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4014 | phase = FPT_s_PhaseTbl[phase_ref]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4015 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4016 | (*phase) (p_port, p_card); /* Call the correct phase func */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4017 | } |
| 4018 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4019 | /*--------------------------------------------------------------------- |
| 4020 | * |
| 4021 | * Function: Data Out Phase |
| 4022 | * |
| 4023 | * Description: Start up both the BusMaster and Xbow. |
| 4024 | * |
| 4025 | *---------------------------------------------------------------------*/ |
| 4026 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4027 | static void FPT_phaseDataOut(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | { |
| 4029 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4030 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4031 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4032 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 4033 | if (currSCCB == NULL) { |
| 4034 | return; /* Exit if No SCCB record */ |
| 4035 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4036 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4037 | currSCCB->Sccb_scsistat = DATA_OUT_ST; |
| 4038 | currSCCB->Sccb_XferState &= ~(F_HOST_XFER_DIR | F_NO_DATA_YET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4039 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4040 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4041 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4042 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4043 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4044 | WR_HARPOON(port + hp_autostart_0, (END_DATA + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4045 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4046 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4047 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4048 | if (currSCCB->Sccb_XferCnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4049 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4050 | if ((currSCCB->ControlByte & SCCB_DATA_XFER_OUT) && |
| 4051 | (currSCCB->HostStatus == SCCB_COMPLETE)) |
| 4052 | currSCCB->HostStatus = SCCB_DATA_OVER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4053 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4054 | FPT_sxfrp(port, p_card); |
| 4055 | if (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | RESET))) |
| 4056 | FPT_phaseDecode(port, p_card); |
| 4057 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4058 | } |
| 4059 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4060 | /*--------------------------------------------------------------------- |
| 4061 | * |
| 4062 | * Function: Data In Phase |
| 4063 | * |
| 4064 | * Description: Startup the BusMaster and the XBOW. |
| 4065 | * |
| 4066 | *---------------------------------------------------------------------*/ |
| 4067 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4068 | static void FPT_phaseDataIn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4069 | { |
| 4070 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4071 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4073 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4074 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4075 | if (currSCCB == NULL) { |
| 4076 | return; /* Exit if No SCCB record */ |
| 4077 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4078 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4079 | currSCCB->Sccb_scsistat = DATA_IN_ST; |
| 4080 | currSCCB->Sccb_XferState |= F_HOST_XFER_DIR; |
| 4081 | currSCCB->Sccb_XferState &= ~F_NO_DATA_YET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4082 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4083 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4084 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4085 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4086 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4087 | WR_HARPOON(port + hp_autostart_0, (END_DATA + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4088 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4089 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4090 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4091 | if (currSCCB->Sccb_XferCnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4092 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4093 | if ((currSCCB->ControlByte & SCCB_DATA_XFER_IN) && |
| 4094 | (currSCCB->HostStatus == SCCB_COMPLETE)) |
| 4095 | currSCCB->HostStatus = SCCB_DATA_OVER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4096 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4097 | FPT_sxfrp(port, p_card); |
| 4098 | if (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | RESET))) |
| 4099 | FPT_phaseDecode(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4100 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4101 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4102 | } |
| 4103 | |
| 4104 | /*--------------------------------------------------------------------- |
| 4105 | * |
| 4106 | * Function: Command Phase |
| 4107 | * |
| 4108 | * Description: Load the CDB into the automation and start it up. |
| 4109 | * |
| 4110 | *---------------------------------------------------------------------*/ |
| 4111 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4112 | static void FPT_phaseCommand(unsigned long p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4113 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4114 | struct sccb *currSCCB; |
| 4115 | unsigned long cdb_reg; |
| 4116 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4117 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4118 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4119 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4120 | if (currSCCB->OperationCode == RESET_COMMAND) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4121 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4122 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4123 | currSCCB->CdbLength = SIX_BYTE_CMD; |
| 4124 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4125 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4126 | WR_HARPOON(p_port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4127 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4128 | ARAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4129 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4130 | cdb_reg = p_port + CMD_STRT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4131 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4132 | for (i = 0; i < currSCCB->CdbLength; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4133 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4134 | if (currSCCB->OperationCode == RESET_COMMAND) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4135 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4136 | WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + 0x00)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4137 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4138 | else |
| 4139 | WRW_HARPOON(cdb_reg, |
| 4140 | (MPM_OP + ACOMMAND + currSCCB->Cdb[i])); |
| 4141 | cdb_reg += 2; |
| 4142 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4143 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4144 | if (currSCCB->CdbLength != TWELVE_BYTE_CMD) |
| 4145 | WRW_HARPOON(cdb_reg, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4146 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4147 | WR_HARPOON(p_port + hp_portctrl_0, (SCSI_PORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4148 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4149 | currSCCB->Sccb_scsistat = COMMAND_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4150 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4151 | WR_HARPOON(p_port + hp_autostart_3, (AUTO_IMMED | CMD_ONLY_STRT)); |
| 4152 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4153 | } |
| 4154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4155 | /*--------------------------------------------------------------------- |
| 4156 | * |
| 4157 | * Function: Status phase |
| 4158 | * |
| 4159 | * Description: Bring in the status and command complete message bytes |
| 4160 | * |
| 4161 | *---------------------------------------------------------------------*/ |
| 4162 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4163 | static void FPT_phaseStatus(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4164 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4165 | /* Start-up the automation to finish off this command and let the |
| 4166 | isr handle the interrupt for command complete when it comes in. |
| 4167 | We could wait here for the interrupt to be generated? |
| 4168 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4169 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4170 | WR_HARPOON(port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4171 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4172 | WR_HARPOON(port + hp_autostart_0, (AUTO_IMMED + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4173 | } |
| 4174 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4175 | /*--------------------------------------------------------------------- |
| 4176 | * |
| 4177 | * Function: Phase Message Out |
| 4178 | * |
| 4179 | * Description: Send out our message (if we have one) and handle whatever |
| 4180 | * else is involed. |
| 4181 | * |
| 4182 | *---------------------------------------------------------------------*/ |
| 4183 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4184 | static void FPT_phaseMsgOut(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4185 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4186 | unsigned char message, scsiID; |
| 4187 | struct sccb *currSCCB; |
| 4188 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4189 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4190 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4191 | |
| 4192 | if (currSCCB != NULL) { |
| 4193 | |
| 4194 | message = currSCCB->Sccb_scsimsg; |
| 4195 | scsiID = currSCCB->TargID; |
| 4196 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4197 | if (message == SMDEV_RESET) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4198 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4199 | currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4200 | currTar_Info->TarSyncCtrl = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4201 | FPT_sssyncv(port, scsiID, NARROW_SCSI, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4202 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4203 | if (FPT_sccbMgrTbl[p_card][scsiID]. |
| 4204 | TarEEValue & EE_SYNC_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4205 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4206 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus &= |
| 4207 | ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4208 | |
| 4209 | } |
| 4210 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4211 | if (FPT_sccbMgrTbl[p_card][scsiID]. |
| 4212 | TarEEValue & EE_WIDE_SCSI) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4213 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4214 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus &= |
| 4215 | ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4216 | } |
| 4217 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4218 | FPT_queueFlushSccb(p_card, SCCB_COMPLETE); |
| 4219 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 4220 | } else if (currSCCB->Sccb_scsistat == ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4221 | currSCCB->HostStatus = SCCB_COMPLETE; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4222 | if (FPT_BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] != |
| 4223 | NULL) { |
| 4224 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4225 | Sccb_tag] = NULL; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4226 | FPT_sccbMgrTbl[p_card][scsiID].TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4227 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4229 | } |
| 4230 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4231 | else if (currSCCB->Sccb_scsistat < COMMAND_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4232 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4233 | if (message == SMNO_OP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4234 | currSCCB->Sccb_MGRFlags |= F_DEV_SELECTED; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4235 | |
| 4236 | FPT_ssel(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4237 | return; |
| 4238 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4239 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4240 | |
| 4241 | if (message == SMABORT) |
| 4242 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4243 | FPT_queueFlushSccb(p_card, SCCB_COMPLETE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4244 | } |
| 4245 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4246 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4247 | message = SMABORT; |
| 4248 | } |
| 4249 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4250 | WRW_HARPOON((port + hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4251 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4252 | WR_HARPOON(port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4253 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4254 | WR_HARPOON(port + hp_scsidata_0, message); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4255 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4256 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4257 | |
| 4258 | ACCEPT_MSG(port); |
| 4259 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4260 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4261 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4262 | if ((message == SMABORT) || (message == SMDEV_RESET) || |
| 4263 | (message == SMABORT_TAG)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4264 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4265 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | PHASE))) { |
| 4266 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4267 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4268 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 4269 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4270 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4271 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4272 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4273 | if ((FPT_BL_Card[p_card]. |
| 4274 | globalFlags & F_CONLUN_IO) |
| 4275 | && |
| 4276 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4277 | TarStatus & TAR_TAG_Q_MASK) != |
| 4278 | TAG_Q_TRYING)) |
| 4279 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4280 | TargID]. |
| 4281 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4282 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4283 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4284 | TargID]. |
| 4285 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4286 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4287 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 4288 | currSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4289 | } |
| 4290 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4291 | else { |
| 4292 | FPT_BL_Card[p_card].globalFlags |= |
| 4293 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4294 | } |
| 4295 | } |
| 4296 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4297 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4298 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4299 | FPT_sxfrp(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4300 | } |
| 4301 | } |
| 4302 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4303 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4304 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4305 | if (message == SMPARITY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4306 | currSCCB->Sccb_scsimsg = SMNO_OP; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4307 | WR_HARPOON(port + hp_autostart_1, |
| 4308 | (AUTO_IMMED + DISCONNECT_START)); |
| 4309 | } else { |
| 4310 | FPT_sxfrp(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4311 | } |
| 4312 | } |
| 4313 | } |
| 4314 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4315 | /*--------------------------------------------------------------------- |
| 4316 | * |
| 4317 | * Function: Message In phase |
| 4318 | * |
| 4319 | * Description: Bring in the message and determine what to do with it. |
| 4320 | * |
| 4321 | *---------------------------------------------------------------------*/ |
| 4322 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4323 | static void FPT_phaseMsgIn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4324 | { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 4325 | unsigned char message; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4326 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4327 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4328 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4329 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4330 | if (FPT_BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4331 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4332 | FPT_phaseChkFifo(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4333 | } |
| 4334 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4335 | message = RD_HARPOON(port + hp_scsidata_0); |
| 4336 | if ((message == SMDISC) || (message == SMSAVE_DATA_PTR)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4337 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4338 | WR_HARPOON(port + hp_autostart_1, |
| 4339 | (AUTO_IMMED + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4340 | |
| 4341 | } |
| 4342 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4343 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4344 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4345 | message = FPT_sfm(port, currSCCB); |
| 4346 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4347 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4348 | FPT_sdecm(message, port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4349 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4350 | } else { |
| 4351 | if (currSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4352 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4353 | WR_HARPOON(port + hp_autostart_1, |
| 4354 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4355 | } |
| 4356 | } |
| 4357 | |
| 4358 | } |
| 4359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4360 | /*--------------------------------------------------------------------- |
| 4361 | * |
| 4362 | * Function: Illegal phase |
| 4363 | * |
| 4364 | * Description: Target switched to some illegal phase, so all we can do |
| 4365 | * is report an error back to the host (if that is possible) |
| 4366 | * and send an ABORT message to the misbehaving target. |
| 4367 | * |
| 4368 | *---------------------------------------------------------------------*/ |
| 4369 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4370 | static void FPT_phaseIllegal(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4371 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4372 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4373 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4374 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4375 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4376 | WR_HARPOON(port + hp_scsisig, RD_HARPOON(port + hp_scsisig)); |
| 4377 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4379 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4380 | currSCCB->Sccb_scsistat = ABORT_ST; |
| 4381 | currSCCB->Sccb_scsimsg = SMABORT; |
| 4382 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4383 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4384 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4385 | } |
| 4386 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4387 | /*--------------------------------------------------------------------- |
| 4388 | * |
| 4389 | * Function: Phase Check FIFO |
| 4390 | * |
| 4391 | * Description: Make sure data has been flushed from both FIFOs and abort |
| 4392 | * the operations if necessary. |
| 4393 | * |
| 4394 | *---------------------------------------------------------------------*/ |
| 4395 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4396 | static void FPT_phaseChkFifo(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4397 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4398 | unsigned long xfercnt; |
| 4399 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4400 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4401 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4402 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4403 | if (currSCCB->Sccb_scsistat == DATA_IN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4404 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4405 | while ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) && |
| 4406 | (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY)) { |
| 4407 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4408 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4409 | if (!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) { |
| 4410 | currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4412 | currSCCB->Sccb_XferCnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4413 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4414 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 4415 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
| 4416 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 4417 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 4418 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4420 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4421 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4422 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4423 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4424 | while ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) |
| 4425 | && (RD_HARPOON(port + hp_ext_status) & |
| 4426 | BM_CMD_BUSY)) { |
| 4427 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4429 | } |
| 4430 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4431 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4432 | /*End Data In specific code. */ |
| 4433 | GET_XFER_CNT(port, xfercnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4434 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4435 | WR_HARPOON(port + hp_xfercnt_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4437 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4439 | currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - xfercnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4440 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4441 | currSCCB->Sccb_XferCnt = xfercnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4442 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4443 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 4444 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4445 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4446 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 4447 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 4448 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4450 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4451 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4452 | WR_HARPOON(port + hp_fifowrite, 0x00); |
| 4453 | WR_HARPOON(port + hp_fiforead, 0x00); |
| 4454 | WR_HARPOON(port + hp_xferstat, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4455 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4456 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4457 | } |
| 4458 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4459 | /*--------------------------------------------------------------------- |
| 4460 | * |
| 4461 | * Function: Phase Bus Free |
| 4462 | * |
| 4463 | * Description: We just went bus free so figure out if it was |
| 4464 | * because of command complete or from a disconnect. |
| 4465 | * |
| 4466 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4467 | static void FPT_phaseBusFree(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4468 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4469 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4470 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4471 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4472 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4473 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4474 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4475 | DISABLE_AUTO(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4476 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4477 | if (currSCCB->OperationCode == RESET_COMMAND) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4478 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4479 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4480 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4481 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4482 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4483 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4484 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4485 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4486 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4487 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4488 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, |
| 4489 | p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4490 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4491 | FPT_queueSearchSelect(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4492 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4493 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4494 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4495 | else if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
| 4496 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= |
| 4497 | (unsigned char)SYNC_SUPPORTED; |
| 4498 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4499 | ~EE_SYNC_MASK; |
| 4500 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4501 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4502 | else if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
| 4503 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus = |
| 4504 | (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4505 | TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4506 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4507 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4508 | ~EE_WIDE_SCSI; |
| 4509 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4510 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4511 | else if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { |
| 4512 | /* Make sure this is not a phony BUS_FREE. If we were |
| 4513 | reselected or if BUSY is NOT on then this is a |
| 4514 | valid BUS FREE. SRR Wednesday, 5/10/1995. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4515 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4516 | if ((!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) || |
| 4517 | (RDW_HARPOON((port + hp_intstat)) & RSEL)) { |
| 4518 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4519 | TarStatus &= ~TAR_TAG_Q_MASK; |
| 4520 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4521 | TarStatus |= TAG_Q_REJECT; |
| 4522 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4523 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4524 | else { |
| 4525 | return; |
| 4526 | } |
| 4527 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4528 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4529 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4530 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4531 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4532 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4533 | if (!currSCCB->HostStatus) { |
| 4534 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4535 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4537 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4538 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4539 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4540 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4541 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4542 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4543 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4544 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4545 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4546 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, |
| 4547 | p_card); |
| 4548 | return; |
| 4549 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4550 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4551 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4552 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4553 | } /*end if !=null */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4554 | } |
| 4555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4556 | /*--------------------------------------------------------------------- |
| 4557 | * |
| 4558 | * Function: Auto Load Default Map |
| 4559 | * |
| 4560 | * Description: Load the Automation RAM with the defualt map values. |
| 4561 | * |
| 4562 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4563 | static void FPT_autoLoadDefaultMap(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4564 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4565 | unsigned long map_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4566 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4567 | ARAM_ACCESS(p_port); |
| 4568 | map_addr = p_port + hp_aramBase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4569 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4570 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0xC0)); /*ID MESSAGE */ |
| 4571 | map_addr += 2; |
| 4572 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0x20)); /*SIMPLE TAG QUEUEING MSG */ |
| 4573 | map_addr += 2; |
| 4574 | WRW_HARPOON(map_addr, RAT_OP); /*RESET ATTENTION */ |
| 4575 | map_addr += 2; |
| 4576 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0x00)); /*TAG ID MSG */ |
| 4577 | map_addr += 2; |
| 4578 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 0 */ |
| 4579 | map_addr += 2; |
| 4580 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 1 */ |
| 4581 | map_addr += 2; |
| 4582 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 2 */ |
| 4583 | map_addr += 2; |
| 4584 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 3 */ |
| 4585 | map_addr += 2; |
| 4586 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 4 */ |
| 4587 | map_addr += 2; |
| 4588 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 5 */ |
| 4589 | map_addr += 2; |
| 4590 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 6 */ |
| 4591 | map_addr += 2; |
| 4592 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 7 */ |
| 4593 | map_addr += 2; |
| 4594 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 8 */ |
| 4595 | map_addr += 2; |
| 4596 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 9 */ |
| 4597 | map_addr += 2; |
| 4598 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 10 */ |
| 4599 | map_addr += 2; |
| 4600 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 11 */ |
| 4601 | map_addr += 2; |
| 4602 | WRW_HARPOON(map_addr, (CPE_OP + ADATA_OUT + DINT)); /*JUMP IF DATA OUT */ |
| 4603 | map_addr += 2; |
| 4604 | WRW_HARPOON(map_addr, (TCB_OP + FIFO_0 + DI)); /*JUMP IF NO DATA IN FIFO */ |
| 4605 | map_addr += 2; /*This means AYNC DATA IN */ |
| 4606 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IDO_STRT)); /*STOP AND INTERRUPT */ |
| 4607 | map_addr += 2; |
| 4608 | WRW_HARPOON(map_addr, (CPE_OP + ADATA_IN + DINT)); /*JUMP IF NOT DATA IN PHZ */ |
| 4609 | map_addr += 2; |
| 4610 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + ST)); /*IF NOT MSG IN CHECK 4 DATA IN */ |
| 4611 | map_addr += 2; |
| 4612 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x02)); /*SAVE DATA PTR MSG? */ |
| 4613 | map_addr += 2; |
| 4614 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + DC)); /*GO CHECK FOR DISCONNECT MSG */ |
| 4615 | map_addr += 2; |
| 4616 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_AR1)); /*SAVE DATA PTRS MSG */ |
| 4617 | map_addr += 2; |
| 4618 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + ST)); /*IF NOT MSG IN CHECK DATA IN */ |
| 4619 | map_addr += 2; |
| 4620 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x04)); /*DISCONNECT MSG? */ |
| 4621 | map_addr += 2; |
| 4622 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + UNKNWN)); /*UKNKNOWN MSG */ |
| 4623 | map_addr += 2; |
| 4624 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_BUCKET)); /*XFER DISCONNECT MSG */ |
| 4625 | map_addr += 2; |
| 4626 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ITAR_DISC)); /*STOP AND INTERRUPT */ |
| 4627 | map_addr += 2; |
| 4628 | WRW_HARPOON(map_addr, (CPN_OP + ASTATUS + UNKNWN)); /*JUMP IF NOT STATUS PHZ. */ |
| 4629 | map_addr += 2; |
| 4630 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_AR0)); /*GET STATUS BYTE */ |
| 4631 | map_addr += 2; |
| 4632 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + CC)); /*ERROR IF NOT MSG IN PHZ */ |
| 4633 | map_addr += 2; |
| 4634 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x00)); /*CHECK FOR CMD COMPLETE MSG. */ |
| 4635 | map_addr += 2; |
| 4636 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + CC)); /*ERROR IF NOT CMD COMPLETE MSG. */ |
| 4637 | map_addr += 2; |
| 4638 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_BUCKET)); /*GET CMD COMPLETE MSG */ |
| 4639 | map_addr += 2; |
| 4640 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ICMD_COMP)); /*END OF COMMAND */ |
| 4641 | map_addr += 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4642 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4643 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IUNKWN)); /*RECEIVED UNKNOWN MSG BYTE */ |
| 4644 | map_addr += 2; |
| 4645 | WRW_HARPOON(map_addr, (SSI_OP + SSI_INO_CC)); /*NO COMMAND COMPLETE AFTER STATUS */ |
| 4646 | map_addr += 2; |
| 4647 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ITICKLE)); /*BIOS Tickled the Mgr */ |
| 4648 | map_addr += 2; |
| 4649 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IRFAIL)); /*EXPECTED ID/TAG MESSAGES AND */ |
| 4650 | map_addr += 2; /* DIDN'T GET ONE */ |
| 4651 | WRW_HARPOON(map_addr, (CRR_OP + AR3 + S_IDREG)); /* comp SCSI SEL ID & AR3 */ |
| 4652 | map_addr += 2; |
| 4653 | WRW_HARPOON(map_addr, (BRH_OP + EQUAL + 0x00)); /*SEL ID OK then Conti. */ |
| 4654 | map_addr += 2; |
| 4655 | WRW_HARPOON(map_addr, (SSI_OP + SSI_INO_CC)); /*NO COMMAND COMPLETE AFTER STATUS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4656 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4657 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4658 | } |
| 4659 | |
| 4660 | /*--------------------------------------------------------------------- |
| 4661 | * |
| 4662 | * Function: Auto Command Complete |
| 4663 | * |
| 4664 | * Description: Post command back to host and find another command |
| 4665 | * to execute. |
| 4666 | * |
| 4667 | *---------------------------------------------------------------------*/ |
| 4668 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4669 | static void FPT_autoCmdCmplt(unsigned long p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4670 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4671 | struct sccb *currSCCB; |
| 4672 | unsigned char status_byte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4673 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4674 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4675 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4676 | status_byte = RD_HARPOON(p_port + hp_gp_reg_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4677 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4678 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUN_CA = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4679 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4680 | if (status_byte != SSGOOD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4681 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4682 | if (status_byte == SSQ_FULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4683 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4684 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4685 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4686 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4687 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4688 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4689 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4690 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4691 | FPT_BL_Card[p_card]. |
| 4692 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4693 | [currSCCB->TargID]. |
| 4694 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4695 | NULL; |
| 4696 | } else { |
| 4697 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4698 | TarLUNBusy[0] = 1; |
| 4699 | if (currSCCB->Sccb_tag) { |
| 4700 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4701 | FPT_BL_Card[p_card]. |
| 4702 | discQCount--; |
| 4703 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4704 | Sccb_tag] |
| 4705 | = NULL; |
| 4706 | } else { |
| 4707 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4708 | FPT_BL_Card[p_card]. |
| 4709 | discQCount--; |
| 4710 | FPT_BL_Card[p_card]. |
| 4711 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4712 | [currSCCB->TargID]. |
| 4713 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4714 | } |
| 4715 | } |
| 4716 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4717 | currSCCB->Sccb_MGRFlags |= F_STATUSLOADED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4718 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4719 | FPT_queueSelectFail(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4720 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4721 | return; |
| 4722 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4723 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4724 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
| 4725 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= |
| 4726 | (unsigned char)SYNC_SUPPORTED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4727 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4728 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4729 | ~EE_SYNC_MASK; |
| 4730 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4731 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4732 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4733 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4734 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4735 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4736 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4737 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4738 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4739 | FPT_BL_Card[p_card]. |
| 4740 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4741 | [currSCCB->TargID]. |
| 4742 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4743 | NULL; |
| 4744 | } else { |
| 4745 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4746 | TarLUNBusy[0] = 1; |
| 4747 | if (currSCCB->Sccb_tag) { |
| 4748 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4749 | FPT_BL_Card[p_card]. |
| 4750 | discQCount--; |
| 4751 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4752 | Sccb_tag] |
| 4753 | = NULL; |
| 4754 | } else { |
| 4755 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4756 | FPT_BL_Card[p_card]. |
| 4757 | discQCount--; |
| 4758 | FPT_BL_Card[p_card]. |
| 4759 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4760 | [currSCCB->TargID]. |
| 4761 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4762 | } |
| 4763 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4764 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4765 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4766 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4767 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4768 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4769 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4770 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus = |
| 4771 | (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4772 | TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4773 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4774 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4775 | ~EE_WIDE_SCSI; |
| 4776 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4777 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4778 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4779 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4780 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4781 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4782 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4783 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4784 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4785 | FPT_BL_Card[p_card]. |
| 4786 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4787 | [currSCCB->TargID]. |
| 4788 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4789 | NULL; |
| 4790 | } else { |
| 4791 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4792 | TarLUNBusy[0] = 1; |
| 4793 | if (currSCCB->Sccb_tag) { |
| 4794 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4795 | FPT_BL_Card[p_card]. |
| 4796 | discQCount--; |
| 4797 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4798 | Sccb_tag] |
| 4799 | = NULL; |
| 4800 | } else { |
| 4801 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4802 | FPT_BL_Card[p_card]. |
| 4803 | discQCount--; |
| 4804 | FPT_BL_Card[p_card]. |
| 4805 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4806 | [currSCCB->TargID]. |
| 4807 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4808 | } |
| 4809 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4810 | return; |
| 4811 | |
| 4812 | } |
| 4813 | |
| 4814 | if (status_byte == SSCHECK) { |
| 4815 | if (FPT_BL_Card[p_card].globalFlags & F_DO_RENEGO) { |
| 4816 | if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4817 | TarEEValue & EE_SYNC_MASK) { |
| 4818 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4819 | TargID]. |
| 4820 | TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4821 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4822 | if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4823 | TarEEValue & EE_WIDE_SCSI) { |
| 4824 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4825 | TargID]. |
| 4826 | TarStatus &= ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4827 | } |
| 4828 | } |
| 4829 | } |
| 4830 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4831 | if (!(currSCCB->Sccb_XferState & F_AUTO_SENSE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4832 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4833 | currSCCB->SccbStatus = SCCB_ERROR; |
| 4834 | currSCCB->TargetStatus = status_byte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4835 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4836 | if (status_byte == SSCHECK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4837 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4838 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4839 | TarLUN_CA = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4840 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4841 | if (currSCCB->RequestSenseLength != |
| 4842 | NO_AUTO_REQUEST_SENSE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4843 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4844 | if (currSCCB->RequestSenseLength == 0) |
| 4845 | currSCCB->RequestSenseLength = |
| 4846 | 14; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4847 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4848 | FPT_ssenss(&FPT_BL_Card[p_card]); |
| 4849 | FPT_BL_Card[p_card].globalFlags |= |
| 4850 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4851 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4852 | if (((FPT_BL_Card[p_card]. |
| 4853 | globalFlags & F_CONLUN_IO) |
| 4854 | && |
| 4855 | ((FPT_sccbMgrTbl[p_card] |
| 4856 | [currSCCB->TargID]. |
| 4857 | TarStatus & TAR_TAG_Q_MASK) != |
| 4858 | TAG_Q_TRYING))) { |
| 4859 | FPT_sccbMgrTbl[p_card] |
| 4860 | [currSCCB->TargID]. |
| 4861 | TarLUNBusy[currSCCB->Lun] = |
| 4862 | 1; |
| 4863 | if (FPT_BL_Card[p_card]. |
| 4864 | discQCount != 0) |
| 4865 | FPT_BL_Card[p_card]. |
| 4866 | discQCount--; |
| 4867 | FPT_BL_Card[p_card]. |
| 4868 | discQ_Tbl[FPT_sccbMgrTbl |
| 4869 | [p_card] |
| 4870 | [currSCCB-> |
| 4871 | TargID]. |
| 4872 | LunDiscQ_Idx |
| 4873 | [currSCCB->Lun]] = |
| 4874 | NULL; |
| 4875 | } else { |
| 4876 | FPT_sccbMgrTbl[p_card] |
| 4877 | [currSCCB->TargID]. |
| 4878 | TarLUNBusy[0] = 1; |
| 4879 | if (currSCCB->Sccb_tag) { |
| 4880 | if (FPT_BL_Card[p_card]. |
| 4881 | discQCount != 0) |
| 4882 | FPT_BL_Card |
| 4883 | [p_card]. |
| 4884 | discQCount--; |
| 4885 | FPT_BL_Card[p_card]. |
| 4886 | discQ_Tbl[currSCCB-> |
| 4887 | Sccb_tag] |
| 4888 | = NULL; |
| 4889 | } else { |
| 4890 | if (FPT_BL_Card[p_card]. |
| 4891 | discQCount != 0) |
| 4892 | FPT_BL_Card |
| 4893 | [p_card]. |
| 4894 | discQCount--; |
| 4895 | FPT_BL_Card[p_card]. |
| 4896 | discQ_Tbl |
| 4897 | [FPT_sccbMgrTbl |
| 4898 | [p_card][currSCCB-> |
| 4899 | TargID]. |
| 4900 | LunDiscQ_Idx[0]] = |
| 4901 | NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4902 | } |
| 4903 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4904 | return; |
| 4905 | } |
| 4906 | } |
| 4907 | } |
| 4908 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4909 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4910 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4911 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4912 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4913 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB-> |
| 4914 | Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4915 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4916 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4917 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4918 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4919 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4920 | |
| 4921 | #define SHORT_WAIT 0x0000000F |
| 4922 | #define LONG_WAIT 0x0000FFFFL |
| 4923 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4924 | /*--------------------------------------------------------------------- |
| 4925 | * |
| 4926 | * Function: Data Transfer Processor |
| 4927 | * |
| 4928 | * Description: This routine performs two tasks. |
| 4929 | * (1) Start data transfer by calling HOST_DATA_XFER_START |
| 4930 | * function. Once data transfer is started, (2) Depends |
| 4931 | * on the type of data transfer mode Scatter/Gather mode |
| 4932 | * or NON Scatter/Gather mode. In NON Scatter/Gather mode, |
| 4933 | * this routine checks Sccb_MGRFlag (F_HOST_XFER_ACT bit) for |
| 4934 | * data transfer done. In Scatter/Gather mode, this routine |
| 4935 | * checks bus master command complete and dual rank busy |
| 4936 | * bit to keep chaining SC transfer command. Similarly, |
| 4937 | * in Scatter/Gather mode, it checks Sccb_MGRFlag |
| 4938 | * (F_HOST_XFER_ACT bit) for data transfer done. |
| 4939 | * |
| 4940 | *---------------------------------------------------------------------*/ |
| 4941 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4942 | static void FPT_dataXferProcessor(unsigned long port, |
| 4943 | struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4944 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4945 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4946 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4947 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4948 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4949 | if (currSCCB->Sccb_XferState & F_SG_XFER) { |
| 4950 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
| 4951 | { |
| 4952 | currSCCB->Sccb_sgseg += (unsigned char)SG_BUF_CNT; |
| 4953 | currSCCB->Sccb_SGoffset = 0x00; |
| 4954 | } |
| 4955 | pCurrCard->globalFlags |= F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4956 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4957 | FPT_busMstrSGDataXferStart(port, currSCCB); |
| 4958 | } |
| 4959 | |
| 4960 | else { |
| 4961 | if (!(pCurrCard->globalFlags & F_HOST_XFER_ACT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4962 | pCurrCard->globalFlags |= F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4963 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4964 | FPT_busMstrDataXferStart(port, currSCCB); |
| 4965 | } |
| 4966 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4967 | } |
| 4968 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4969 | /*--------------------------------------------------------------------- |
| 4970 | * |
| 4971 | * Function: BusMaster Scatter Gather Data Transfer Start |
| 4972 | * |
| 4973 | * Description: |
| 4974 | * |
| 4975 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4976 | static void FPT_busMstrSGDataXferStart(unsigned long p_port, |
| 4977 | struct sccb *pcurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4978 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4979 | unsigned long count, addr, tmpSGCnt; |
| 4980 | unsigned int sg_index; |
| 4981 | unsigned char sg_count, i; |
| 4982 | unsigned long reg_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4983 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4984 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4985 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4986 | count = ((unsigned long)HOST_RD_CMD) << 24; |
| 4987 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4988 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4989 | else { |
| 4990 | count = ((unsigned long)HOST_WRT_CMD) << 24; |
| 4991 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4992 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4993 | sg_count = 0; |
| 4994 | tmpSGCnt = 0; |
| 4995 | sg_index = pcurrSCCB->Sccb_sgseg; |
| 4996 | reg_offset = hp_aramBase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4997 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4998 | i = (unsigned char)(RD_HARPOON(p_port + hp_page_ctrl) & |
| 4999 | ~(SGRAM_ARAM | SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5000 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5001 | WR_HARPOON(p_port + hp_page_ctrl, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5002 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5003 | while ((sg_count < (unsigned char)SG_BUF_CNT) && |
| 5004 | ((unsigned long)(sg_index * (unsigned int)SG_ELEMENT_SIZE) < |
| 5005 | pcurrSCCB->DataLength)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5006 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5007 | tmpSGCnt += *(((unsigned long *)pcurrSCCB->DataPointer) + |
| 5008 | (sg_index * 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5009 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5010 | count |= *(((unsigned long *)pcurrSCCB->DataPointer) + |
| 5011 | (sg_index * 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5012 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5013 | addr = *(((unsigned long *)pcurrSCCB->DataPointer) + |
| 5014 | ((sg_index * 2) + 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5015 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5016 | if ((!sg_count) && (pcurrSCCB->Sccb_SGoffset)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5017 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5018 | addr += |
| 5019 | ((count & 0x00FFFFFFL) - pcurrSCCB->Sccb_SGoffset); |
| 5020 | count = |
| 5021 | (count & 0xFF000000L) | pcurrSCCB->Sccb_SGoffset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5022 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5023 | tmpSGCnt = count & 0x00FFFFFFL; |
| 5024 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5025 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5026 | WR_HARP32(p_port, reg_offset, addr); |
| 5027 | reg_offset += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5028 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5029 | WR_HARP32(p_port, reg_offset, count); |
| 5030 | reg_offset += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5031 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5032 | count &= 0xFF000000L; |
| 5033 | sg_index++; |
| 5034 | sg_count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5035 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5036 | } /*End While */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5037 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5038 | pcurrSCCB->Sccb_XferCnt = tmpSGCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5039 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5040 | WR_HARPOON(p_port + hp_sg_addr, (sg_count << 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5041 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5042 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5043 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5044 | WR_HARP32(p_port, hp_xfercnt_0, tmpSGCnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5045 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5046 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5047 | (DMA_PORT | SCSI_PORT | SCSI_INBIT)); |
| 5048 | WR_HARPOON(p_port + hp_scsisig, S_DATAI_PH); |
| 5049 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5050 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5051 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5052 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5053 | if ((!(RD_HARPOON(p_port + hp_synctarg_0) & NARROW_SCSI)) && |
| 5054 | (tmpSGCnt & 0x000000001)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5055 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5056 | pcurrSCCB->Sccb_XferState |= F_ODD_BALL_CNT; |
| 5057 | tmpSGCnt--; |
| 5058 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5059 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5060 | WR_HARP32(p_port, hp_xfercnt_0, tmpSGCnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5062 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5063 | (SCSI_PORT | DMA_PORT | DMA_RD)); |
| 5064 | WR_HARPOON(p_port + hp_scsisig, S_DATAO_PH); |
| 5065 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5066 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5067 | WR_HARPOON(p_port + hp_page_ctrl, (unsigned char)(i | SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5068 | |
| 5069 | } |
| 5070 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5071 | /*--------------------------------------------------------------------- |
| 5072 | * |
| 5073 | * Function: BusMaster Data Transfer Start |
| 5074 | * |
| 5075 | * Description: |
| 5076 | * |
| 5077 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5078 | static void FPT_busMstrDataXferStart(unsigned long p_port, |
| 5079 | struct sccb *pcurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5080 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5081 | unsigned long addr, count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5082 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5083 | if (!(pcurrSCCB->Sccb_XferState & F_AUTO_SENSE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5084 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5085 | count = pcurrSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5086 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5087 | addr = |
| 5088 | (unsigned long)pcurrSCCB->DataPointer + pcurrSCCB->Sccb_ATC; |
| 5089 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5090 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5091 | else { |
| 5092 | addr = pcurrSCCB->SensePointer; |
| 5093 | count = pcurrSCCB->RequestSenseLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5094 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5095 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5096 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5097 | HP_SETUP_ADDR_CNT(p_port, addr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5098 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5099 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5100 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5101 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5102 | (DMA_PORT | SCSI_PORT | SCSI_INBIT)); |
| 5103 | WR_HARPOON(p_port + hp_scsisig, S_DATAI_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5104 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5105 | WR_HARPOON(p_port + hp_xfer_cmd, |
| 5106 | (XFER_DMA_HOST | XFER_HOST_AUTO | XFER_DMA_8BIT)); |
| 5107 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5108 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5109 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5110 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5111 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5112 | (SCSI_PORT | DMA_PORT | DMA_RD)); |
| 5113 | WR_HARPOON(p_port + hp_scsisig, S_DATAO_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5114 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5115 | WR_HARPOON(p_port + hp_xfer_cmd, |
| 5116 | (XFER_HOST_DMA | XFER_HOST_AUTO | XFER_DMA_8BIT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5117 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5118 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5119 | } |
| 5120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5121 | /*--------------------------------------------------------------------- |
| 5122 | * |
| 5123 | * Function: BusMaster Timeout Handler |
| 5124 | * |
| 5125 | * Description: This function is called after a bus master command busy time |
| 5126 | * out is detected. This routines issue halt state machine |
| 5127 | * with a software time out for command busy. If command busy |
| 5128 | * is still asserted at the end of the time out, it issues |
| 5129 | * hard abort with another software time out. It hard abort |
| 5130 | * command busy is also time out, it'll just give up. |
| 5131 | * |
| 5132 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5133 | static unsigned char FPT_busMstrTimeOut(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5134 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5135 | unsigned long timeout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5136 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5137 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5138 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5139 | WR_HARPOON(p_port + hp_sys_ctrl, HALT_MACH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5140 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5141 | while ((!(RD_HARPOON(p_port + hp_ext_status) & CMD_ABORTED)) |
| 5142 | && timeout--) { |
| 5143 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5144 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5145 | if (RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) { |
| 5146 | WR_HARPOON(p_port + hp_sys_ctrl, HARD_ABORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5147 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5148 | timeout = LONG_WAIT; |
| 5149 | while ((RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) |
| 5150 | && timeout--) { |
| 5151 | } |
| 5152 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5153 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5154 | RD_HARPOON(p_port + hp_int_status); /*Clear command complete */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5155 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5156 | if (RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5157 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5158 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5159 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5160 | else { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5161 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5162 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5163 | } |
| 5164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5165 | /*--------------------------------------------------------------------- |
| 5166 | * |
| 5167 | * Function: Host Data Transfer Abort |
| 5168 | * |
| 5169 | * Description: Abort any in progress transfer. |
| 5170 | * |
| 5171 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5172 | static void FPT_hostDataXferAbort(unsigned long port, unsigned char p_card, |
| 5173 | struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5174 | { |
| 5175 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5176 | unsigned long timeout; |
| 5177 | unsigned long remain_cnt; |
| 5178 | unsigned int sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5179 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5180 | FPT_BL_Card[p_card].globalFlags &= ~F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5181 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5182 | if (pCurrSCCB->Sccb_XferState & F_AUTO_SENSE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5183 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5184 | if (!(RD_HARPOON(port + hp_int_status) & INT_CMD_COMPL)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5185 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5186 | WR_HARPOON(port + hp_bm_ctrl, |
| 5187 | (RD_HARPOON(port + hp_bm_ctrl) | |
| 5188 | FLUSH_XFER_CNTR)); |
| 5189 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5190 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5191 | while ((RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) |
| 5192 | && timeout--) { |
| 5193 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5194 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5195 | WR_HARPOON(port + hp_bm_ctrl, |
| 5196 | (RD_HARPOON(port + hp_bm_ctrl) & |
| 5197 | ~FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5198 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5199 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5200 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5201 | if (FPT_busMstrTimeOut(port)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5202 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5203 | if (pCurrSCCB->HostStatus == 0x00) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5204 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5205 | pCurrSCCB->HostStatus = |
| 5206 | SCCB_BM_ERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5207 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5208 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5209 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5210 | if (RD_HARPOON(port + hp_int_status) & |
| 5211 | INT_EXT_STATUS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5212 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5213 | if (RD_HARPOON(port + hp_ext_status) & |
| 5214 | BAD_EXT_STATUS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5215 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5216 | if (pCurrSCCB->HostStatus == |
| 5217 | 0x00) |
| 5218 | { |
| 5219 | pCurrSCCB->HostStatus = |
| 5220 | SCCB_BM_ERR; |
| 5221 | } |
| 5222 | } |
| 5223 | } |
| 5224 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5226 | else if (pCurrSCCB->Sccb_XferCnt) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5227 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5228 | if (pCurrSCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5229 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5230 | WR_HARPOON(port + hp_page_ctrl, |
| 5231 | (RD_HARPOON(port + hp_page_ctrl) & |
| 5232 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5233 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5234 | WR_HARPOON(port + hp_sg_addr, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5235 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5236 | sg_ptr = pCurrSCCB->Sccb_sgseg + SG_BUF_CNT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5237 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5238 | if (sg_ptr > |
| 5239 | (unsigned int)(pCurrSCCB->DataLength / |
| 5240 | SG_ELEMENT_SIZE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5241 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5242 | sg_ptr = |
| 5243 | (unsigned int)(pCurrSCCB->DataLength / |
| 5244 | SG_ELEMENT_SIZE); |
| 5245 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5246 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5247 | remain_cnt = pCurrSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5248 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5249 | while (remain_cnt < 0x01000000L) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5250 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5251 | sg_ptr--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5252 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5253 | if (remain_cnt > |
| 5254 | (unsigned |
| 5255 | long)(*(((unsigned long *)pCurrSCCB-> |
| 5256 | DataPointer) + (sg_ptr * 2)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5257 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5258 | remain_cnt -= |
| 5259 | (unsigned |
| 5260 | long)(*(((unsigned long *) |
| 5261 | pCurrSCCB->DataPointer) + |
| 5262 | (sg_ptr * 2))); |
| 5263 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5264 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5265 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5266 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5267 | break; |
| 5268 | } |
| 5269 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5270 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5271 | if (remain_cnt < 0x01000000L) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5272 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5273 | pCurrSCCB->Sccb_SGoffset = remain_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5274 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5275 | pCurrSCCB->Sccb_sgseg = (unsigned short)sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5276 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5277 | if ((unsigned long)(sg_ptr * SG_ELEMENT_SIZE) == |
| 5278 | pCurrSCCB->DataLength && (remain_cnt == 0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5279 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5280 | pCurrSCCB->Sccb_XferState |= |
| 5281 | F_ALL_XFERRED; |
| 5282 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5283 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5284 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5285 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5286 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5287 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5288 | pCurrSCCB->HostStatus = |
| 5289 | SCCB_GROSS_FW_ERR; |
| 5290 | } |
| 5291 | } |
| 5292 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5293 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5294 | if (!(pCurrSCCB->Sccb_XferState & F_HOST_XFER_DIR)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5295 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5296 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5297 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5298 | FPT_busMstrTimeOut(port); |
| 5299 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5300 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5301 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5302 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5303 | if (RD_HARPOON(port + hp_int_status) & |
| 5304 | INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5305 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5306 | if (RD_HARPOON(port + hp_ext_status) & |
| 5307 | BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5308 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5309 | if (pCurrSCCB->HostStatus == |
| 5310 | 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5311 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5312 | pCurrSCCB->HostStatus = |
| 5313 | SCCB_BM_ERR; |
| 5314 | } |
| 5315 | } |
| 5316 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5317 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5318 | } |
| 5319 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5320 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5321 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5322 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5323 | if ((RD_HARPOON(port + hp_fifo_cnt)) >= BM_THRESHOLD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5324 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5325 | timeout = SHORT_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5326 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5327 | while ((RD_HARPOON(port + hp_ext_status) & |
| 5328 | BM_CMD_BUSY) |
| 5329 | && ((RD_HARPOON(port + hp_fifo_cnt)) >= |
| 5330 | BM_THRESHOLD) && timeout--) { |
| 5331 | } |
| 5332 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5333 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5334 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5336 | WR_HARPOON(port + hp_bm_ctrl, |
| 5337 | (RD_HARPOON(port + hp_bm_ctrl) | |
| 5338 | FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5339 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5340 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5341 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5342 | while ((RD_HARPOON(port + hp_ext_status) & |
| 5343 | BM_CMD_BUSY) && timeout--) { |
| 5344 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5345 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5346 | WR_HARPOON(port + hp_bm_ctrl, |
| 5347 | (RD_HARPOON(port + hp_bm_ctrl) & |
| 5348 | ~FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5349 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5350 | if (RD_HARPOON(port + hp_ext_status) & |
| 5351 | BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5352 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5353 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5354 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5355 | pCurrSCCB->HostStatus = |
| 5356 | SCCB_BM_ERR; |
| 5357 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5358 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5359 | FPT_busMstrTimeOut(port); |
| 5360 | } |
| 5361 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5362 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5363 | if (RD_HARPOON(port + hp_int_status) & INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5364 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5365 | if (RD_HARPOON(port + hp_ext_status) & |
| 5366 | BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5367 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5368 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5369 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5370 | pCurrSCCB->HostStatus = |
| 5371 | SCCB_BM_ERR; |
| 5372 | } |
| 5373 | } |
| 5374 | } |
| 5375 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5376 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5377 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5379 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5381 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5382 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5383 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5384 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5385 | while ((RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) |
| 5386 | && timeout--) { |
| 5387 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5388 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5389 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5390 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5391 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5392 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5393 | pCurrSCCB->HostStatus = SCCB_BM_ERR; |
| 5394 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5395 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5396 | FPT_busMstrTimeOut(port); |
| 5397 | } |
| 5398 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5399 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5400 | if (RD_HARPOON(port + hp_int_status) & INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5401 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5402 | if (RD_HARPOON(port + hp_ext_status) & BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5403 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5404 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5405 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5406 | pCurrSCCB->HostStatus = SCCB_BM_ERR; |
| 5407 | } |
| 5408 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5409 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5410 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5412 | if (pCurrSCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5413 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5414 | WR_HARPOON(port + hp_page_ctrl, |
| 5415 | (RD_HARPOON(port + hp_page_ctrl) & |
| 5416 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5417 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5418 | WR_HARPOON(port + hp_sg_addr, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5420 | pCurrSCCB->Sccb_sgseg += SG_BUF_CNT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5421 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5422 | pCurrSCCB->Sccb_SGoffset = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5423 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5424 | if ((unsigned long)(pCurrSCCB->Sccb_sgseg * |
| 5425 | SG_ELEMENT_SIZE) >= |
| 5426 | pCurrSCCB->DataLength) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5427 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5428 | pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5430 | pCurrSCCB->Sccb_sgseg = |
| 5431 | (unsigned short)(pCurrSCCB->DataLength / |
| 5432 | SG_ELEMENT_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5433 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5434 | } |
| 5435 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5437 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5439 | if (!(pCurrSCCB->Sccb_XferState & F_AUTO_SENSE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5440 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5441 | pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED; |
| 5442 | } |
| 5443 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5444 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5445 | WR_HARPOON(port + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5446 | } |
| 5447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5448 | /*--------------------------------------------------------------------- |
| 5449 | * |
| 5450 | * Function: Host Data Transfer Restart |
| 5451 | * |
| 5452 | * Description: Reset the available count due to a restore data |
| 5453 | * pointers message. |
| 5454 | * |
| 5455 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5456 | static void FPT_hostDataXferRestart(struct sccb *currSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5457 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5458 | unsigned long data_count; |
| 5459 | unsigned int sg_index; |
| 5460 | unsigned long *sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5461 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5462 | if (currSCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5464 | currSCCB->Sccb_XferCnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5466 | sg_index = 0xffff; /*Index by long words into sg list. */ |
| 5467 | data_count = 0; /*Running count of SG xfer counts. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5468 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5469 | sg_ptr = (unsigned long *)currSCCB->DataPointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5470 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5471 | while (data_count < currSCCB->Sccb_ATC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5472 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5473 | sg_index++; |
| 5474 | data_count += *(sg_ptr + (sg_index * 2)); |
| 5475 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5476 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5477 | if (data_count == currSCCB->Sccb_ATC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5478 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5479 | currSCCB->Sccb_SGoffset = 0; |
| 5480 | sg_index++; |
| 5481 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5482 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5483 | else { |
| 5484 | currSCCB->Sccb_SGoffset = |
| 5485 | data_count - currSCCB->Sccb_ATC; |
| 5486 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5487 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5488 | currSCCB->Sccb_sgseg = (unsigned short)sg_index; |
| 5489 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5490 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5491 | else { |
| 5492 | currSCCB->Sccb_XferCnt = |
| 5493 | currSCCB->DataLength - currSCCB->Sccb_ATC; |
| 5494 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5495 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5496 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5497 | /*--------------------------------------------------------------------- |
| 5498 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5499 | * Function: FPT_scini |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5500 | * |
| 5501 | * Description: Setup all data structures necessary for SCAM selection. |
| 5502 | * |
| 5503 | *---------------------------------------------------------------------*/ |
| 5504 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5505 | static void FPT_scini(unsigned char p_card, unsigned char p_our_id, |
| 5506 | unsigned char p_power_up) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5507 | { |
| 5508 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5509 | unsigned char loser, assigned_id; |
| 5510 | unsigned long p_port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5511 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5512 | unsigned char i, k, ScamFlg; |
| 5513 | struct sccb_card *currCard; |
| 5514 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5515 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5516 | currCard = &FPT_BL_Card[p_card]; |
| 5517 | p_port = currCard->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5518 | pCurrNvRam = currCard->pNvRamInfo; |
| 5519 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5520 | if (pCurrNvRam) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5521 | ScamFlg = pCurrNvRam->niScamConf; |
| 5522 | i = pCurrNvRam->niSysConf; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5523 | } else { |
| 5524 | ScamFlg = |
| 5525 | (unsigned char)FPT_utilEERead(p_port, SCAM_CONFIG / 2); |
| 5526 | i = (unsigned |
| 5527 | char)(FPT_utilEERead(p_port, (SYSTEM_CONFIG / 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5528 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5529 | if (!(i & 0x02)) /* check if reset bus in AutoSCSI parameter set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5530 | return; |
| 5531 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5532 | FPT_inisci(p_card, p_port, p_our_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5533 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5534 | /* Force to wait 1 sec after SCSI bus reset. Some SCAM device FW |
| 5535 | too slow to return to SCAM selection */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5537 | /* if (p_power_up) |
| 5538 | FPT_Wait1Second(p_port); |
| 5539 | else |
| 5540 | FPT_Wait(p_port, TO_250ms); */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5541 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5542 | FPT_Wait1Second(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5543 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5544 | if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2)) { |
| 5545 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5546 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5547 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5548 | FPT_scsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5549 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5550 | do { |
| 5551 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5552 | FPT_scxferc(p_port, DOM_MSTR); |
| 5553 | loser = |
| 5554 | FPT_scsendi(p_port, |
| 5555 | &FPT_scamInfo[p_our_id].id_string[0]); |
| 5556 | } while (loser == 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5557 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5558 | FPT_scbusf(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5559 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5560 | if ((p_power_up) && (!loser)) { |
| 5561 | FPT_sresb(p_port, p_card); |
| 5562 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5563 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5564 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5565 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5566 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5567 | FPT_scsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5568 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5569 | do { |
| 5570 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5571 | FPT_scxferc(p_port, DOM_MSTR); |
| 5572 | loser = |
| 5573 | FPT_scsendi(p_port, |
| 5574 | &FPT_scamInfo[p_our_id]. |
| 5575 | id_string[0]); |
| 5576 | } while (loser == 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5577 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5578 | FPT_scbusf(p_port); |
| 5579 | } |
| 5580 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5581 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5582 | else { |
| 5583 | loser = 0; |
| 5584 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5585 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5586 | if (!loser) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5587 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5588 | FPT_scamInfo[p_our_id].state = ID_ASSIGNED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5589 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5590 | if (ScamFlg & SCAM_ENABLED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5591 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5592 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 5593 | if ((FPT_scamInfo[i].state == ID_UNASSIGNED) || |
| 5594 | (FPT_scamInfo[i].state == ID_UNUSED)) { |
| 5595 | if (FPT_scsell(p_port, i)) { |
| 5596 | FPT_scamInfo[i].state = LEGACY; |
| 5597 | if ((FPT_scamInfo[i]. |
| 5598 | id_string[0] != 0xFF) |
| 5599 | || (FPT_scamInfo[i]. |
| 5600 | id_string[1] != 0xFA)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5601 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5602 | FPT_scamInfo[i]. |
| 5603 | id_string[0] = 0xFF; |
| 5604 | FPT_scamInfo[i]. |
| 5605 | id_string[1] = 0xFA; |
| 5606 | if (pCurrNvRam == NULL) |
| 5607 | currCard-> |
| 5608 | globalFlags |
| 5609 | |= |
| 5610 | F_UPDATE_EEPROM; |
| 5611 | } |
| 5612 | } |
| 5613 | } |
| 5614 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5615 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5616 | FPT_sresb(p_port, p_card); |
| 5617 | FPT_Wait1Second(p_port); |
| 5618 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5619 | } |
| 5620 | FPT_scsel(p_port); |
| 5621 | FPT_scasid(p_card, p_port); |
| 5622 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5623 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5624 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5625 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5626 | else if ((loser) && (ScamFlg & SCAM_ENABLED)) { |
| 5627 | FPT_scamInfo[p_our_id].id_string[0] = SLV_TYPE_CODE0; |
| 5628 | assigned_id = 0; |
| 5629 | FPT_scwtsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5630 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5631 | do { |
| 5632 | while (FPT_scxferc(p_port, 0x00) != SYNC_PTRN) { |
| 5633 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5634 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5635 | i = FPT_scxferc(p_port, 0x00); |
| 5636 | if (i == ASSIGN_ID) { |
| 5637 | if (! |
| 5638 | (FPT_scsendi |
| 5639 | (p_port, |
| 5640 | &FPT_scamInfo[p_our_id].id_string[0]))) { |
| 5641 | i = FPT_scxferc(p_port, 0x00); |
| 5642 | if (FPT_scvalq(i)) { |
| 5643 | k = FPT_scxferc(p_port, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5644 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5645 | if (FPT_scvalq(k)) { |
| 5646 | currCard->ourId = |
| 5647 | ((unsigned char)(i |
| 5648 | << |
| 5649 | 3) |
| 5650 | + |
| 5651 | (k & |
| 5652 | (unsigned char)7)) |
| 5653 | & (unsigned char) |
| 5654 | 0x3F; |
| 5655 | FPT_inisci(p_card, |
| 5656 | p_port, |
| 5657 | p_our_id); |
| 5658 | FPT_scamInfo[currCard-> |
| 5659 | ourId]. |
| 5660 | state = ID_ASSIGNED; |
| 5661 | FPT_scamInfo[currCard-> |
| 5662 | ourId]. |
| 5663 | id_string[0] |
| 5664 | = SLV_TYPE_CODE0; |
| 5665 | assigned_id = 1; |
| 5666 | } |
| 5667 | } |
| 5668 | } |
| 5669 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5670 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5671 | else if (i == SET_P_FLAG) { |
| 5672 | if (!(FPT_scsendi(p_port, |
| 5673 | &FPT_scamInfo[p_our_id]. |
| 5674 | id_string[0]))) |
| 5675 | FPT_scamInfo[p_our_id].id_string[0] |= |
| 5676 | 0x80; |
| 5677 | } |
| 5678 | } while (!assigned_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5679 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5680 | while (FPT_scxferc(p_port, 0x00) != CFG_CMPLT) { |
| 5681 | } |
| 5682 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5683 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5684 | if (ScamFlg & SCAM_ENABLED) { |
| 5685 | FPT_scbusf(p_port); |
| 5686 | if (currCard->globalFlags & F_UPDATE_EEPROM) { |
| 5687 | FPT_scsavdi(p_card, p_port); |
| 5688 | currCard->globalFlags &= ~F_UPDATE_EEPROM; |
| 5689 | } |
| 5690 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5691 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5692 | /* |
| 5693 | for (i=0,k=0; i < MAX_SCSI_TAR; i++) |
| 5694 | { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5695 | if ((FPT_scamInfo[i].state == ID_ASSIGNED) || |
| 5696 | (FPT_scamInfo[i].state == LEGACY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5697 | k++; |
| 5698 | } |
| 5699 | |
| 5700 | if (k==2) |
| 5701 | currCard->globalFlags |= F_SINGLE_DEVICE; |
| 5702 | else |
| 5703 | currCard->globalFlags &= ~F_SINGLE_DEVICE; |
| 5704 | */ |
| 5705 | } |
| 5706 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5707 | /*--------------------------------------------------------------------- |
| 5708 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5709 | * Function: FPT_scarb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5710 | * |
| 5711 | * Description: Gain control of the bus and wait SCAM select time (250ms) |
| 5712 | * |
| 5713 | *---------------------------------------------------------------------*/ |
| 5714 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5715 | static int FPT_scarb(unsigned long p_port, unsigned char p_sel_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5716 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5717 | if (p_sel_type == INIT_SELTD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5718 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5719 | while (RD_HARPOON(p_port + hp_scsisig) & (SCSI_SEL | SCSI_BSY)) { |
| 5720 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5721 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5722 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_SEL) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5723 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5724 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5725 | if (RD_HARPOON(p_port + hp_scsidata_0) != 00) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5726 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5727 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5728 | WR_HARPOON(p_port + hp_scsisig, |
| 5729 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5730 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5731 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_SEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5732 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5733 | WR_HARPOON(p_port + hp_scsisig, |
| 5734 | (RD_HARPOON(p_port + hp_scsisig) & |
| 5735 | ~SCSI_BSY)); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5736 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5737 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5738 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5739 | WR_HARPOON(p_port + hp_scsisig, |
| 5740 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5741 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5742 | if (RD_HARPOON(p_port + hp_scsidata_0) != 00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5743 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5744 | WR_HARPOON(p_port + hp_scsisig, |
| 5745 | (RD_HARPOON(p_port + hp_scsisig) & |
| 5746 | ~(SCSI_BSY | SCSI_SEL))); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5747 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5748 | } |
| 5749 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5750 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5751 | WR_HARPOON(p_port + hp_clkctrl_0, (RD_HARPOON(p_port + hp_clkctrl_0) |
| 5752 | & ~ACTdeassert)); |
| 5753 | WR_HARPOON(p_port + hp_scsireset, SCAM_EN); |
| 5754 | WR_HARPOON(p_port + hp_scsidata_0, 0x00); |
| 5755 | WR_HARPOON(p_port + hp_scsidata_1, 0x00); |
| 5756 | WR_HARPOON(p_port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5757 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5758 | WR_HARPOON(p_port + hp_scsisig, |
| 5759 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_MSG)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5760 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5761 | WR_HARPOON(p_port + hp_scsisig, (RD_HARPOON(p_port + hp_scsisig) |
| 5762 | & ~SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5763 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5764 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5765 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5766 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5767 | } |
| 5768 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5769 | /*--------------------------------------------------------------------- |
| 5770 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5771 | * Function: FPT_scbusf |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5772 | * |
| 5773 | * Description: Release the SCSI bus and disable SCAM selection. |
| 5774 | * |
| 5775 | *---------------------------------------------------------------------*/ |
| 5776 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5777 | static void FPT_scbusf(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5778 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5779 | WR_HARPOON(p_port + hp_page_ctrl, |
| 5780 | (RD_HARPOON(p_port + hp_page_ctrl) | G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5781 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5782 | WR_HARPOON(p_port + hp_scsidata_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5783 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5784 | WR_HARPOON(p_port + hp_portctrl_0, (RD_HARPOON(p_port + hp_portctrl_0) |
| 5785 | & ~SCSI_BUS_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5786 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5787 | WR_HARPOON(p_port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5788 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5789 | WR_HARPOON(p_port + hp_scsireset, (RD_HARPOON(p_port + hp_scsireset) |
| 5790 | & ~SCAM_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5791 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5792 | WR_HARPOON(p_port + hp_clkctrl_0, (RD_HARPOON(p_port + hp_clkctrl_0) |
| 5793 | | ACTdeassert)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5794 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5795 | WRW_HARPOON((p_port + hp_intstat), (BUS_FREE | AUTO_INT | SCAM_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5796 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5797 | WR_HARPOON(p_port + hp_page_ctrl, |
| 5798 | (RD_HARPOON(p_port + hp_page_ctrl) & ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5799 | } |
| 5800 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5801 | /*--------------------------------------------------------------------- |
| 5802 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5803 | * Function: FPT_scasid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5804 | * |
| 5805 | * Description: Assign an ID to all the SCAM devices. |
| 5806 | * |
| 5807 | *---------------------------------------------------------------------*/ |
| 5808 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5809 | static void FPT_scasid(unsigned char p_card, unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5810 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5811 | unsigned char temp_id_string[ID_STRING_LENGTH]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5812 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5813 | unsigned char i, k, scam_id; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 5814 | unsigned char crcBytes[3]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5815 | struct nvram_info *pCurrNvRam; |
| 5816 | unsigned short *pCrcBytes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5817 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5818 | pCurrNvRam = FPT_BL_Card[p_card].pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5819 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5820 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5821 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5822 | while (!i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5823 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5824 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 5825 | temp_id_string[k] = (unsigned char)0x00; |
| 5826 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5827 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5828 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5829 | FPT_scxferc(p_port, ASSIGN_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5830 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5831 | if (!(FPT_sciso(p_port, &temp_id_string[0]))) { |
| 5832 | if (pCurrNvRam) { |
Alexey Dobriyan | fd1e29e | 2006-03-08 00:14:27 -0800 | [diff] [blame] | 5833 | pCrcBytes = (unsigned short *)&crcBytes[0]; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5834 | *pCrcBytes = FPT_CalcCrc16(&temp_id_string[0]); |
| 5835 | crcBytes[2] = FPT_CalcLrc(&temp_id_string[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5836 | temp_id_string[1] = crcBytes[2]; |
| 5837 | temp_id_string[2] = crcBytes[0]; |
| 5838 | temp_id_string[3] = crcBytes[1]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5839 | for (k = 4; k < ID_STRING_LENGTH; k++) |
| 5840 | temp_id_string[k] = (unsigned char)0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5841 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5842 | i = FPT_scmachid(p_card, temp_id_string); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5843 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5844 | if (i == CLR_PRIORITY) { |
| 5845 | FPT_scxferc(p_port, MISC_CODE); |
| 5846 | FPT_scxferc(p_port, CLR_P_FLAG); |
| 5847 | i = 0; /*Not the last ID yet. */ |
| 5848 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5849 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5850 | else if (i != NO_ID_AVAIL) { |
| 5851 | if (i < 8) |
| 5852 | FPT_scxferc(p_port, ID_0_7); |
| 5853 | else |
| 5854 | FPT_scxferc(p_port, ID_8_F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5855 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5856 | scam_id = (i & (unsigned char)0x07); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5857 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5858 | for (k = 1; k < 0x08; k <<= 1) |
| 5859 | if (!(k & i)) |
| 5860 | scam_id += 0x08; /*Count number of zeros in DB0-3. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5861 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5862 | FPT_scxferc(p_port, scam_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5863 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5864 | i = 0; /*Not the last ID yet. */ |
| 5865 | } |
| 5866 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5867 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5868 | else { |
| 5869 | i = 1; |
| 5870 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5871 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5872 | } /*End while */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5873 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5874 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5875 | FPT_scxferc(p_port, CFG_CMPLT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5876 | } |
| 5877 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5878 | /*--------------------------------------------------------------------- |
| 5879 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5880 | * Function: FPT_scsel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5881 | * |
| 5882 | * Description: Select all the SCAM devices. |
| 5883 | * |
| 5884 | *---------------------------------------------------------------------*/ |
| 5885 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5886 | static void FPT_scsel(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5887 | { |
| 5888 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5889 | WR_HARPOON(p_port + hp_scsisig, SCSI_SEL); |
| 5890 | FPT_scwiros(p_port, SCSI_MSG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5891 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5892 | WR_HARPOON(p_port + hp_scsisig, (SCSI_SEL | SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5893 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5894 | WR_HARPOON(p_port + hp_scsisig, |
| 5895 | (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
| 5896 | WR_HARPOON(p_port + hp_scsidata_0, |
| 5897 | (unsigned char)(RD_HARPOON(p_port + hp_scsidata_0) | |
| 5898 | (unsigned char)(BIT(7) + BIT(6)))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5899 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5900 | WR_HARPOON(p_port + hp_scsisig, (SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
| 5901 | FPT_scwiros(p_port, SCSI_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5902 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5903 | WR_HARPOON(p_port + hp_scsidata_0, |
| 5904 | (unsigned char)(RD_HARPOON(p_port + hp_scsidata_0) & |
| 5905 | ~(unsigned char)BIT(6))); |
| 5906 | FPT_scwirod(p_port, BIT(6)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5907 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5908 | WR_HARPOON(p_port + hp_scsisig, |
| 5909 | (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5910 | } |
| 5911 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5912 | /*--------------------------------------------------------------------- |
| 5913 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5914 | * Function: FPT_scxferc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5915 | * |
| 5916 | * Description: Handshake the p_data (DB4-0) across the bus. |
| 5917 | * |
| 5918 | *---------------------------------------------------------------------*/ |
| 5919 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5920 | static unsigned char FPT_scxferc(unsigned long p_port, unsigned char p_data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5921 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5922 | unsigned char curr_data, ret_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5923 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5924 | curr_data = p_data | BIT(7) | BIT(5); /*Start with DB7 & DB5 asserted. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5925 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5926 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5927 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5928 | curr_data &= ~BIT(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5929 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5930 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5931 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5932 | FPT_scwirod(p_port, BIT(7)); /*Wait for DB7 to be released. */ |
| 5933 | while (!(RD_HARPOON(p_port + hp_scsidata_0) & BIT(5))) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5934 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5935 | ret_data = (RD_HARPOON(p_port + hp_scsidata_0) & (unsigned char)0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5936 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5937 | curr_data |= BIT(6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5938 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5939 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5940 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5941 | curr_data &= ~BIT(5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5942 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5943 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5944 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5945 | FPT_scwirod(p_port, BIT(5)); /*Wait for DB5 to be released. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5946 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5947 | curr_data &= ~(BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0)); /*Release data bits */ |
| 5948 | curr_data |= BIT(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5949 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5950 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5951 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5952 | curr_data &= ~BIT(6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5953 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5954 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5955 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5956 | FPT_scwirod(p_port, BIT(6)); /*Wait for DB6 to be released. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5957 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5958 | return ret_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5959 | } |
| 5960 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5961 | /*--------------------------------------------------------------------- |
| 5962 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5963 | * Function: FPT_scsendi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5964 | * |
| 5965 | * Description: Transfer our Identification string to determine if we |
| 5966 | * will be the dominant master. |
| 5967 | * |
| 5968 | *---------------------------------------------------------------------*/ |
| 5969 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5970 | static unsigned char FPT_scsendi(unsigned long p_port, |
| 5971 | unsigned char p_id_string[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5972 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5973 | unsigned char ret_data, byte_cnt, bit_cnt, defer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5974 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5975 | defer = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5976 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5977 | for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5978 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5979 | for (bit_cnt = 0x80; bit_cnt != 0; bit_cnt >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5980 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5981 | if (defer) |
| 5982 | ret_data = FPT_scxferc(p_port, 00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5983 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5984 | else if (p_id_string[byte_cnt] & bit_cnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5985 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5986 | ret_data = FPT_scxferc(p_port, 02); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5987 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5988 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5989 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5990 | ret_data = FPT_scxferc(p_port, 01); |
| 5991 | if (ret_data & 02) |
| 5992 | defer = 1; |
| 5993 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5994 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5995 | if ((ret_data & 0x1C) == 0x10) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5996 | return 0x00; /*End of isolation stage, we won! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5997 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5998 | if (ret_data & 0x1C) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5999 | return 0xFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6000 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6001 | if ((defer) && (!(ret_data & 0x1F))) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6002 | return 0x01; /*End of isolation stage, we lost. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6003 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6004 | } /*bit loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6005 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6006 | } /*byte loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6007 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6008 | if (defer) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6009 | return 0x01; /*We lost */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6010 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6011 | return 0; /*We WON! Yeeessss! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6012 | } |
| 6013 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6014 | /*--------------------------------------------------------------------- |
| 6015 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6016 | * Function: FPT_sciso |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6017 | * |
| 6018 | * Description: Transfer the Identification string. |
| 6019 | * |
| 6020 | *---------------------------------------------------------------------*/ |
| 6021 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6022 | static unsigned char FPT_sciso(unsigned long p_port, |
| 6023 | unsigned char p_id_string[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6024 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6025 | unsigned char ret_data, the_data, byte_cnt, bit_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6026 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6027 | the_data = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6028 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6029 | for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6030 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6031 | for (bit_cnt = 0; bit_cnt < 8; bit_cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6033 | ret_data = FPT_scxferc(p_port, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6034 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6035 | if (ret_data & 0xFC) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6036 | return 0xFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6037 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6038 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6039 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6040 | the_data <<= 1; |
| 6041 | if (ret_data & BIT(1)) { |
| 6042 | the_data |= 1; |
| 6043 | } |
| 6044 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6045 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6046 | if ((ret_data & 0x1F) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6047 | /* |
| 6048 | if(bit_cnt != 0 || bit_cnt != 8) |
| 6049 | { |
| 6050 | byte_cnt = 0; |
| 6051 | bit_cnt = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6052 | FPT_scxferc(p_port, SYNC_PTRN); |
| 6053 | FPT_scxferc(p_port, ASSIGN_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6054 | continue; |
| 6055 | } |
| 6056 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6057 | if (byte_cnt) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6058 | return 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6059 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6060 | return 0xFF; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6061 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6062 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6063 | } /*bit loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6064 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6065 | p_id_string[byte_cnt] = the_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6066 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6067 | } /*byte loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6068 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6069 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6070 | } |
| 6071 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6072 | /*--------------------------------------------------------------------- |
| 6073 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6074 | * Function: FPT_scwirod |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6075 | * |
| 6076 | * Description: Sample the SCSI data bus making sure the signal has been |
| 6077 | * deasserted for the correct number of consecutive samples. |
| 6078 | * |
| 6079 | *---------------------------------------------------------------------*/ |
| 6080 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6081 | static void FPT_scwirod(unsigned long p_port, unsigned char p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6082 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6083 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6084 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6085 | i = 0; |
| 6086 | while (i < MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6087 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6088 | if (RD_HARPOON(p_port + hp_scsidata_0) & p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6089 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6090 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6091 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6092 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6093 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6094 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6095 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6096 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6097 | } |
| 6098 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6099 | /*--------------------------------------------------------------------- |
| 6100 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6101 | * Function: FPT_scwiros |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6102 | * |
| 6103 | * Description: Sample the SCSI Signal lines making sure the signal has been |
| 6104 | * deasserted for the correct number of consecutive samples. |
| 6105 | * |
| 6106 | *---------------------------------------------------------------------*/ |
| 6107 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6108 | static void FPT_scwiros(unsigned long p_port, unsigned char p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6109 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6110 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6111 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6112 | i = 0; |
| 6113 | while (i < MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6114 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6115 | if (RD_HARPOON(p_port + hp_scsisig) & p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6116 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6117 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6118 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6119 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6120 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6121 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6122 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6123 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6124 | } |
| 6125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6126 | /*--------------------------------------------------------------------- |
| 6127 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6128 | * Function: FPT_scvalq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6129 | * |
| 6130 | * Description: Make sure we received a valid data byte. |
| 6131 | * |
| 6132 | *---------------------------------------------------------------------*/ |
| 6133 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 6134 | static unsigned char FPT_scvalq(unsigned char p_quintet) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6135 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6136 | unsigned char count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6137 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6138 | for (count = 1; count < 0x08; count <<= 1) { |
| 6139 | if (!(p_quintet & count)) |
| 6140 | p_quintet -= 0x80; |
| 6141 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6142 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6143 | if (p_quintet & 0x18) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6144 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6145 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6146 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6147 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6148 | } |
| 6149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6150 | /*--------------------------------------------------------------------- |
| 6151 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6152 | * Function: FPT_scsell |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6153 | * |
| 6154 | * Description: Select the specified device ID using a selection timeout |
| 6155 | * less than 4ms. If somebody responds then it is a legacy |
| 6156 | * drive and this ID must be marked as such. |
| 6157 | * |
| 6158 | *---------------------------------------------------------------------*/ |
| 6159 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6160 | static unsigned char FPT_scsell(unsigned long p_port, unsigned char targ_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6161 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6162 | unsigned long i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6163 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6164 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6165 | (RD_HARPOON(p_port + hp_page_ctrl) | G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6166 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6167 | ARAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6168 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6169 | WR_HARPOON(p_port + hp_addstat, |
| 6170 | (RD_HARPOON(p_port + hp_addstat) | SCAM_TIMER)); |
| 6171 | WR_HARPOON(p_port + hp_seltimeout, TO_4ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6172 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6173 | for (i = p_port + CMD_STRT; i < p_port + CMD_STRT + 12; i += 2) { |
| 6174 | WRW_HARPOON(i, (MPM_OP + ACOMMAND)); |
| 6175 | } |
| 6176 | WRW_HARPOON(i, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6177 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6178 | WRW_HARPOON((p_port + hp_intstat), |
| 6179 | (RESET | TIMEOUT | SEL | BUS_FREE | AUTO_INT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6180 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6181 | WR_HARPOON(p_port + hp_select_id, targ_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6182 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6183 | WR_HARPOON(p_port + hp_portctrl_0, SCSI_PORT); |
| 6184 | WR_HARPOON(p_port + hp_autostart_3, (SELECT | CMD_ONLY_STRT)); |
| 6185 | WR_HARPOON(p_port + hp_scsictrl_0, (SEL_TAR | ENA_RESEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6186 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6187 | while (!(RDW_HARPOON((p_port + hp_intstat)) & |
| 6188 | (RESET | PROG_HLT | TIMEOUT | AUTO_INT))) { |
| 6189 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6190 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6191 | if (RDW_HARPOON((p_port + hp_intstat)) & RESET) |
| 6192 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6193 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6194 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6195 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6196 | WR_HARPOON(p_port + hp_addstat, |
| 6197 | (RD_HARPOON(p_port + hp_addstat) & ~SCAM_TIMER)); |
| 6198 | WR_HARPOON(p_port + hp_seltimeout, TO_290ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6199 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6200 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6201 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6202 | if (RDW_HARPOON((p_port + hp_intstat)) & (RESET | TIMEOUT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6203 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6204 | WRW_HARPOON((p_port + hp_intstat), |
| 6205 | (RESET | TIMEOUT | SEL | BUS_FREE | PHASE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6206 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6207 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6208 | (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6209 | ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6210 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6211 | return 0; /*No legacy device */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6212 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6213 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6214 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6215 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6216 | while (!(RDW_HARPOON((p_port + hp_intstat)) & BUS_FREE)) { |
| 6217 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_REQ) { |
| 6218 | WR_HARPOON(p_port + hp_scsisig, |
| 6219 | (SCSI_ACK + S_ILL_PH)); |
| 6220 | ACCEPT_MSG(p_port); |
| 6221 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6222 | } |
| 6223 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6224 | WRW_HARPOON((p_port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6226 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6227 | (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6228 | ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6229 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6230 | return 1; /*Found one of them oldies! */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6231 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6232 | } |
| 6233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6234 | /*--------------------------------------------------------------------- |
| 6235 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6236 | * Function: FPT_scwtsel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6237 | * |
| 6238 | * Description: Wait to be selected by another SCAM initiator. |
| 6239 | * |
| 6240 | *---------------------------------------------------------------------*/ |
| 6241 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6242 | static void FPT_scwtsel(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6243 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6244 | while (!(RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) { |
| 6245 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6246 | } |
| 6247 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6248 | /*--------------------------------------------------------------------- |
| 6249 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6250 | * Function: FPT_inisci |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6251 | * |
| 6252 | * Description: Setup the data Structure with the info from the EEPROM. |
| 6253 | * |
| 6254 | *---------------------------------------------------------------------*/ |
| 6255 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6256 | static void FPT_inisci(unsigned char p_card, unsigned long p_port, |
| 6257 | unsigned char p_our_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6258 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6259 | unsigned char i, k, max_id; |
| 6260 | unsigned short ee_data; |
| 6261 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6262 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6263 | pCurrNvRam = FPT_BL_Card[p_card].pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6264 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6265 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6266 | max_id = 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6267 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6268 | else |
| 6269 | max_id = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6270 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6271 | if (pCurrNvRam) { |
| 6272 | for (i = 0; i < max_id; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6274 | for (k = 0; k < 4; k++) |
| 6275 | FPT_scamInfo[i].id_string[k] = |
| 6276 | pCurrNvRam->niScamTbl[i][k]; |
| 6277 | for (k = 4; k < ID_STRING_LENGTH; k++) |
| 6278 | FPT_scamInfo[i].id_string[k] = |
| 6279 | (unsigned char)0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6280 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6281 | if (FPT_scamInfo[i].id_string[0] == 0x00) |
| 6282 | FPT_scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */ |
| 6283 | else |
| 6284 | FPT_scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6285 | |
| 6286 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6287 | } else { |
| 6288 | for (i = 0; i < max_id; i++) { |
| 6289 | for (k = 0; k < ID_STRING_LENGTH; k += 2) { |
| 6290 | ee_data = |
| 6291 | FPT_utilEERead(p_port, |
| 6292 | (unsigned |
| 6293 | short)((EE_SCAMBASE / 2) + |
| 6294 | (unsigned short)(i * |
| 6295 | ((unsigned short)ID_STRING_LENGTH / 2)) + (unsigned short)(k / 2))); |
| 6296 | FPT_scamInfo[i].id_string[k] = |
| 6297 | (unsigned char)ee_data; |
| 6298 | ee_data >>= 8; |
| 6299 | FPT_scamInfo[i].id_string[k + 1] = |
| 6300 | (unsigned char)ee_data; |
| 6301 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6302 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6303 | if ((FPT_scamInfo[i].id_string[0] == 0x00) || |
| 6304 | (FPT_scamInfo[i].id_string[0] == 0xFF)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6305 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6306 | FPT_scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6308 | else |
| 6309 | FPT_scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6310 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6311 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6312 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6313 | for (k = 0; k < ID_STRING_LENGTH; k++) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6314 | FPT_scamInfo[p_our_id].id_string[k] = FPT_scamHAString[k]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6315 | |
| 6316 | } |
| 6317 | |
| 6318 | /*--------------------------------------------------------------------- |
| 6319 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6320 | * Function: FPT_scmachid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6321 | * |
| 6322 | * Description: Match the Device ID string with our values stored in |
| 6323 | * the EEPROM. |
| 6324 | * |
| 6325 | *---------------------------------------------------------------------*/ |
| 6326 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6327 | static unsigned char FPT_scmachid(unsigned char p_card, |
| 6328 | unsigned char p_id_string[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6329 | { |
| 6330 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6331 | unsigned char i, k, match; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6332 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6333 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6334 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6335 | match = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6336 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6337 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6338 | if (p_id_string[k] != FPT_scamInfo[i].id_string[k]) |
| 6339 | match = 0; |
| 6340 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6341 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6342 | if (match) { |
| 6343 | FPT_scamInfo[i].state = ID_ASSIGNED; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6344 | return i; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6345 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6347 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6348 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6349 | if (p_id_string[0] & BIT(5)) |
| 6350 | i = 8; |
| 6351 | else |
| 6352 | i = MAX_SCSI_TAR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6353 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6354 | if (((p_id_string[0] & 0x06) == 0x02) |
| 6355 | || ((p_id_string[0] & 0x06) == 0x04)) |
| 6356 | match = p_id_string[1] & (unsigned char)0x1F; |
| 6357 | else |
| 6358 | match = 7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6359 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6360 | while (i > 0) { |
| 6361 | i--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6362 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6363 | if (FPT_scamInfo[match].state == ID_UNUSED) { |
| 6364 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6365 | FPT_scamInfo[match].id_string[k] = |
| 6366 | p_id_string[k]; |
| 6367 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6368 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6369 | FPT_scamInfo[match].state = ID_ASSIGNED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6370 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6371 | if (FPT_BL_Card[p_card].pNvRamInfo == NULL) |
| 6372 | FPT_BL_Card[p_card].globalFlags |= |
| 6373 | F_UPDATE_EEPROM; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6374 | return match; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6375 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6376 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6377 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6378 | match--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6379 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6380 | if (match == 0xFF) { |
| 6381 | if (p_id_string[0] & BIT(5)) |
| 6382 | match = 7; |
| 6383 | else |
| 6384 | match = MAX_SCSI_TAR - 1; |
| 6385 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6386 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6387 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6388 | if (p_id_string[0] & BIT(7)) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6389 | return CLR_PRIORITY; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6390 | } |
| 6391 | |
| 6392 | if (p_id_string[0] & BIT(5)) |
| 6393 | i = 8; |
| 6394 | else |
| 6395 | i = MAX_SCSI_TAR; |
| 6396 | |
| 6397 | if (((p_id_string[0] & 0x06) == 0x02) |
| 6398 | || ((p_id_string[0] & 0x06) == 0x04)) |
| 6399 | match = p_id_string[1] & (unsigned char)0x1F; |
| 6400 | else |
| 6401 | match = 7; |
| 6402 | |
| 6403 | while (i > 0) { |
| 6404 | |
| 6405 | i--; |
| 6406 | |
| 6407 | if (FPT_scamInfo[match].state == ID_UNASSIGNED) { |
| 6408 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6409 | FPT_scamInfo[match].id_string[k] = |
| 6410 | p_id_string[k]; |
| 6411 | } |
| 6412 | |
| 6413 | FPT_scamInfo[match].id_string[0] |= BIT(7); |
| 6414 | FPT_scamInfo[match].state = ID_ASSIGNED; |
| 6415 | if (FPT_BL_Card[p_card].pNvRamInfo == NULL) |
| 6416 | FPT_BL_Card[p_card].globalFlags |= |
| 6417 | F_UPDATE_EEPROM; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6418 | return match; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6419 | |
| 6420 | } |
| 6421 | |
| 6422 | match--; |
| 6423 | |
| 6424 | if (match == 0xFF) { |
| 6425 | if (p_id_string[0] & BIT(5)) |
| 6426 | match = 7; |
| 6427 | else |
| 6428 | match = MAX_SCSI_TAR - 1; |
| 6429 | } |
| 6430 | } |
| 6431 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6432 | return NO_ID_AVAIL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6433 | } |
| 6434 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6435 | /*--------------------------------------------------------------------- |
| 6436 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6437 | * Function: FPT_scsavdi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6438 | * |
| 6439 | * Description: Save off the device SCAM ID strings. |
| 6440 | * |
| 6441 | *---------------------------------------------------------------------*/ |
| 6442 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6443 | static void FPT_scsavdi(unsigned char p_card, unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6444 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6445 | unsigned char i, k, max_id; |
| 6446 | unsigned short ee_data, sum_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6447 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6448 | sum_data = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6450 | for (i = 1; i < EE_SCAMBASE / 2; i++) { |
| 6451 | sum_data += FPT_utilEERead(p_port, i); |
| 6452 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6453 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6454 | FPT_utilEEWriteOnOff(p_port, 1); /* Enable write access to the EEPROM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6455 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6456 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6457 | max_id = 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6458 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6459 | else |
| 6460 | max_id = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6461 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6462 | for (i = 0; i < max_id; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6464 | for (k = 0; k < ID_STRING_LENGTH; k += 2) { |
| 6465 | ee_data = FPT_scamInfo[i].id_string[k + 1]; |
| 6466 | ee_data <<= 8; |
| 6467 | ee_data |= FPT_scamInfo[i].id_string[k]; |
| 6468 | sum_data += ee_data; |
| 6469 | FPT_utilEEWrite(p_port, ee_data, |
| 6470 | (unsigned short)((EE_SCAMBASE / 2) + |
| 6471 | (unsigned short)(i * |
| 6472 | ((unsigned short)ID_STRING_LENGTH / 2)) + (unsigned short)(k / 2))); |
| 6473 | } |
| 6474 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6475 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6476 | FPT_utilEEWrite(p_port, sum_data, EEPROM_CHECK_SUM / 2); |
| 6477 | FPT_utilEEWriteOnOff(p_port, 0); /* Turn off write access */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6478 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6479 | |
| 6480 | /*--------------------------------------------------------------------- |
| 6481 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6482 | * Function: FPT_XbowInit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6483 | * |
| 6484 | * Description: Setup the Xbow for normal operation. |
| 6485 | * |
| 6486 | *---------------------------------------------------------------------*/ |
| 6487 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6488 | static void FPT_XbowInit(unsigned long port, unsigned char ScamFlg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6489 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6490 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6492 | i = RD_HARPOON(port + hp_page_ctrl); |
| 6493 | WR_HARPOON(port + hp_page_ctrl, (unsigned char)(i | G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6494 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6495 | WR_HARPOON(port + hp_scsireset, 0x00); |
| 6496 | WR_HARPOON(port + hp_portctrl_1, HOST_MODE8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6497 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6498 | WR_HARPOON(port + hp_scsireset, (DMA_RESET | HPSCSI_RESET | PROG_RESET | |
| 6499 | FIFO_CLR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6500 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6501 | WR_HARPOON(port + hp_scsireset, SCSI_INI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6502 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6503 | WR_HARPOON(port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6504 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6505 | WR_HARPOON(port + hp_scsisig, 0x00); /* Clear any signals we might */ |
| 6506 | WR_HARPOON(port + hp_scsictrl_0, ENA_SCAM_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6507 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6508 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6509 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6510 | FPT_default_intena = RESET | RSEL | PROG_HLT | TIMEOUT | |
| 6511 | BUS_FREE | XFER_CNT_0 | AUTO_INT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6512 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6513 | if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2)) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6514 | FPT_default_intena |= SCAM_SEL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6515 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6516 | WRW_HARPOON((port + hp_intena), FPT_default_intena); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6517 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6518 | WR_HARPOON(port + hp_seltimeout, TO_290ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6519 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6520 | /* Turn on SCSI_MODE8 for narrow cards to fix the |
| 6521 | strapping issue with the DUAL CHANNEL card */ |
| 6522 | if (RD_HARPOON(port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6523 | WR_HARPOON(port + hp_addstat, SCSI_MODE8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6524 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6525 | WR_HARPOON(port + hp_page_ctrl, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6526 | |
| 6527 | } |
| 6528 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6529 | /*--------------------------------------------------------------------- |
| 6530 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6531 | * Function: FPT_BusMasterInit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6532 | * |
| 6533 | * Description: Initialize the BusMaster for normal operations. |
| 6534 | * |
| 6535 | *---------------------------------------------------------------------*/ |
| 6536 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6537 | static void FPT_BusMasterInit(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6538 | { |
| 6539 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6540 | WR_HARPOON(p_port + hp_sys_ctrl, DRVR_RST); |
| 6541 | WR_HARPOON(p_port + hp_sys_ctrl, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6542 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6543 | WR_HARPOON(p_port + hp_host_blk_cnt, XFER_BLK64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6544 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6545 | WR_HARPOON(p_port + hp_bm_ctrl, (BMCTRL_DEFAULT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6546 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6547 | WR_HARPOON(p_port + hp_ee_ctrl, (SCSI_TERM_ENA_H)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6548 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6549 | RD_HARPOON(p_port + hp_int_status); /*Clear interrupts. */ |
| 6550 | WR_HARPOON(p_port + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
| 6551 | WR_HARPOON(p_port + hp_page_ctrl, (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6552 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6553 | } |
| 6554 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6555 | /*--------------------------------------------------------------------- |
| 6556 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6557 | * Function: FPT_DiagEEPROM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6558 | * |
| 6559 | * Description: Verfiy checksum and 'Key' and initialize the EEPROM if |
| 6560 | * necessary. |
| 6561 | * |
| 6562 | *---------------------------------------------------------------------*/ |
| 6563 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6564 | static void FPT_DiagEEPROM(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6565 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6566 | unsigned short index, temp, max_wd_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6567 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6568 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6569 | max_wd_cnt = EEPROM_WD_CNT; |
| 6570 | else |
| 6571 | max_wd_cnt = EEPROM_WD_CNT * 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6572 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6573 | temp = FPT_utilEERead(p_port, FW_SIGNATURE / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6574 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6575 | if (temp == 0x4641) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6576 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6577 | for (index = 2; index < max_wd_cnt; index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6578 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6579 | temp += FPT_utilEERead(p_port, index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6580 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6581 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6582 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6583 | if (temp == FPT_utilEERead(p_port, EEPROM_CHECK_SUM / 2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6584 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6585 | return; /*EEPROM is Okay so return now! */ |
| 6586 | } |
| 6587 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6588 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6589 | FPT_utilEEWriteOnOff(p_port, (unsigned char)1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6590 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6591 | for (index = 0; index < max_wd_cnt; index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6592 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6593 | FPT_utilEEWrite(p_port, 0x0000, index); |
| 6594 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6595 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6596 | temp = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6597 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6598 | FPT_utilEEWrite(p_port, 0x4641, FW_SIGNATURE / 2); |
| 6599 | temp += 0x4641; |
| 6600 | FPT_utilEEWrite(p_port, 0x3920, MODEL_NUMB_0 / 2); |
| 6601 | temp += 0x3920; |
| 6602 | FPT_utilEEWrite(p_port, 0x3033, MODEL_NUMB_2 / 2); |
| 6603 | temp += 0x3033; |
| 6604 | FPT_utilEEWrite(p_port, 0x2020, MODEL_NUMB_4 / 2); |
| 6605 | temp += 0x2020; |
| 6606 | FPT_utilEEWrite(p_port, 0x70D3, SYSTEM_CONFIG / 2); |
| 6607 | temp += 0x70D3; |
| 6608 | FPT_utilEEWrite(p_port, 0x0010, BIOS_CONFIG / 2); |
| 6609 | temp += 0x0010; |
| 6610 | FPT_utilEEWrite(p_port, 0x0003, SCAM_CONFIG / 2); |
| 6611 | temp += 0x0003; |
| 6612 | FPT_utilEEWrite(p_port, 0x0007, ADAPTER_SCSI_ID / 2); |
| 6613 | temp += 0x0007; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6614 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6615 | FPT_utilEEWrite(p_port, 0x0000, IGNORE_B_SCAN / 2); |
| 6616 | temp += 0x0000; |
| 6617 | FPT_utilEEWrite(p_port, 0x0000, SEND_START_ENA / 2); |
| 6618 | temp += 0x0000; |
| 6619 | FPT_utilEEWrite(p_port, 0x0000, DEVICE_ENABLE / 2); |
| 6620 | temp += 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6621 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6622 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL01 / 2); |
| 6623 | temp += 0x4242; |
| 6624 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL23 / 2); |
| 6625 | temp += 0x4242; |
| 6626 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL45 / 2); |
| 6627 | temp += 0x4242; |
| 6628 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL67 / 2); |
| 6629 | temp += 0x4242; |
| 6630 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL89 / 2); |
| 6631 | temp += 0x4242; |
| 6632 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLab / 2); |
| 6633 | temp += 0x4242; |
| 6634 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLcd / 2); |
| 6635 | temp += 0x4242; |
| 6636 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLef / 2); |
| 6637 | temp += 0x4242; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6638 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6639 | FPT_utilEEWrite(p_port, 0x6C46, 64 / 2); /*PRODUCT ID */ |
| 6640 | temp += 0x6C46; |
| 6641 | FPT_utilEEWrite(p_port, 0x7361, 66 / 2); /* FlashPoint LT */ |
| 6642 | temp += 0x7361; |
| 6643 | FPT_utilEEWrite(p_port, 0x5068, 68 / 2); |
| 6644 | temp += 0x5068; |
| 6645 | FPT_utilEEWrite(p_port, 0x696F, 70 / 2); |
| 6646 | temp += 0x696F; |
| 6647 | FPT_utilEEWrite(p_port, 0x746E, 72 / 2); |
| 6648 | temp += 0x746E; |
| 6649 | FPT_utilEEWrite(p_port, 0x4C20, 74 / 2); |
| 6650 | temp += 0x4C20; |
| 6651 | FPT_utilEEWrite(p_port, 0x2054, 76 / 2); |
| 6652 | temp += 0x2054; |
| 6653 | FPT_utilEEWrite(p_port, 0x2020, 78 / 2); |
| 6654 | temp += 0x2020; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6655 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6656 | index = ((EE_SCAMBASE / 2) + (7 * 16)); |
| 6657 | FPT_utilEEWrite(p_port, (0x0700 + TYPE_CODE0), index); |
| 6658 | temp += (0x0700 + TYPE_CODE0); |
| 6659 | index++; |
| 6660 | FPT_utilEEWrite(p_port, 0x5542, index); /*Vendor ID code */ |
| 6661 | temp += 0x5542; /* BUSLOGIC */ |
| 6662 | index++; |
| 6663 | FPT_utilEEWrite(p_port, 0x4C53, index); |
| 6664 | temp += 0x4C53; |
| 6665 | index++; |
| 6666 | FPT_utilEEWrite(p_port, 0x474F, index); |
| 6667 | temp += 0x474F; |
| 6668 | index++; |
| 6669 | FPT_utilEEWrite(p_port, 0x4349, index); |
| 6670 | temp += 0x4349; |
| 6671 | index++; |
| 6672 | FPT_utilEEWrite(p_port, 0x5442, index); /*Vendor unique code */ |
| 6673 | temp += 0x5442; /* BT- 930 */ |
| 6674 | index++; |
| 6675 | FPT_utilEEWrite(p_port, 0x202D, index); |
| 6676 | temp += 0x202D; |
| 6677 | index++; |
| 6678 | FPT_utilEEWrite(p_port, 0x3339, index); |
| 6679 | temp += 0x3339; |
| 6680 | index++; /*Serial # */ |
| 6681 | FPT_utilEEWrite(p_port, 0x2030, index); /* 01234567 */ |
| 6682 | temp += 0x2030; |
| 6683 | index++; |
| 6684 | FPT_utilEEWrite(p_port, 0x5453, index); |
| 6685 | temp += 0x5453; |
| 6686 | index++; |
| 6687 | FPT_utilEEWrite(p_port, 0x5645, index); |
| 6688 | temp += 0x5645; |
| 6689 | index++; |
| 6690 | FPT_utilEEWrite(p_port, 0x2045, index); |
| 6691 | temp += 0x2045; |
| 6692 | index++; |
| 6693 | FPT_utilEEWrite(p_port, 0x202F, index); |
| 6694 | temp += 0x202F; |
| 6695 | index++; |
| 6696 | FPT_utilEEWrite(p_port, 0x4F4A, index); |
| 6697 | temp += 0x4F4A; |
| 6698 | index++; |
| 6699 | FPT_utilEEWrite(p_port, 0x204E, index); |
| 6700 | temp += 0x204E; |
| 6701 | index++; |
| 6702 | FPT_utilEEWrite(p_port, 0x3539, index); |
| 6703 | temp += 0x3539; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6704 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6705 | FPT_utilEEWrite(p_port, temp, EEPROM_CHECK_SUM / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6706 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6707 | FPT_utilEEWriteOnOff(p_port, (unsigned char)0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6708 | |
| 6709 | } |
| 6710 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6711 | /*--------------------------------------------------------------------- |
| 6712 | * |
| 6713 | * Function: Queue Search Select |
| 6714 | * |
| 6715 | * Description: Try to find a new command to execute. |
| 6716 | * |
| 6717 | *---------------------------------------------------------------------*/ |
| 6718 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6719 | static void FPT_queueSearchSelect(struct sccb_card *pCurrCard, |
| 6720 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6721 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6722 | unsigned char scan_ptr, lun; |
| 6723 | struct sccb_mgr_tar_info *currTar_Info; |
| 6724 | struct sccb *pOldSccb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6725 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6726 | scan_ptr = pCurrCard->scanIndex; |
| 6727 | do { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6728 | currTar_Info = &FPT_sccbMgrTbl[p_card][scan_ptr]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6729 | if ((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 6730 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 6731 | TAG_Q_TRYING)) { |
| 6732 | if (currTar_Info->TarSelQ_Cnt != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6733 | |
| 6734 | scan_ptr++; |
| 6735 | if (scan_ptr == MAX_SCSI_TAR) |
| 6736 | scan_ptr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6737 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6738 | for (lun = 0; lun < MAX_LUN; lun++) { |
| 6739 | if (currTar_Info->TarLUNBusy[lun] == 0) { |
| 6740 | |
| 6741 | pCurrCard->currentSCCB = |
| 6742 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6743 | pOldSccb = NULL; |
| 6744 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6745 | while ((pCurrCard-> |
| 6746 | currentSCCB != NULL) |
| 6747 | && (lun != |
| 6748 | pCurrCard-> |
| 6749 | currentSCCB->Lun)) { |
| 6750 | pOldSccb = |
| 6751 | pCurrCard-> |
| 6752 | currentSCCB; |
| 6753 | pCurrCard->currentSCCB = |
| 6754 | (struct sccb |
| 6755 | *)(pCurrCard-> |
| 6756 | currentSCCB)-> |
| 6757 | Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6758 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6759 | if (pCurrCard->currentSCCB == |
| 6760 | NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6761 | continue; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6762 | if (pOldSccb != NULL) { |
| 6763 | pOldSccb-> |
| 6764 | Sccb_forwardlink = |
| 6765 | (struct sccb |
| 6766 | *)(pCurrCard-> |
| 6767 | currentSCCB)-> |
| 6768 | Sccb_forwardlink; |
| 6769 | pOldSccb-> |
| 6770 | Sccb_backlink = |
| 6771 | (struct sccb |
| 6772 | *)(pCurrCard-> |
| 6773 | currentSCCB)-> |
| 6774 | Sccb_backlink; |
| 6775 | currTar_Info-> |
| 6776 | TarSelQ_Cnt--; |
| 6777 | } else { |
| 6778 | currTar_Info-> |
| 6779 | TarSelQ_Head = |
| 6780 | (struct sccb |
| 6781 | *)(pCurrCard-> |
| 6782 | currentSCCB)-> |
| 6783 | Sccb_forwardlink; |
| 6784 | |
| 6785 | if (currTar_Info-> |
| 6786 | TarSelQ_Head == |
| 6787 | NULL) { |
| 6788 | currTar_Info-> |
| 6789 | TarSelQ_Tail |
| 6790 | = NULL; |
| 6791 | currTar_Info-> |
| 6792 | TarSelQ_Cnt |
| 6793 | = 0; |
| 6794 | } else { |
| 6795 | currTar_Info-> |
| 6796 | TarSelQ_Cnt--; |
| 6797 | currTar_Info-> |
| 6798 | TarSelQ_Head-> |
| 6799 | Sccb_backlink |
| 6800 | = |
| 6801 | (struct sccb |
| 6802 | *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6803 | } |
| 6804 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6805 | pCurrCard->scanIndex = scan_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6806 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6807 | pCurrCard->globalFlags |= |
| 6808 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6809 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6810 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6811 | } |
| 6812 | } |
| 6813 | } |
| 6814 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6815 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6816 | scan_ptr++; |
| 6817 | if (scan_ptr == MAX_SCSI_TAR) { |
| 6818 | scan_ptr = 0; |
| 6819 | } |
| 6820 | } |
| 6821 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6822 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6823 | if ((currTar_Info->TarSelQ_Cnt != 0) && |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6824 | (currTar_Info->TarLUNBusy[0] == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6825 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6826 | pCurrCard->currentSCCB = |
| 6827 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6828 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6829 | currTar_Info->TarSelQ_Head = |
| 6830 | (struct sccb *)(pCurrCard->currentSCCB)-> |
| 6831 | Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6832 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6833 | if (currTar_Info->TarSelQ_Head == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6834 | currTar_Info->TarSelQ_Tail = NULL; |
| 6835 | currTar_Info->TarSelQ_Cnt = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6836 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6837 | currTar_Info->TarSelQ_Cnt--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6838 | currTar_Info->TarSelQ_Head-> |
| 6839 | Sccb_backlink = (struct sccb *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6840 | } |
| 6841 | |
| 6842 | scan_ptr++; |
| 6843 | if (scan_ptr == MAX_SCSI_TAR) |
| 6844 | scan_ptr = 0; |
| 6845 | |
| 6846 | pCurrCard->scanIndex = scan_ptr; |
| 6847 | |
| 6848 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 6849 | |
| 6850 | break; |
| 6851 | } |
| 6852 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6853 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6854 | scan_ptr++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6855 | if (scan_ptr == MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6856 | scan_ptr = 0; |
| 6857 | } |
| 6858 | } |
| 6859 | } |
| 6860 | } while (scan_ptr != pCurrCard->scanIndex); |
| 6861 | } |
| 6862 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6863 | /*--------------------------------------------------------------------- |
| 6864 | * |
| 6865 | * Function: Queue Select Fail |
| 6866 | * |
| 6867 | * Description: Add the current SCCB to the head of the Queue. |
| 6868 | * |
| 6869 | *---------------------------------------------------------------------*/ |
| 6870 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6871 | static void FPT_queueSelectFail(struct sccb_card *pCurrCard, |
| 6872 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6873 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6874 | unsigned char thisTarg; |
| 6875 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6876 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6877 | if (pCurrCard->currentSCCB != NULL) { |
| 6878 | thisTarg = |
| 6879 | (unsigned char)(((struct sccb *)(pCurrCard->currentSCCB))-> |
| 6880 | TargID); |
| 6881 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6882 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6883 | pCurrCard->currentSCCB->Sccb_backlink = (struct sccb *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6884 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6885 | pCurrCard->currentSCCB->Sccb_forwardlink = |
| 6886 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6887 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6888 | if (currTar_Info->TarSelQ_Cnt == 0) { |
| 6889 | currTar_Info->TarSelQ_Tail = pCurrCard->currentSCCB; |
| 6890 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6891 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6892 | else { |
| 6893 | currTar_Info->TarSelQ_Head->Sccb_backlink = |
| 6894 | pCurrCard->currentSCCB; |
| 6895 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6896 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6897 | currTar_Info->TarSelQ_Head = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6898 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6899 | pCurrCard->currentSCCB = NULL; |
| 6900 | currTar_Info->TarSelQ_Cnt++; |
| 6901 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6902 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6903 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6904 | /*--------------------------------------------------------------------- |
| 6905 | * |
| 6906 | * Function: Queue Command Complete |
| 6907 | * |
| 6908 | * Description: Call the callback function with the current SCCB. |
| 6909 | * |
| 6910 | *---------------------------------------------------------------------*/ |
| 6911 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6912 | static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, |
| 6913 | struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6914 | { |
| 6915 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6916 | unsigned char i, SCSIcmd; |
| 6917 | CALL_BK_FN callback; |
| 6918 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6919 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6920 | SCSIcmd = p_sccb->Cdb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6921 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6922 | if (!(p_sccb->Sccb_XferState & F_ALL_XFERRED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6923 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6924 | if ((p_sccb-> |
| 6925 | ControlByte & (SCCB_DATA_XFER_OUT | SCCB_DATA_XFER_IN)) |
| 6926 | && (p_sccb->HostStatus == SCCB_COMPLETE) |
| 6927 | && (p_sccb->TargetStatus != SSCHECK)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6928 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6929 | if ((SCSIcmd == SCSI_READ) || |
| 6930 | (SCSIcmd == SCSI_WRITE) || |
| 6931 | (SCSIcmd == SCSI_READ_EXTENDED) || |
| 6932 | (SCSIcmd == SCSI_WRITE_EXTENDED) || |
| 6933 | (SCSIcmd == SCSI_WRITE_AND_VERIFY) || |
| 6934 | (SCSIcmd == SCSI_START_STOP_UNIT) || |
| 6935 | (pCurrCard->globalFlags & F_NO_FILTER) |
| 6936 | ) |
| 6937 | p_sccb->HostStatus = SCCB_DATA_UNDER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6938 | } |
| 6939 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6940 | if (p_sccb->SccbStatus == SCCB_IN_PROCESS) { |
| 6941 | if (p_sccb->HostStatus || p_sccb->TargetStatus) |
| 6942 | p_sccb->SccbStatus = SCCB_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6943 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6944 | p_sccb->SccbStatus = SCCB_SUCCESS; |
| 6945 | } |
| 6946 | |
| 6947 | if (p_sccb->Sccb_XferState & F_AUTO_SENSE) { |
| 6948 | |
| 6949 | p_sccb->CdbLength = p_sccb->Save_CdbLen; |
| 6950 | for (i = 0; i < 6; i++) { |
| 6951 | p_sccb->Cdb[i] = p_sccb->Save_Cdb[i]; |
| 6952 | } |
| 6953 | } |
| 6954 | |
| 6955 | if ((p_sccb->OperationCode == RESIDUAL_SG_COMMAND) || |
| 6956 | (p_sccb->OperationCode == RESIDUAL_COMMAND)) { |
| 6957 | |
| 6958 | FPT_utilUpdateResidual(p_sccb); |
| 6959 | } |
| 6960 | |
| 6961 | pCurrCard->cmdCounter--; |
| 6962 | if (!pCurrCard->cmdCounter) { |
| 6963 | |
| 6964 | if (pCurrCard->globalFlags & F_GREEN_PC) { |
| 6965 | WR_HARPOON(pCurrCard->ioPort + hp_clkctrl_0, |
| 6966 | (PWR_DWN | CLKCTRL_DEFAULT)); |
| 6967 | WR_HARPOON(pCurrCard->ioPort + hp_sys_ctrl, STOP_CLK); |
| 6968 | } |
| 6969 | |
| 6970 | WR_HARPOON(pCurrCard->ioPort + hp_semaphore, |
| 6971 | (RD_HARPOON(pCurrCard->ioPort + hp_semaphore) & |
| 6972 | ~SCCB_MGR_ACTIVE)); |
| 6973 | |
| 6974 | } |
| 6975 | |
| 6976 | if (pCurrCard->discQCount != 0) { |
| 6977 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
| 6978 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 6979 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 6980 | TAG_Q_TRYING))) { |
| 6981 | pCurrCard->discQCount--; |
| 6982 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 6983 | LunDiscQ_Idx[p_sccb->Lun]] = NULL; |
| 6984 | } else { |
| 6985 | if (p_sccb->Sccb_tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6986 | pCurrCard->discQCount--; |
| 6987 | pCurrCard->discQ_Tbl[p_sccb->Sccb_tag] = NULL; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6988 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6989 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6990 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 6991 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6992 | } |
| 6993 | } |
| 6994 | |
| 6995 | } |
| 6996 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6997 | callback = (CALL_BK_FN) p_sccb->SccbCallback; |
| 6998 | callback(p_sccb); |
| 6999 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 7000 | pCurrCard->currentSCCB = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7001 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7002 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7003 | /*--------------------------------------------------------------------- |
| 7004 | * |
| 7005 | * Function: Queue Disconnect |
| 7006 | * |
| 7007 | * Description: Add SCCB to our disconnect array. |
| 7008 | * |
| 7009 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7010 | static void FPT_queueDisconnect(struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7011 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7012 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7013 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7014 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7015 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7016 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 7017 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 7018 | FPT_BL_Card[p_card].discQ_Tbl[currTar_Info-> |
| 7019 | LunDiscQ_Idx[p_sccb->Lun]] = |
| 7020 | p_sccb; |
| 7021 | } else { |
| 7022 | if (p_sccb->Sccb_tag) { |
| 7023 | FPT_BL_Card[p_card].discQ_Tbl[p_sccb->Sccb_tag] = |
| 7024 | p_sccb; |
| 7025 | FPT_sccbMgrTbl[p_card][p_sccb->TargID].TarLUNBusy[0] = |
| 7026 | 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7027 | FPT_sccbMgrTbl[p_card][p_sccb->TargID].TarTagQ_Cnt++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7028 | } else { |
| 7029 | FPT_BL_Card[p_card].discQ_Tbl[currTar_Info-> |
| 7030 | LunDiscQ_Idx[0]] = p_sccb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7031 | } |
| 7032 | } |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7033 | FPT_BL_Card[p_card].currentSCCB = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7034 | } |
| 7035 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7036 | /*--------------------------------------------------------------------- |
| 7037 | * |
| 7038 | * Function: Queue Flush SCCB |
| 7039 | * |
| 7040 | * Description: Flush all SCCB's back to the host driver for this target. |
| 7041 | * |
| 7042 | *---------------------------------------------------------------------*/ |
| 7043 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7044 | static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7045 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7046 | unsigned char qtag, thisTarg; |
| 7047 | struct sccb *currSCCB; |
| 7048 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7049 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7050 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 7051 | if (currSCCB != NULL) { |
| 7052 | thisTarg = (unsigned char)currSCCB->TargID; |
| 7053 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7054 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7055 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7056 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7057 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] && |
| 7058 | (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == |
| 7059 | thisTarg)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7060 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7061 | FPT_BL_Card[p_card].discQ_Tbl[qtag]-> |
| 7062 | HostStatus = (unsigned char)error_code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7063 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7064 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 7065 | FPT_BL_Card[p_card]. |
| 7066 | discQ_Tbl[qtag], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7067 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7068 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 7069 | currTar_Info->TarTagQ_Cnt--; |
| 7070 | |
| 7071 | } |
| 7072 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7073 | } |
| 7074 | |
| 7075 | } |
| 7076 | |
| 7077 | /*--------------------------------------------------------------------- |
| 7078 | * |
| 7079 | * Function: Queue Flush Target SCCB |
| 7080 | * |
| 7081 | * Description: Flush all SCCB's back to the host driver for this target. |
| 7082 | * |
| 7083 | *---------------------------------------------------------------------*/ |
| 7084 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7085 | static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg, |
| 7086 | unsigned char error_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7087 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7088 | unsigned char qtag; |
| 7089 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7090 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7091 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7092 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7093 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7094 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7095 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] && |
| 7096 | (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == thisTarg)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7097 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7098 | FPT_BL_Card[p_card].discQ_Tbl[qtag]->HostStatus = |
| 7099 | (unsigned char)error_code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7100 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7101 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 7102 | FPT_BL_Card[p_card]. |
| 7103 | discQ_Tbl[qtag], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7104 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7105 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 7106 | currTar_Info->TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7107 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7108 | } |
| 7109 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7110 | |
| 7111 | } |
| 7112 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7113 | static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7114 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7115 | struct sccb_mgr_tar_info *currTar_Info; |
| 7116 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_SCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7117 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7118 | p_SCCB->Sccb_forwardlink = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7119 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7120 | p_SCCB->Sccb_backlink = currTar_Info->TarSelQ_Tail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7121 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7122 | if (currTar_Info->TarSelQ_Cnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7123 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7124 | currTar_Info->TarSelQ_Head = p_SCCB; |
| 7125 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7126 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7127 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7128 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7129 | currTar_Info->TarSelQ_Tail->Sccb_forwardlink = p_SCCB; |
| 7130 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7131 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7132 | currTar_Info->TarSelQ_Tail = p_SCCB; |
| 7133 | currTar_Info->TarSelQ_Cnt++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7134 | } |
| 7135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7136 | /*--------------------------------------------------------------------- |
| 7137 | * |
| 7138 | * Function: Queue Find SCCB |
| 7139 | * |
| 7140 | * Description: Search the target select Queue for this SCCB, and |
| 7141 | * remove it if found. |
| 7142 | * |
| 7143 | *---------------------------------------------------------------------*/ |
| 7144 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7145 | static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB, |
| 7146 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7147 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7148 | struct sccb *q_ptr; |
| 7149 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7150 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7151 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_SCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7152 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7153 | q_ptr = currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7154 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7155 | while (q_ptr != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7156 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7157 | if (q_ptr == p_SCCB) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7158 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7159 | if (currTar_Info->TarSelQ_Head == q_ptr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7160 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7161 | currTar_Info->TarSelQ_Head = |
| 7162 | q_ptr->Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7163 | } |
| 7164 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7165 | if (currTar_Info->TarSelQ_Tail == q_ptr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7166 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7167 | currTar_Info->TarSelQ_Tail = |
| 7168 | q_ptr->Sccb_backlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7169 | } |
| 7170 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7171 | if (q_ptr->Sccb_forwardlink != NULL) { |
| 7172 | q_ptr->Sccb_forwardlink->Sccb_backlink = |
| 7173 | q_ptr->Sccb_backlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7174 | } |
| 7175 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7176 | if (q_ptr->Sccb_backlink != NULL) { |
| 7177 | q_ptr->Sccb_backlink->Sccb_forwardlink = |
| 7178 | q_ptr->Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7179 | } |
| 7180 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7181 | currTar_Info->TarSelQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7182 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7183 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7184 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7185 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7186 | else { |
| 7187 | q_ptr = q_ptr->Sccb_forwardlink; |
| 7188 | } |
| 7189 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7190 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7191 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7192 | |
| 7193 | } |
| 7194 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7195 | /*--------------------------------------------------------------------- |
| 7196 | * |
| 7197 | * Function: Utility Update Residual Count |
| 7198 | * |
| 7199 | * Description: Update the XferCnt to the remaining byte count. |
| 7200 | * If we transferred all the data then just write zero. |
| 7201 | * If Non-SG transfer then report Total Cnt - Actual Transfer |
| 7202 | * Cnt. For SG transfers add the count fields of all |
| 7203 | * remaining SG elements, as well as any partial remaining |
| 7204 | * element. |
| 7205 | * |
| 7206 | *---------------------------------------------------------------------*/ |
| 7207 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7208 | static void FPT_utilUpdateResidual(struct sccb *p_SCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7209 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7210 | unsigned long partial_cnt; |
| 7211 | unsigned int sg_index; |
| 7212 | unsigned long *sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7213 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7214 | if (p_SCCB->Sccb_XferState & F_ALL_XFERRED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7215 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7216 | p_SCCB->DataLength = 0x0000; |
| 7217 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7218 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7219 | else if (p_SCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7220 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7221 | partial_cnt = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7222 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7223 | sg_index = p_SCCB->Sccb_sgseg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7224 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7225 | sg_ptr = (unsigned long *)p_SCCB->DataPointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7226 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7227 | if (p_SCCB->Sccb_SGoffset) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7228 | |
| 7229 | partial_cnt = p_SCCB->Sccb_SGoffset; |
| 7230 | sg_index++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7231 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7232 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7233 | while (((unsigned long)sg_index * |
| 7234 | (unsigned long)SG_ELEMENT_SIZE) < p_SCCB->DataLength) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7235 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7236 | partial_cnt += *(sg_ptr + (sg_index * 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7237 | sg_index++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7238 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7239 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7240 | p_SCCB->DataLength = partial_cnt; |
| 7241 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7242 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7243 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7244 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7245 | p_SCCB->DataLength -= p_SCCB->Sccb_ATC; |
| 7246 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7247 | } |
| 7248 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7249 | /*--------------------------------------------------------------------- |
| 7250 | * |
| 7251 | * Function: Wait 1 Second |
| 7252 | * |
| 7253 | * Description: Wait for 1 second. |
| 7254 | * |
| 7255 | *---------------------------------------------------------------------*/ |
| 7256 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 7257 | static void FPT_Wait1Second(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7258 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7259 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7260 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7261 | for (i = 0; i < 4; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7262 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7263 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7264 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7265 | if ((RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST)) |
| 7266 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7267 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7268 | if ((RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) |
| 7269 | break; |
| 7270 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7271 | } |
| 7272 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7273 | /*--------------------------------------------------------------------- |
| 7274 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7275 | * Function: FPT_Wait |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7276 | * |
| 7277 | * Description: Wait the desired delay. |
| 7278 | * |
| 7279 | *---------------------------------------------------------------------*/ |
| 7280 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 7281 | static void FPT_Wait(unsigned long p_port, unsigned char p_delay) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7282 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7283 | unsigned char old_timer; |
| 7284 | unsigned char green_flag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7285 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7286 | old_timer = RD_HARPOON(p_port + hp_seltimeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7287 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7288 | green_flag = RD_HARPOON(p_port + hp_clkctrl_0); |
| 7289 | WR_HARPOON(p_port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7290 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7291 | WR_HARPOON(p_port + hp_seltimeout, p_delay); |
| 7292 | WRW_HARPOON((p_port + hp_intstat), TIMEOUT); |
| 7293 | WRW_HARPOON((p_port + hp_intena), (FPT_default_intena & ~TIMEOUT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7294 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7295 | WR_HARPOON(p_port + hp_portctrl_0, |
| 7296 | (RD_HARPOON(p_port + hp_portctrl_0) | START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7297 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7298 | while (!(RDW_HARPOON((p_port + hp_intstat)) & TIMEOUT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7299 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7300 | if ((RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST)) |
| 7301 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7302 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7303 | if ((RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) |
| 7304 | break; |
| 7305 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7306 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7307 | WR_HARPOON(p_port + hp_portctrl_0, |
| 7308 | (RD_HARPOON(p_port + hp_portctrl_0) & ~START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7309 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7310 | WRW_HARPOON((p_port + hp_intstat), TIMEOUT); |
| 7311 | WRW_HARPOON((p_port + hp_intena), FPT_default_intena); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7312 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7313 | WR_HARPOON(p_port + hp_clkctrl_0, green_flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7314 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7315 | WR_HARPOON(p_port + hp_seltimeout, old_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7316 | } |
| 7317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7318 | /*--------------------------------------------------------------------- |
| 7319 | * |
| 7320 | * Function: Enable/Disable Write to EEPROM |
| 7321 | * |
| 7322 | * Description: The EEPROM must first be enabled for writes |
| 7323 | * A total of 9 clocks are needed. |
| 7324 | * |
| 7325 | *---------------------------------------------------------------------*/ |
| 7326 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7327 | static void FPT_utilEEWriteOnOff(unsigned long p_port, unsigned char p_mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7328 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7329 | unsigned char ee_value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7330 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7331 | ee_value = |
| 7332 | (unsigned char)(RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7333 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7334 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7335 | if (p_mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7336 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7337 | FPT_utilEESendCmdAddr(p_port, EWEN, EWEN_ADDR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7338 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7339 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7340 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7341 | FPT_utilEESendCmdAddr(p_port, EWDS, EWDS_ADDR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7342 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7343 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */ |
| 7344 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); /*Turn off Master Select */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7345 | } |
| 7346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7347 | /*--------------------------------------------------------------------- |
| 7348 | * |
| 7349 | * Function: Write EEPROM |
| 7350 | * |
| 7351 | * Description: Write a word to the EEPROM at the specified |
| 7352 | * address. |
| 7353 | * |
| 7354 | *---------------------------------------------------------------------*/ |
| 7355 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7356 | static void FPT_utilEEWrite(unsigned long p_port, unsigned short ee_data, |
| 7357 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7358 | { |
| 7359 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7360 | unsigned char ee_value; |
| 7361 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7362 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7363 | ee_value = |
| 7364 | (unsigned |
| 7365 | char)((RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7366 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)) | (SEE_MS | SEE_CS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7367 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7368 | FPT_utilEESendCmdAddr(p_port, EE_WRITE, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7369 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7370 | ee_value |= (SEE_MS + SEE_CS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7371 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7372 | for (i = 0x8000; i != 0; i >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7373 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7374 | if (i & ee_data) |
| 7375 | ee_value |= SEE_DO; |
| 7376 | else |
| 7377 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7379 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7380 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7381 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7382 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7383 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7384 | ee_value &= ~SEE_CLK; |
| 7385 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7386 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7387 | } |
| 7388 | ee_value &= (EXT_ARB_ACK | SCSI_TERM_ENA_H); |
| 7389 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7390 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7391 | FPT_Wait(p_port, TO_10ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7392 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7393 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS | SEE_CS)); /* Set CS to EEPROM */ |
| 7394 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /* Turn off CS */ |
| 7395 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); /* Turn off Master Select */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7396 | } |
| 7397 | |
| 7398 | /*--------------------------------------------------------------------- |
| 7399 | * |
| 7400 | * Function: Read EEPROM |
| 7401 | * |
| 7402 | * Description: Read a word from the EEPROM at the desired |
| 7403 | * address. |
| 7404 | * |
| 7405 | *---------------------------------------------------------------------*/ |
| 7406 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7407 | static unsigned short FPT_utilEERead(unsigned long p_port, |
| 7408 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7409 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7410 | unsigned short i, ee_data1, ee_data2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7411 | |
| 7412 | i = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7413 | ee_data1 = FPT_utilEEReadOrg(p_port, ee_addr); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7414 | do { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7415 | ee_data2 = FPT_utilEEReadOrg(p_port, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7416 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7417 | if (ee_data1 == ee_data2) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7418 | return ee_data1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7419 | |
| 7420 | ee_data1 = ee_data2; |
| 7421 | i++; |
| 7422 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7423 | } while (i < 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7424 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7425 | return ee_data1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7426 | } |
| 7427 | |
| 7428 | /*--------------------------------------------------------------------- |
| 7429 | * |
| 7430 | * Function: Read EEPROM Original |
| 7431 | * |
| 7432 | * Description: Read a word from the EEPROM at the desired |
| 7433 | * address. |
| 7434 | * |
| 7435 | *---------------------------------------------------------------------*/ |
| 7436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7437 | static unsigned short FPT_utilEEReadOrg(unsigned long p_port, |
| 7438 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7439 | { |
| 7440 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7441 | unsigned char ee_value; |
| 7442 | unsigned short i, ee_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7443 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7444 | ee_value = |
| 7445 | (unsigned |
| 7446 | char)((RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7447 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)) | (SEE_MS | SEE_CS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7448 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7449 | FPT_utilEESendCmdAddr(p_port, EE_READ, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7450 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7451 | ee_value |= (SEE_MS + SEE_CS); |
| 7452 | ee_data = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7453 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7454 | for (i = 1; i <= 16; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7455 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7456 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7457 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7458 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7459 | ee_value &= ~SEE_CLK; |
| 7460 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7461 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7462 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7463 | ee_data <<= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7464 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7465 | if (RD_HARPOON(p_port + hp_ee_ctrl) & SEE_DI) |
| 7466 | ee_data |= 1; |
| 7467 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7468 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7469 | ee_value &= ~(SEE_MS + SEE_CS); |
| 7470 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */ |
| 7471 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); /*Turn off Master Select */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7472 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7473 | return ee_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7474 | } |
| 7475 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7476 | /*--------------------------------------------------------------------- |
| 7477 | * |
| 7478 | * Function: Send EE command and Address to the EEPROM |
| 7479 | * |
| 7480 | * Description: Transfers the correct command and sends the address |
| 7481 | * to the eeprom. |
| 7482 | * |
| 7483 | *---------------------------------------------------------------------*/ |
| 7484 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7485 | static void FPT_utilEESendCmdAddr(unsigned long p_port, unsigned char ee_cmd, |
| 7486 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7487 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7488 | unsigned char ee_value; |
| 7489 | unsigned char narrow_flg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7490 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7491 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7492 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7493 | narrow_flg = |
| 7494 | (unsigned char)(RD_HARPOON(p_port + hp_page_ctrl) & |
| 7495 | NARROW_SCSI_CARD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7496 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7497 | ee_value = SEE_MS; |
| 7498 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7499 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7500 | ee_value |= SEE_CS; /* Set CS to EEPROM */ |
| 7501 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7502 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7503 | for (i = 0x04; i != 0; i >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7504 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7505 | if (i & ee_cmd) |
| 7506 | ee_value |= SEE_DO; |
| 7507 | else |
| 7508 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7509 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7510 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7511 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7512 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7513 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7514 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7515 | ee_value &= ~SEE_CLK; |
| 7516 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7517 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7518 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7519 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7520 | if (narrow_flg) |
| 7521 | i = 0x0080; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7522 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7523 | else |
| 7524 | i = 0x0200; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7525 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7526 | while (i != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7527 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7528 | if (i & ee_addr) |
| 7529 | ee_value |= SEE_DO; |
| 7530 | else |
| 7531 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7532 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7533 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7534 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7535 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7536 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7537 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7538 | ee_value &= ~SEE_CLK; |
| 7539 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7540 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7541 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7542 | i >>= 1; |
| 7543 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7544 | } |
| 7545 | |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 7546 | static unsigned short FPT_CalcCrc16(unsigned char buffer[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7547 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7548 | unsigned short crc = 0; |
| 7549 | int i, j; |
| 7550 | unsigned short ch; |
| 7551 | for (i = 0; i < ID_STRING_LENGTH; i++) { |
| 7552 | ch = (unsigned short)buffer[i]; |
| 7553 | for (j = 0; j < 8; j++) { |
| 7554 | if ((crc ^ ch) & 1) |
| 7555 | crc = (crc >> 1) ^ CRCMASK; |
| 7556 | else |
| 7557 | crc >>= 1; |
| 7558 | ch >>= 1; |
| 7559 | } |
| 7560 | } |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7561 | return crc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7562 | } |
| 7563 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 7564 | static unsigned char FPT_CalcLrc(unsigned char buffer[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7565 | { |
| 7566 | int i; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 7567 | unsigned char lrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7568 | lrc = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7569 | for (i = 0; i < ID_STRING_LENGTH; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7570 | lrc ^= buffer[i]; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7571 | return lrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7572 | } |
| 7573 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7574 | /* |
| 7575 | The following inline definitions avoid type conflicts. |
| 7576 | */ |
| 7577 | |
| 7578 | static inline unsigned char |
| 7579 | FlashPoint__ProbeHostAdapter(struct FlashPoint_Info *FlashPointInfo) |
| 7580 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7581 | return FlashPoint_ProbeHostAdapter((struct sccb_mgr_info *) |
| 7582 | FlashPointInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7583 | } |
| 7584 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7585 | static inline FlashPoint_CardHandle_T |
| 7586 | FlashPoint__HardwareResetHostAdapter(struct FlashPoint_Info *FlashPointInfo) |
| 7587 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7588 | return FlashPoint_HardwareResetHostAdapter((struct sccb_mgr_info *) |
| 7589 | FlashPointInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7590 | } |
| 7591 | |
| 7592 | static inline void |
| 7593 | FlashPoint__ReleaseHostAdapter(FlashPoint_CardHandle_T CardHandle) |
| 7594 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7595 | FlashPoint_ReleaseHostAdapter(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7596 | } |
| 7597 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7598 | static inline void |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7599 | FlashPoint__StartCCB(FlashPoint_CardHandle_T CardHandle, |
| 7600 | struct BusLogic_CCB *CCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7601 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7602 | FlashPoint_StartCCB(CardHandle, (struct sccb *)CCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7603 | } |
| 7604 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7605 | static inline void |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7606 | FlashPoint__AbortCCB(FlashPoint_CardHandle_T CardHandle, |
| 7607 | struct BusLogic_CCB *CCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7608 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7609 | FlashPoint_AbortCCB(CardHandle, (struct sccb *)CCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7610 | } |
| 7611 | |
Richard Knutsson | 2065e31 | 2007-02-05 16:39:01 -0800 | [diff] [blame] | 7612 | static inline bool |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7613 | FlashPoint__InterruptPending(FlashPoint_CardHandle_T CardHandle) |
| 7614 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7615 | return FlashPoint_InterruptPending(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7616 | } |
| 7617 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7618 | static inline int |
| 7619 | FlashPoint__HandleInterrupt(FlashPoint_CardHandle_T CardHandle) |
| 7620 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7621 | return FlashPoint_HandleInterrupt(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7622 | } |
| 7623 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7624 | #define FlashPoint_ProbeHostAdapter FlashPoint__ProbeHostAdapter |
| 7625 | #define FlashPoint_HardwareResetHostAdapter FlashPoint__HardwareResetHostAdapter |
| 7626 | #define FlashPoint_ReleaseHostAdapter FlashPoint__ReleaseHostAdapter |
| 7627 | #define FlashPoint_StartCCB FlashPoint__StartCCB |
| 7628 | #define FlashPoint_AbortCCB FlashPoint__AbortCCB |
| 7629 | #define FlashPoint_InterruptPending FlashPoint__InterruptPending |
| 7630 | #define FlashPoint_HandleInterrupt FlashPoint__HandleInterrupt |
| 7631 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7632 | #else /* CONFIG_SCSI_OMIT_FLASHPOINT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7633 | |
| 7634 | /* |
| 7635 | Define prototypes for the FlashPoint SCCB Manager Functions. |
| 7636 | */ |
| 7637 | |
| 7638 | extern unsigned char FlashPoint_ProbeHostAdapter(struct FlashPoint_Info *); |
| 7639 | extern FlashPoint_CardHandle_T |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7640 | FlashPoint_HardwareResetHostAdapter(struct FlashPoint_Info *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7641 | extern void FlashPoint_StartCCB(FlashPoint_CardHandle_T, struct BusLogic_CCB *); |
| 7642 | extern int FlashPoint_AbortCCB(FlashPoint_CardHandle_T, struct BusLogic_CCB *); |
Richard Knutsson | 2065e31 | 2007-02-05 16:39:01 -0800 | [diff] [blame] | 7643 | extern bool FlashPoint_InterruptPending(FlashPoint_CardHandle_T); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7644 | extern int FlashPoint_HandleInterrupt(FlashPoint_CardHandle_T); |
| 7645 | extern void FlashPoint_ReleaseHostAdapter(FlashPoint_CardHandle_T); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7646 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7647 | #endif /* CONFIG_SCSI_OMIT_FLASHPOINT */ |