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 | #include <linux/config.h> |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #ifndef CONFIG_SCSI_OMIT_FLASHPOINT |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #define MAX_CARDS 8 |
| 23 | #undef BUSTYPE_PCI |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #define CRCMASK 0xA001 |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #define FAILURE 0xFFFFFFFFL |
| 28 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 29 | #define BIT(x) ((unsigned char)(1<<(x))) /* single-bit mask in bit position x */ |
| 30 | #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] | 31 | |
Alexey Dobriyan | 69eb2ea | 2006-03-08 00:14:29 -0800 | [diff] [blame] | 32 | struct sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 33 | typedef void (*CALL_BK_FN) (struct sccb *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Alexey Dobriyan | 7f10166 | 2006-03-08 00:14:30 -0800 | [diff] [blame] | 35 | struct sccb_mgr_info { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 36 | unsigned long si_baseaddr; |
| 37 | unsigned char si_present; |
| 38 | unsigned char si_intvect; |
| 39 | unsigned char si_id; |
| 40 | unsigned char si_lun; |
| 41 | unsigned short si_fw_revision; |
| 42 | unsigned short si_per_targ_init_sync; |
| 43 | unsigned short si_per_targ_fast_nego; |
| 44 | unsigned short si_per_targ_ultra_nego; |
| 45 | unsigned short si_per_targ_no_disc; |
| 46 | unsigned short si_per_targ_wide_nego; |
| 47 | unsigned short si_flags; |
| 48 | unsigned char si_card_family; |
| 49 | unsigned char si_bustype; |
| 50 | unsigned char si_card_model[3]; |
| 51 | unsigned char si_relative_cardnum; |
| 52 | unsigned char si_reserved[4]; |
| 53 | unsigned long si_OS_reserved; |
| 54 | unsigned char si_XlatInfo[4]; |
| 55 | unsigned long si_reserved2[5]; |
| 56 | unsigned long si_secondary_range; |
Alexey Dobriyan | 7f10166 | 2006-03-08 00:14:30 -0800 | [diff] [blame] | 57 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 59 | #define SCSI_PARITY_ENA 0x0001 |
| 60 | #define LOW_BYTE_TERM 0x0010 |
| 61 | #define HIGH_BYTE_TERM 0x0020 |
| 62 | #define BUSTYPE_PCI 0x3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | #define SUPPORT_16TAR_32LUN 0x0002 |
| 65 | #define SOFT_RESET 0x0004 |
| 66 | #define EXTENDED_TRANSLATION 0x0008 |
| 67 | #define POST_ALL_UNDERRRUNS 0x0040 |
| 68 | #define FLAG_SCAM_ENABLED 0x0080 |
| 69 | #define FLAG_SCAM_LEVEL2 0x0100 |
| 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | #define HARPOON_FAMILY 0x02 |
| 72 | |
Alexey Dobriyan | 32357988 | 2006-01-15 02:12:54 +0100 | [diff] [blame] | 73 | /* SCCB struct used for both SCCB and UCB manager compiles! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | * The UCB Manager treats the SCCB as it's 'native hardware structure' |
| 75 | */ |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | #pragma pack(1) |
Alexey Dobriyan | 69eb2ea | 2006-03-08 00:14:29 -0800 | [diff] [blame] | 78 | struct sccb { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 79 | unsigned char OperationCode; |
| 80 | unsigned char ControlByte; |
| 81 | unsigned char CdbLength; |
| 82 | unsigned char RequestSenseLength; |
| 83 | unsigned long DataLength; |
| 84 | unsigned long DataPointer; |
| 85 | unsigned char CcbRes[2]; |
| 86 | unsigned char HostStatus; |
| 87 | unsigned char TargetStatus; |
| 88 | unsigned char TargID; |
| 89 | unsigned char Lun; |
| 90 | unsigned char Cdb[12]; |
| 91 | unsigned char CcbRes1; |
| 92 | unsigned char Reserved1; |
| 93 | unsigned long Reserved2; |
| 94 | unsigned long SensePointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 96 | CALL_BK_FN SccbCallback; /* VOID (*SccbCallback)(); */ |
| 97 | unsigned long SccbIOPort; /* Identifies board base port */ |
| 98 | unsigned char SccbStatus; |
| 99 | unsigned char SCCBRes2; |
| 100 | unsigned short SccbOSFlags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 102 | unsigned long Sccb_XferCnt; /* actual transfer count */ |
| 103 | unsigned long Sccb_ATC; |
| 104 | unsigned long SccbVirtDataPtr; /* virtual addr for OS/2 */ |
| 105 | unsigned long Sccb_res1; |
| 106 | unsigned short Sccb_MGRFlags; |
| 107 | unsigned short Sccb_sgseg; |
| 108 | unsigned char Sccb_scsimsg; /* identify msg for selection */ |
| 109 | unsigned char Sccb_tag; |
| 110 | unsigned char Sccb_scsistat; |
| 111 | unsigned char Sccb_idmsg; /* image of last msg in */ |
| 112 | struct sccb *Sccb_forwardlink; |
| 113 | struct sccb *Sccb_backlink; |
| 114 | unsigned long Sccb_savedATC; |
| 115 | unsigned char Save_Cdb[6]; |
| 116 | unsigned char Save_CdbLen; |
| 117 | unsigned char Sccb_XferState; |
| 118 | unsigned long Sccb_SGoffset; |
| 119 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | #pragma pack() |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | #define SCATTER_GATHER_COMMAND 0x02 |
| 124 | #define RESIDUAL_COMMAND 0x03 |
| 125 | #define RESIDUAL_SG_COMMAND 0x04 |
| 126 | #define RESET_COMMAND 0x81 |
| 127 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 128 | #define F_USE_CMD_Q 0x20 /*Inidcates TAGGED command. */ |
| 129 | #define TAG_TYPE_MASK 0xC0 /*Type of tag msg to send. */ |
| 130 | #define SCCB_DATA_XFER_OUT 0x10 /* Write */ |
| 131 | #define SCCB_DATA_XFER_IN 0x08 /* Read */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 133 | #define NO_AUTO_REQUEST_SENSE 0x01 /* No Request Sense Buffer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 135 | #define BUS_FREE_ST 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | #define SELECT_ST 1 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 137 | #define SELECT_BDR_ST 2 /* Select w\ Bus Device Reset */ |
| 138 | #define SELECT_SN_ST 3 /* Select w\ Sync Nego */ |
| 139 | #define SELECT_WN_ST 4 /* Select w\ Wide Data Nego */ |
| 140 | #define SELECT_Q_ST 5 /* Select w\ Tagged Q'ing */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | #define COMMAND_ST 6 |
| 142 | #define DATA_OUT_ST 7 |
| 143 | #define DATA_IN_ST 8 |
| 144 | #define DISCONNECT_ST 9 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | #define ABORT_ST 11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | #define F_HOST_XFER_DIR 0x01 |
| 148 | #define F_ALL_XFERRED 0x02 |
| 149 | #define F_SG_XFER 0x04 |
| 150 | #define F_AUTO_SENSE 0x08 |
| 151 | #define F_ODD_BALL_CNT 0x10 |
| 152 | #define F_NO_DATA_YET 0x80 |
| 153 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | #define F_STATUSLOADED 0x01 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | #define F_DEV_SELECTED 0x04 |
| 156 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 157 | #define SCCB_COMPLETE 0x00 /* SCCB completed without error */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | #define SCCB_DATA_UNDER_RUN 0x0C |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 159 | #define SCCB_SELECTION_TIMEOUT 0x11 /* Set SCSI selection timed out */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | #define SCCB_DATA_OVER_RUN 0x12 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 161 | #define SCCB_PHASE_SEQUENCE_FAIL 0x14 /* Target bus phase sequence failure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 163 | #define SCCB_GROSS_FW_ERR 0x27 /* Major problem! */ |
| 164 | #define SCCB_BM_ERR 0x30 /* BusMaster error. */ |
| 165 | #define SCCB_PARITY_ERR 0x34 /* SCSI parity error */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | |
| 167 | #define SCCB_IN_PROCESS 0x00 |
| 168 | #define SCCB_SUCCESS 0x01 |
| 169 | #define SCCB_ABORT 0x02 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | #define SCCB_ERROR 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | #define ORION_FW_REV 3110 |
| 173 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 174 | #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] | 175 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 176 | #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] | 177 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 178 | #define MAX_SCSI_TAR 16 |
| 179 | #define MAX_LUN 32 |
| 180 | #define LUN_MASK 0x1f |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 182 | #define SG_BUF_CNT 16 /*Number of prefetched elements. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 184 | #define SG_ELEMENT_SIZE 8 /*Eight byte per element. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Alexey Dobriyan | ad0e1d9 | 2006-03-08 00:14:28 -0800 | [diff] [blame] | 186 | #define RD_HARPOON(ioport) inb((u32)ioport) |
| 187 | #define RDW_HARPOON(ioport) inw((u32)ioport) |
| 188 | #define RD_HARP32(ioport,offset,data) (data = inl((u32)(ioport + offset))) |
| 189 | #define WR_HARPOON(ioport,val) outb((u8) val, (u32)ioport) |
| 190 | #define WRW_HARPOON(ioport,val) outw((u16)val, (u32)ioport) |
| 191 | #define WR_HARP32(ioport,offset,data) outl(data, (u32)(ioport + offset)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | #define TAR_SYNC_MASK (BIT(7)+BIT(6)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | #define SYNC_TRYING BIT(6) |
| 195 | #define SYNC_SUPPORTED (BIT(7)+BIT(6)) |
| 196 | |
| 197 | #define TAR_WIDE_MASK (BIT(5)+BIT(4)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | #define WIDE_ENABLED BIT(4) |
| 199 | #define WIDE_NEGOCIATED BIT(5) |
| 200 | |
| 201 | #define TAR_TAG_Q_MASK (BIT(3)+BIT(2)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | #define TAG_Q_TRYING BIT(2) |
| 203 | #define TAG_Q_REJECT BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | |
| 205 | #define TAR_ALLOW_DISC BIT(0) |
| 206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | #define EE_SYNC_MASK (BIT(0)+BIT(1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | #define EE_SYNC_5MB BIT(0) |
| 209 | #define EE_SYNC_10MB BIT(1) |
| 210 | #define EE_SYNC_20MB (BIT(0)+BIT(1)) |
| 211 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | #define EE_WIDE_SCSI BIT(7) |
| 213 | |
Alexey Dobriyan | f31dc0c | 2006-03-08 00:14:31 -0800 | [diff] [blame] | 214 | struct sccb_mgr_tar_info { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 216 | struct sccb *TarSelQ_Head; |
| 217 | struct sccb *TarSelQ_Tail; |
| 218 | unsigned char TarLUN_CA; /*Contingent Allgiance */ |
| 219 | unsigned char TarTagQ_Cnt; |
| 220 | unsigned char TarSelQ_Cnt; |
| 221 | unsigned char TarStatus; |
| 222 | unsigned char TarEEValue; |
| 223 | unsigned char TarSyncCtrl; |
| 224 | unsigned char TarReserved[2]; /* for alignment */ |
| 225 | unsigned char LunDiscQ_Idx[MAX_LUN]; |
| 226 | unsigned char TarLUNBusy[MAX_LUN]; |
Alexey Dobriyan | f31dc0c | 2006-03-08 00:14:31 -0800 | [diff] [blame] | 227 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
Alexey Dobriyan | 68d0c1a | 2006-03-08 00:14:33 -0800 | [diff] [blame] | 229 | struct nvram_info { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 230 | unsigned char niModel; /* Model No. of card */ |
| 231 | unsigned char niCardNo; /* Card no. */ |
| 232 | unsigned long niBaseAddr; /* Port Address of card */ |
| 233 | unsigned char niSysConf; /* Adapter Configuration byte - Byte 16 of eeprom map */ |
| 234 | unsigned char niScsiConf; /* SCSI Configuration byte - Byte 17 of eeprom map */ |
| 235 | unsigned char niScamConf; /* SCAM Configuration byte - Byte 20 of eeprom map */ |
| 236 | unsigned char niAdapId; /* Host Adapter ID - Byte 24 of eerpom map */ |
| 237 | unsigned char niSyncTbl[MAX_SCSI_TAR / 2]; /* Sync/Wide byte of targets */ |
| 238 | 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] | 239 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | #define MODEL_LT 1 |
| 242 | #define MODEL_DL 2 |
| 243 | #define MODEL_LW 3 |
| 244 | #define MODEL_DW 4 |
| 245 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 246 | struct sccb_card { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 247 | struct sccb *currentSCCB; |
| 248 | struct sccb_mgr_info *cardInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 250 | unsigned long ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 252 | unsigned short cmdCounter; |
| 253 | unsigned char discQCount; |
| 254 | unsigned char tagQ_Lst; |
| 255 | unsigned char cardIndex; |
| 256 | unsigned char scanIndex; |
| 257 | unsigned char globalFlags; |
| 258 | unsigned char ourId; |
| 259 | struct nvram_info *pNvRamInfo; |
| 260 | struct sccb *discQ_Tbl[QUEUE_DEPTH]; |
| 261 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 262 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | #define F_TAG_STARTED 0x01 |
| 265 | #define F_CONLUN_IO 0x02 |
| 266 | #define F_DO_RENEGO 0x04 |
| 267 | #define F_NO_FILTER 0x08 |
| 268 | #define F_GREEN_PC 0x10 |
| 269 | #define F_HOST_XFER_ACT 0x20 |
| 270 | #define F_NEW_SCCB_CMD 0x40 |
| 271 | #define F_UPDATE_EEPROM 0x80 |
| 272 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | #define ID_STRING_LENGTH 32 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 274 | #define TYPE_CODE0 0x63 /*Level2 Mstr (bits 7-6), */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 276 | #define SLV_TYPE_CODE0 0xA3 /*Priority Bit set (bits 7-6), */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
| 278 | #define ASSIGN_ID 0x00 |
| 279 | #define SET_P_FLAG 0x01 |
| 280 | #define CFG_CMPLT 0x03 |
| 281 | #define DOM_MSTR 0x0F |
| 282 | #define SYNC_PTRN 0x1F |
| 283 | |
| 284 | #define ID_0_7 0x18 |
| 285 | #define ID_8_F 0x11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | #define MISC_CODE 0x14 |
| 287 | #define CLR_P_FLAG 0x18 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | #define INIT_SELTD 0x01 |
| 290 | #define LEVEL2_TAR 0x02 |
| 291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 292 | enum scam_id_st { ID0, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, ID9, ID10, ID11, |
| 293 | ID12, |
| 294 | ID13, ID14, ID15, ID_UNUSED, ID_UNASSIGNED, ID_ASSIGNED, LEGACY, |
| 295 | CLR_PRIORITY, NO_ID_AVAIL |
| 296 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
| 298 | typedef struct SCCBscam_info { |
| 299 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 300 | unsigned char id_string[ID_STRING_LENGTH]; |
| 301 | enum scam_id_st state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 303 | } SCCBSCAM_INFO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | #define SCSI_REQUEST_SENSE 0x03 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | #define SCSI_READ 0x08 |
| 307 | #define SCSI_WRITE 0x0A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | #define SCSI_START_STOP_UNIT 0x1B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | #define SCSI_READ_EXTENDED 0x28 |
| 310 | #define SCSI_WRITE_EXTENDED 0x2A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | #define SCSI_WRITE_AND_VERIFY 0x2E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | #define SSGOOD 0x00 |
| 314 | #define SSCHECK 0x02 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | #define SSQ_FULL 0x28 |
| 316 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | #define SMCMD_COMP 0x00 |
| 318 | #define SMEXT 0x01 |
| 319 | #define SMSAVE_DATA_PTR 0x02 |
| 320 | #define SMREST_DATA_PTR 0x03 |
| 321 | #define SMDISC 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | #define SMABORT 0x06 |
| 323 | #define SMREJECT 0x07 |
| 324 | #define SMNO_OP 0x08 |
| 325 | #define SMPARITY 0x09 |
| 326 | #define SMDEV_RESET 0x0C |
| 327 | #define SMABORT_TAG 0x0D |
| 328 | #define SMINIT_RECOVERY 0x0F |
| 329 | #define SMREL_RECOVERY 0x10 |
| 330 | |
| 331 | #define SMIDENT 0x80 |
| 332 | #define DISC_PRIV 0x40 |
| 333 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | #define SMSYNC 0x01 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | #define SMWDTR 0x03 |
| 336 | #define SM8BIT 0x00 |
| 337 | #define SM16BIT 0x01 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 338 | #define SMIGNORWR 0x23 /* Ignore Wide Residue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
| 340 | #define SIX_BYTE_CMD 0x06 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | #define TWELVE_BYTE_CMD 0x0C |
| 342 | |
| 343 | #define ASYNC 0x00 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 344 | #define MAX_OFFSET 0x0F /* Maxbyteoffset for Sync Xfers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
| 346 | #define EEPROM_WD_CNT 256 |
| 347 | |
| 348 | #define EEPROM_CHECK_SUM 0 |
| 349 | #define FW_SIGNATURE 2 |
| 350 | #define MODEL_NUMB_0 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | #define MODEL_NUMB_2 6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | #define MODEL_NUMB_4 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | #define SYSTEM_CONFIG 16 |
| 354 | #define SCSI_CONFIG 17 |
| 355 | #define BIOS_CONFIG 18 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | #define SCAM_CONFIG 20 |
| 357 | #define ADAPTER_SCSI_ID 24 |
| 358 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | #define IGNORE_B_SCAN 32 |
| 360 | #define SEND_START_ENA 34 |
| 361 | #define DEVICE_ENABLE 36 |
| 362 | |
| 363 | #define SYNC_RATE_TBL 38 |
| 364 | #define SYNC_RATE_TBL01 38 |
| 365 | #define SYNC_RATE_TBL23 40 |
| 366 | #define SYNC_RATE_TBL45 42 |
| 367 | #define SYNC_RATE_TBL67 44 |
| 368 | #define SYNC_RATE_TBL89 46 |
| 369 | #define SYNC_RATE_TBLab 48 |
| 370 | #define SYNC_RATE_TBLcd 50 |
| 371 | #define SYNC_RATE_TBLef 52 |
| 372 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 373 | #define EE_SCAMBASE 256 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 375 | #define SCAM_ENABLED BIT(2) |
| 376 | #define SCAM_LEVEL2 BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 378 | #define RENEGO_ENA BITW(10) |
| 379 | #define CONNIO_ENA BITW(11) |
| 380 | #define GREEN_PC_ENA BITW(12) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 382 | #define AUTO_RATE_00 00 |
| 383 | #define AUTO_RATE_05 01 |
| 384 | #define AUTO_RATE_10 02 |
| 385 | #define AUTO_RATE_20 03 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 387 | #define WIDE_NEGO_BIT BIT(7) |
| 388 | #define DISC_ENABLE_BIT BIT(6) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 390 | #define hp_vendor_id_0 0x00 /* LSB */ |
| 391 | #define ORION_VEND_0 0x4B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 393 | #define hp_vendor_id_1 0x01 /* MSB */ |
| 394 | #define ORION_VEND_1 0x10 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 396 | #define hp_device_id_0 0x02 /* LSB */ |
| 397 | #define ORION_DEV_0 0x30 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 399 | #define hp_device_id_1 0x03 /* MSB */ |
| 400 | #define ORION_DEV_1 0x81 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
| 402 | /* Sub Vendor ID and Sub Device ID only available in |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 403 | Harpoon Version 2 and higher */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 405 | #define hp_sub_device_id_0 0x06 /* LSB */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 407 | #define hp_semaphore 0x0C |
| 408 | #define SCCB_MGR_ACTIVE BIT(0) |
| 409 | #define TICKLE_ME BIT(1) |
| 410 | #define SCCB_MGR_PRESENT BIT(3) |
| 411 | #define BIOS_IN_USE BIT(4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 413 | #define hp_sys_ctrl 0x0F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 415 | #define STOP_CLK BIT(0) /*Turn off BusMaster Clock */ |
| 416 | #define DRVR_RST BIT(1) /*Firmware Reset to 80C15 chip */ |
| 417 | #define HALT_MACH BIT(3) /*Halt State Machine */ |
| 418 | #define HARD_ABORT BIT(4) /*Hard Abort */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 420 | #define hp_host_blk_cnt 0x13 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 422 | #define XFER_BLK64 0x06 /* 1 1 0 64 byte per block */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 424 | #define BM_THRESHOLD 0x40 /* PCI mode can only xfer 16 bytes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 426 | #define hp_int_mask 0x17 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 428 | #define INT_CMD_COMPL BIT(0) /* DMA command complete */ |
| 429 | #define INT_EXT_STATUS BIT(1) /* Extended Status Set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 431 | #define hp_xfer_cnt_lo 0x18 |
| 432 | #define hp_xfer_cnt_hi 0x1A |
| 433 | #define hp_xfer_cmd 0x1B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 435 | #define XFER_HOST_DMA 0x00 /* 0 0 0 Transfer Host -> DMA */ |
| 436 | #define XFER_DMA_HOST 0x01 /* 0 0 1 Transfer DMA -> Host */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 438 | #define XFER_HOST_AUTO 0x00 /* 0 0 Auto Transfer Size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 440 | #define XFER_DMA_8BIT 0x20 /* 0 1 8 BIT Transfer Size */ |
Alexey Dobriyan | 85ae97d | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 442 | #define DISABLE_INT BIT(7) /*Do not interrupt at end of cmd. */ |
Alexey Dobriyan | 85ae97d | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 443 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 444 | #define HOST_WRT_CMD ((DISABLE_INT + XFER_HOST_DMA + XFER_HOST_AUTO + XFER_DMA_8BIT)) |
| 445 | #define HOST_RD_CMD ((DISABLE_INT + XFER_DMA_HOST + XFER_HOST_AUTO + XFER_DMA_8BIT)) |
Alexey Dobriyan | 85ae97d | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 446 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 447 | #define hp_host_addr_lo 0x1C |
| 448 | #define hp_host_addr_hmi 0x1E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 450 | #define hp_ee_ctrl 0x22 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 452 | #define EXT_ARB_ACK BIT(7) |
| 453 | #define SCSI_TERM_ENA_H BIT(6) /* SCSI high byte terminator */ |
| 454 | #define SEE_MS BIT(5) |
| 455 | #define SEE_CS BIT(3) |
| 456 | #define SEE_CLK BIT(2) |
| 457 | #define SEE_DO BIT(1) |
| 458 | #define SEE_DI BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 460 | #define EE_READ 0x06 |
| 461 | #define EE_WRITE 0x05 |
| 462 | #define EWEN 0x04 |
| 463 | #define EWEN_ADDR 0x03C0 |
| 464 | #define EWDS 0x04 |
| 465 | #define EWDS_ADDR 0x0000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 467 | #define hp_bm_ctrl 0x26 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 469 | #define SCSI_TERM_ENA_L BIT(0) /*Enable/Disable external terminators */ |
| 470 | #define FLUSH_XFER_CNTR BIT(1) /*Flush transfer counter */ |
| 471 | #define FORCE1_XFER BIT(5) /*Always xfer one byte in byte mode */ |
| 472 | #define FAST_SINGLE BIT(6) /*?? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 474 | #define BMCTRL_DEFAULT (FORCE1_XFER|FAST_SINGLE|SCSI_TERM_ENA_L) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 476 | #define hp_sg_addr 0x28 |
| 477 | #define hp_page_ctrl 0x29 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 479 | #define SCATTER_EN BIT(0) |
| 480 | #define SGRAM_ARAM BIT(1) |
| 481 | #define G_INT_DISABLE BIT(3) /* Enable/Disable all Interrupts */ |
| 482 | #define NARROW_SCSI_CARD BIT(4) /* NARROW/WIDE SCSI config pin */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 484 | #define hp_pci_stat_cfg 0x2D |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 486 | #define REC_MASTER_ABORT BIT(5) /*received Master abort */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 488 | #define hp_rev_num 0x33 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 490 | #define hp_stack_data 0x34 |
| 491 | #define hp_stack_addr 0x35 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 493 | #define hp_ext_status 0x36 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 495 | #define BM_FORCE_OFF BIT(0) /*Bus Master is forced to get off */ |
| 496 | #define PCI_TGT_ABORT BIT(0) /*PCI bus master transaction aborted */ |
| 497 | #define PCI_DEV_TMOUT BIT(1) /*PCI Device Time out */ |
| 498 | #define CMD_ABORTED BIT(4) /*Command aborted */ |
| 499 | #define BM_PARITY_ERR BIT(5) /*parity error on data received */ |
| 500 | #define PIO_OVERRUN BIT(6) /*Slave data overrun */ |
| 501 | #define BM_CMD_BUSY BIT(7) /*Bus master transfer command busy */ |
| 502 | #define BAD_EXT_STATUS (BM_FORCE_OFF | PCI_DEV_TMOUT | CMD_ABORTED | \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | BM_PARITY_ERR | PIO_OVERRUN) |
| 504 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 505 | #define hp_int_status 0x37 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 507 | #define EXT_STATUS_ON BIT(1) /*Extended status is valid */ |
| 508 | #define SCSI_INTERRUPT BIT(2) /*Global indication of a SCSI int. */ |
| 509 | #define INT_ASSERTED BIT(5) /* */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 511 | #define hp_fifo_cnt 0x38 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 513 | #define hp_intena 0x40 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 515 | #define RESET BITW(7) |
| 516 | #define PROG_HLT BITW(6) |
| 517 | #define PARITY BITW(5) |
| 518 | #define FIFO BITW(4) |
| 519 | #define SEL BITW(3) |
| 520 | #define SCAM_SEL BITW(2) |
| 521 | #define RSEL BITW(1) |
| 522 | #define TIMEOUT BITW(0) |
| 523 | #define BUS_FREE BITW(15) |
| 524 | #define XFER_CNT_0 BITW(14) |
| 525 | #define PHASE BITW(13) |
| 526 | #define IUNKWN BITW(12) |
| 527 | #define ICMD_COMP BITW(11) |
| 528 | #define ITICKLE BITW(10) |
| 529 | #define IDO_STRT BITW(9) |
| 530 | #define ITAR_DISC BITW(8) |
| 531 | #define AUTO_INT (BITW(12)+BITW(11)+BITW(10)+BITW(9)+BITW(8)) |
| 532 | #define CLR_ALL_INT 0xFFFF |
| 533 | #define CLR_ALL_INT_1 0xFF00 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 535 | #define hp_intstat 0x42 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 537 | #define hp_scsisig 0x44 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 539 | #define SCSI_SEL BIT(7) |
| 540 | #define SCSI_BSY BIT(6) |
| 541 | #define SCSI_REQ BIT(5) |
| 542 | #define SCSI_ACK BIT(4) |
| 543 | #define SCSI_ATN BIT(3) |
| 544 | #define SCSI_CD BIT(2) |
| 545 | #define SCSI_MSG BIT(1) |
| 546 | #define SCSI_IOBIT BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 548 | #define S_SCSI_PHZ (BIT(2)+BIT(1)+BIT(0)) |
| 549 | #define S_MSGO_PH (BIT(2)+BIT(1) ) |
| 550 | #define S_MSGI_PH (BIT(2)+BIT(1)+BIT(0)) |
| 551 | #define S_DATAI_PH ( BIT(0)) |
| 552 | #define S_DATAO_PH 0x00 |
| 553 | #define S_ILL_PH ( BIT(1) ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 555 | #define hp_scsictrl_0 0x45 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 557 | #define SEL_TAR BIT(6) |
| 558 | #define ENA_ATN BIT(4) |
| 559 | #define ENA_RESEL BIT(2) |
| 560 | #define SCSI_RST BIT(1) |
| 561 | #define ENA_SCAM_SEL BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 563 | #define hp_portctrl_0 0x46 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 565 | #define SCSI_PORT BIT(7) |
| 566 | #define SCSI_INBIT BIT(6) |
| 567 | #define DMA_PORT BIT(5) |
| 568 | #define DMA_RD BIT(4) |
| 569 | #define HOST_PORT BIT(3) |
| 570 | #define HOST_WRT BIT(2) |
| 571 | #define SCSI_BUS_EN BIT(1) |
| 572 | #define START_TO BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 574 | #define hp_scsireset 0x47 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 576 | #define SCSI_INI BIT(6) |
| 577 | #define SCAM_EN BIT(5) |
| 578 | #define DMA_RESET BIT(3) |
| 579 | #define HPSCSI_RESET BIT(2) |
| 580 | #define PROG_RESET BIT(1) |
| 581 | #define FIFO_CLR BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 583 | #define hp_xfercnt_0 0x48 |
| 584 | #define hp_xfercnt_2 0x4A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 586 | #define hp_fifodata_0 0x4C |
| 587 | #define hp_addstat 0x4E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 589 | #define SCAM_TIMER BIT(7) |
| 590 | #define SCSI_MODE8 BIT(3) |
| 591 | #define SCSI_PAR_ERR BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 593 | #define hp_prgmcnt_0 0x4F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 595 | #define hp_selfid_0 0x50 |
| 596 | #define hp_selfid_1 0x51 |
| 597 | #define hp_arb_id 0x52 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 599 | #define hp_select_id 0x53 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 601 | #define hp_synctarg_base 0x54 |
| 602 | #define hp_synctarg_12 0x54 |
| 603 | #define hp_synctarg_13 0x55 |
| 604 | #define hp_synctarg_14 0x56 |
| 605 | #define hp_synctarg_15 0x57 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 607 | #define hp_synctarg_8 0x58 |
| 608 | #define hp_synctarg_9 0x59 |
| 609 | #define hp_synctarg_10 0x5A |
| 610 | #define hp_synctarg_11 0x5B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 612 | #define hp_synctarg_4 0x5C |
| 613 | #define hp_synctarg_5 0x5D |
| 614 | #define hp_synctarg_6 0x5E |
| 615 | #define hp_synctarg_7 0x5F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 617 | #define hp_synctarg_0 0x60 |
| 618 | #define hp_synctarg_1 0x61 |
| 619 | #define hp_synctarg_2 0x62 |
| 620 | #define hp_synctarg_3 0x63 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 622 | #define NARROW_SCSI BIT(4) |
| 623 | #define DEFAULT_OFFSET 0x0F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 625 | #define hp_autostart_0 0x64 |
| 626 | #define hp_autostart_1 0x65 |
| 627 | #define hp_autostart_3 0x67 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 629 | #define AUTO_IMMED BIT(5) |
| 630 | #define SELECT BIT(6) |
| 631 | #define END_DATA (BIT(7)+BIT(6)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 633 | #define hp_gp_reg_0 0x68 |
| 634 | #define hp_gp_reg_1 0x69 |
| 635 | #define hp_gp_reg_3 0x6B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 637 | #define hp_seltimeout 0x6C |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 639 | #define TO_4ms 0x67 /* 3.9959ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 641 | #define TO_5ms 0x03 /* 4.9152ms */ |
| 642 | #define TO_10ms 0x07 /* 11.xxxms */ |
| 643 | #define TO_250ms 0x99 /* 250.68ms */ |
| 644 | #define TO_290ms 0xB1 /* 289.99ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 646 | #define hp_clkctrl_0 0x6D |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 648 | #define PWR_DWN BIT(6) |
| 649 | #define ACTdeassert BIT(4) |
| 650 | #define CLK_40MHZ (BIT(1) + BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 652 | #define CLKCTRL_DEFAULT (ACTdeassert | CLK_40MHZ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 654 | #define hp_fiforead 0x6E |
| 655 | #define hp_fifowrite 0x6F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 657 | #define hp_offsetctr 0x70 |
| 658 | #define hp_xferstat 0x71 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 660 | #define FIFO_EMPTY BIT(6) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 662 | #define hp_portctrl_1 0x72 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 664 | #define CHK_SCSI_P BIT(3) |
| 665 | #define HOST_MODE8 BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 667 | #define hp_xfer_pad 0x73 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 669 | #define ID_UNLOCK BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 671 | #define hp_scsidata_0 0x74 |
| 672 | #define hp_scsidata_1 0x75 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 674 | #define hp_aramBase 0x80 |
| 675 | #define BIOS_DATA_OFFSET 0x60 |
| 676 | #define BIOS_RELATIVE_CARD 0x64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 678 | #define AR3 (BITW(9) + BITW(8)) |
| 679 | #define SDATA BITW(10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 681 | #define CRD_OP BITW(11) /* Cmp Reg. w/ Data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 683 | #define CRR_OP BITW(12) /* Cmp Reg. w. Reg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 685 | #define CPE_OP (BITW(14)+BITW(11)) /* Cmp SCSI phs & Branch EQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 687 | #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] | 688 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 689 | #define ADATA_OUT 0x00 |
| 690 | #define ADATA_IN BITW(8) |
| 691 | #define ACOMMAND BITW(10) |
| 692 | #define ASTATUS (BITW(10)+BITW(8)) |
| 693 | #define AMSG_OUT (BITW(10)+BITW(9)) |
| 694 | #define AMSG_IN (BITW(10)+BITW(9)+BITW(8)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 696 | #define BRH_OP BITW(13) /* Branch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 698 | #define ALWAYS 0x00 |
| 699 | #define EQUAL BITW(8) |
| 700 | #define NOT_EQ BITW(9) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 702 | #define TCB_OP (BITW(13)+BITW(11)) /* Test condition & branch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 704 | #define FIFO_0 BITW(10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 706 | #define MPM_OP BITW(15) /* Match phase and move data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 708 | #define MRR_OP BITW(14) /* Move DReg. to Reg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 710 | #define S_IDREG (BIT(2)+BIT(1)+BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 712 | #define D_AR0 0x00 |
| 713 | #define D_AR1 BIT(0) |
| 714 | #define D_BUCKET (BIT(2) + BIT(1) + BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 716 | #define RAT_OP (BITW(14)+BITW(13)+BITW(11)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 718 | #define SSI_OP (BITW(15)+BITW(11)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 720 | #define SSI_ITAR_DISC (ITAR_DISC >> 8) |
| 721 | #define SSI_IDO_STRT (IDO_STRT >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 723 | #define SSI_ICMD_COMP (ICMD_COMP >> 8) |
| 724 | #define SSI_ITICKLE (ITICKLE >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 726 | #define SSI_IUNKWN (IUNKWN >> 8) |
| 727 | #define SSI_INO_CC (IUNKWN >> 8) |
| 728 | #define SSI_IRFAIL (IUNKWN >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 730 | #define NP 0x10 /*Next Phase */ |
| 731 | #define NTCMD 0x02 /*Non- Tagged Command start */ |
| 732 | #define CMDPZ 0x04 /*Command phase */ |
| 733 | #define DINT 0x12 /*Data Out/In interrupt */ |
| 734 | #define DI 0x13 /*Data Out */ |
| 735 | #define DC 0x19 /*Disconnect Message */ |
| 736 | #define ST 0x1D /*Status Phase */ |
| 737 | #define UNKNWN 0x24 /*Unknown bus action */ |
| 738 | #define CC 0x25 /*Command Completion failure */ |
| 739 | #define TICK 0x26 /*New target reselected us. */ |
| 740 | #define SELCHK 0x28 /*Select & Check SCSI ID latch reg */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 742 | #define ID_MSG_STRT hp_aramBase + 0x00 |
| 743 | #define NON_TAG_ID_MSG hp_aramBase + 0x06 |
| 744 | #define CMD_STRT hp_aramBase + 0x08 |
| 745 | #define SYNC_MSGS hp_aramBase + 0x08 |
Alexey Dobriyan | 85ae97d | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 746 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 747 | #define TAG_STRT 0x00 |
| 748 | #define DISCONNECT_START 0x10/2 |
| 749 | #define END_DATA_START 0x14/2 |
| 750 | #define CMD_ONLY_STRT CMDPZ/2 |
| 751 | #define SELCHK_STRT SELCHK/2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | |
| 753 | #define GET_XFER_CNT(port, xfercnt) {RD_HARP32(port,hp_xfercnt_0,xfercnt); xfercnt &= 0xFFFFFF;} |
| 754 | /* #define GET_XFER_CNT(port, xfercnt) (xfercnt = RD_HARPOON(port+hp_xfercnt_2), \ |
| 755 | xfercnt <<= 16,\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 756 | xfercnt |= RDW_HARPOON((unsigned short)(port+hp_xfercnt_0))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | */ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 758 | #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] | 759 | addr >>= 16,\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 760 | WRW_HARPOON((port+hp_host_addr_hmi), (unsigned short)(addr & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | WR_HARP32(port,hp_xfercnt_0,count),\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 762 | WRW_HARPOON((port+hp_xfer_cnt_lo), (unsigned short)(count & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | count >>= 16,\ |
| 764 | WR_HARPOON(port+hp_xfer_cnt_hi, (count & 0xFF))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | |
| 766 | #define ACCEPT_MSG(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\ |
| 767 | WR_HARPOON(port+hp_scsisig, S_ILL_PH);} |
| 768 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | #define ACCEPT_MSG_ATN(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\ |
| 770 | WR_HARPOON(port+hp_scsisig, (S_ILL_PH|SCSI_ATN));} |
| 771 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | #define DISABLE_AUTO(port) (WR_HARPOON(port+hp_scsireset, PROG_RESET),\ |
| 773 | WR_HARPOON(port+hp_scsireset, 0x00)) |
| 774 | |
| 775 | #define ARAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 776 | (RD_HARPOON(p_port+hp_page_ctrl) | SGRAM_ARAM))) |
| 777 | |
| 778 | #define SGRAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 779 | (RD_HARPOON(p_port+hp_page_ctrl) & ~SGRAM_ARAM))) |
| 780 | |
| 781 | #define MDISABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 782 | (RD_HARPOON(p_port+hp_page_ctrl) | G_INT_DISABLE))) |
| 783 | |
| 784 | #define MENABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 785 | (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE))) |
| 786 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 787 | static unsigned char FPT_sisyncn(unsigned long port, unsigned char p_card, |
| 788 | unsigned char syncFlag); |
| 789 | static void FPT_ssel(unsigned long port, unsigned char p_card); |
| 790 | static void FPT_sres(unsigned long port, unsigned char p_card, |
| 791 | struct sccb_card *pCurrCard); |
| 792 | static void FPT_shandem(unsigned long port, unsigned char p_card, |
| 793 | struct sccb *pCurrSCCB); |
| 794 | static void FPT_stsyncn(unsigned long port, unsigned char p_card); |
| 795 | static void FPT_sisyncr(unsigned long port, unsigned char sync_pulse, |
| 796 | unsigned char offset); |
| 797 | static void FPT_sssyncv(unsigned long p_port, unsigned char p_id, |
| 798 | unsigned char p_sync_value, |
| 799 | struct sccb_mgr_tar_info *currTar_Info); |
| 800 | static void FPT_sresb(unsigned long port, unsigned char p_card); |
| 801 | static void FPT_sxfrp(unsigned long p_port, unsigned char p_card); |
| 802 | static void FPT_schkdd(unsigned long port, unsigned char p_card); |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 803 | static unsigned char FPT_RdStack(unsigned long port, unsigned char index); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 804 | static void FPT_WrStack(unsigned long portBase, unsigned char index, |
| 805 | unsigned char data); |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 806 | static unsigned char FPT_ChkIfChipInitialized(unsigned long ioPort); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 808 | static void FPT_SendMsg(unsigned long port, unsigned char message); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 809 | static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg, |
| 810 | unsigned char error_code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 812 | static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card); |
| 813 | static void FPT_RNVRamData(struct nvram_info *pNvRamInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 815 | static unsigned char FPT_siwidn(unsigned long port, unsigned char p_card); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 816 | static void FPT_stwidn(unsigned long port, unsigned char p_card); |
| 817 | static void FPT_siwidr(unsigned long port, unsigned char width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 819 | static void FPT_queueSelectFail(struct sccb_card *pCurrCard, |
| 820 | unsigned char p_card); |
| 821 | static void FPT_queueDisconnect(struct sccb *p_SCCB, unsigned char p_card); |
| 822 | static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, |
| 823 | struct sccb *p_SCCB, unsigned char p_card); |
| 824 | static void FPT_queueSearchSelect(struct sccb_card *pCurrCard, |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 825 | unsigned char p_card); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 826 | static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code); |
| 827 | static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char card); |
| 828 | static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB, |
| 829 | unsigned char p_card); |
| 830 | static void FPT_utilUpdateResidual(struct sccb *p_SCCB); |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 831 | static unsigned short FPT_CalcCrc16(unsigned char buffer[]); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 832 | static unsigned char FPT_CalcLrc(unsigned char buffer[]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 833 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 834 | static void FPT_Wait1Second(unsigned long p_port); |
| 835 | static void FPT_Wait(unsigned long p_port, unsigned char p_delay); |
| 836 | static void FPT_utilEEWriteOnOff(unsigned long p_port, unsigned char p_mode); |
| 837 | static void FPT_utilEEWrite(unsigned long p_port, unsigned short ee_data, |
| 838 | unsigned short ee_addr); |
| 839 | static unsigned short FPT_utilEERead(unsigned long p_port, |
| 840 | unsigned short ee_addr); |
| 841 | static unsigned short FPT_utilEEReadOrg(unsigned long p_port, |
| 842 | unsigned short ee_addr); |
| 843 | static void FPT_utilEESendCmdAddr(unsigned long p_port, unsigned char ee_cmd, |
| 844 | unsigned short ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 846 | static void FPT_phaseDataOut(unsigned long port, unsigned char p_card); |
| 847 | static void FPT_phaseDataIn(unsigned long port, unsigned char p_card); |
| 848 | static void FPT_phaseCommand(unsigned long port, unsigned char p_card); |
| 849 | static void FPT_phaseStatus(unsigned long port, unsigned char p_card); |
| 850 | static void FPT_phaseMsgOut(unsigned long port, unsigned char p_card); |
| 851 | static void FPT_phaseMsgIn(unsigned long port, unsigned char p_card); |
| 852 | static void FPT_phaseIllegal(unsigned long port, unsigned char p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 854 | static void FPT_phaseDecode(unsigned long port, unsigned char p_card); |
| 855 | static void FPT_phaseChkFifo(unsigned long port, unsigned char p_card); |
| 856 | static void FPT_phaseBusFree(unsigned long p_port, unsigned char p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 858 | static void FPT_XbowInit(unsigned long port, unsigned char scamFlg); |
| 859 | static void FPT_BusMasterInit(unsigned long p_port); |
| 860 | static void FPT_DiagEEPROM(unsigned long p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 862 | static void FPT_dataXferProcessor(unsigned long port, |
| 863 | struct sccb_card *pCurrCard); |
| 864 | static void FPT_busMstrSGDataXferStart(unsigned long port, |
| 865 | struct sccb *pCurrSCCB); |
| 866 | static void FPT_busMstrDataXferStart(unsigned long port, |
| 867 | struct sccb *pCurrSCCB); |
| 868 | static void FPT_hostDataXferAbort(unsigned long port, unsigned char p_card, |
| 869 | struct sccb *pCurrSCCB); |
| 870 | static void FPT_hostDataXferRestart(struct sccb *currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 872 | static unsigned char FPT_SccbMgr_bad_isr(unsigned long p_port, |
| 873 | unsigned char p_card, |
| 874 | struct sccb_card *pCurrCard, |
| 875 | unsigned short p_int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 877 | static void FPT_SccbMgrTableInitAll(void); |
| 878 | static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard, |
| 879 | unsigned char p_card); |
| 880 | static void FPT_SccbMgrTableInitTarget(unsigned char p_card, |
| 881 | unsigned char target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 883 | static void FPT_scini(unsigned char p_card, unsigned char p_our_id, |
| 884 | unsigned char p_power_up); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 886 | static int FPT_scarb(unsigned long p_port, unsigned char p_sel_type); |
| 887 | static void FPT_scbusf(unsigned long p_port); |
| 888 | static void FPT_scsel(unsigned long p_port); |
| 889 | static void FPT_scasid(unsigned char p_card, unsigned long p_port); |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 890 | 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] | 891 | static unsigned char FPT_scsendi(unsigned long p_port, |
| 892 | unsigned char p_id_string[]); |
| 893 | static unsigned char FPT_sciso(unsigned long p_port, |
| 894 | unsigned char p_id_string[]); |
| 895 | static void FPT_scwirod(unsigned long p_port, unsigned char p_data_bit); |
| 896 | 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] | 897 | static unsigned char FPT_scvalq(unsigned char p_quintet); |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 898 | 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] | 899 | static void FPT_scwtsel(unsigned long p_port); |
| 900 | static void FPT_inisci(unsigned char p_card, unsigned long p_port, |
| 901 | unsigned char p_our_id); |
| 902 | static void FPT_scsavdi(unsigned char p_card, unsigned long p_port); |
| 903 | static unsigned char FPT_scmachid(unsigned char p_card, |
| 904 | unsigned char p_id_string[]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 906 | static void FPT_autoCmdCmplt(unsigned long p_port, unsigned char p_card); |
| 907 | static void FPT_autoLoadDefaultMap(unsigned long p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 909 | static struct sccb_mgr_tar_info FPT_sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR] = |
| 910 | { {{0}} }; |
| 911 | static struct sccb_card FPT_BL_Card[MAX_CARDS] = { {0} }; |
| 912 | static SCCBSCAM_INFO FPT_scamInfo[MAX_SCSI_TAR] = { {{0}} }; |
| 913 | static struct nvram_info FPT_nvRamInfo[MAX_MB_CARDS] = { {0} }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 915 | static unsigned char FPT_mbCards = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 916 | static unsigned char FPT_scamHAString[] = |
| 917 | { 0x63, 0x07, 'B', 'U', 'S', 'L', 'O', 'G', 'I', 'C', |
| 918 | ' ', 'B', 'T', '-', '9', '3', '0', |
| 919 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 920 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 |
| 921 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 923 | static unsigned short FPT_default_intena = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 925 | static void (*FPT_s_PhaseTbl[8]) (unsigned long, unsigned char) = { |
| 926 | 0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | |
| 928 | /*--------------------------------------------------------------------- |
| 929 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 930 | * Function: FlashPoint_ProbeHostAdapter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | * |
| 932 | * Description: Setup and/or Search for cards and return info to caller. |
| 933 | * |
| 934 | *---------------------------------------------------------------------*/ |
| 935 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 936 | static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 938 | static unsigned char first_time = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 940 | unsigned char i, j, id, ScamFlg; |
| 941 | unsigned short temp, temp2, temp3, temp4, temp5, temp6; |
| 942 | unsigned long ioport; |
| 943 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 945 | ioport = pCardInfo->si_baseaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 947 | if (RD_HARPOON(ioport + hp_vendor_id_0) != ORION_VEND_0) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 948 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 950 | if ((RD_HARPOON(ioport + hp_vendor_id_1) != ORION_VEND_1)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 951 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 953 | if ((RD_HARPOON(ioport + hp_device_id_0) != ORION_DEV_0)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 954 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 956 | if ((RD_HARPOON(ioport + hp_device_id_1) != ORION_DEV_1)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 957 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 959 | if (RD_HARPOON(ioport + hp_rev_num) != 0x0f) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | |
| 961 | /* For new Harpoon then check for sub_device ID LSB |
| 962 | the bits(0-3) must be all ZERO for compatible with |
| 963 | current version of SCCBMgr, else skip this Harpoon |
| 964 | device. */ |
| 965 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 966 | if (RD_HARPOON(ioport + hp_sub_device_id_0) & 0x0f) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 967 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | } |
| 969 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 970 | if (first_time) { |
| 971 | FPT_SccbMgrTableInitAll(); |
| 972 | first_time = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 973 | FPT_mbCards = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 974 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 976 | if (FPT_RdStack(ioport, 0) != 0x00) { |
| 977 | if (FPT_ChkIfChipInitialized(ioport) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | pCurrNvRam = NULL; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 979 | WR_HARPOON(ioport + hp_semaphore, 0x00); |
| 980 | FPT_XbowInit(ioport, 0); /*Must Init the SCSI before attempting */ |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 981 | FPT_DiagEEPROM(ioport); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 982 | } else { |
| 983 | if (FPT_mbCards < MAX_MB_CARDS) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 984 | pCurrNvRam = &FPT_nvRamInfo[FPT_mbCards]; |
| 985 | FPT_mbCards++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | pCurrNvRam->niBaseAddr = ioport; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 987 | FPT_RNVRamData(pCurrNvRam); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 988 | } else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 989 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 991 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | pCurrNvRam = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 994 | WR_HARPOON(ioport + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 995 | WR_HARPOON(ioport + hp_sys_ctrl, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 996 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 997 | if (pCurrNvRam) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | pCardInfo->si_id = pCurrNvRam->niAdapId; |
| 999 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1000 | pCardInfo->si_id = |
| 1001 | (unsigned |
| 1002 | char)(FPT_utilEERead(ioport, |
| 1003 | (ADAPTER_SCSI_ID / |
| 1004 | 2)) & (unsigned char)0x0FF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1006 | pCardInfo->si_lun = 0x00; |
| 1007 | pCardInfo->si_fw_revision = ORION_FW_REV; |
| 1008 | temp2 = 0x0000; |
| 1009 | temp3 = 0x0000; |
| 1010 | temp4 = 0x0000; |
| 1011 | temp5 = 0x0000; |
| 1012 | temp6 = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1014 | for (id = 0; id < (16 / 2); id++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1016 | if (pCurrNvRam) { |
| 1017 | temp = (unsigned short)pCurrNvRam->niSyncTbl[id]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) + |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1019 | (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000)); |
| 1020 | } else |
| 1021 | temp = |
| 1022 | FPT_utilEERead(ioport, |
| 1023 | (unsigned short)((SYNC_RATE_TBL / 2) |
| 1024 | + id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1026 | for (i = 0; i < 2; temp >>= 8, i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1028 | temp2 >>= 1; |
| 1029 | temp3 >>= 1; |
| 1030 | temp4 >>= 1; |
| 1031 | temp5 >>= 1; |
| 1032 | temp6 >>= 1; |
| 1033 | switch (temp & 0x3) { |
| 1034 | case AUTO_RATE_20: /* Synchronous, 20 mega-transfers/second */ |
| 1035 | temp6 |= 0x8000; /* Fall through */ |
| 1036 | case AUTO_RATE_10: /* Synchronous, 10 mega-transfers/second */ |
| 1037 | temp5 |= 0x8000; /* Fall through */ |
| 1038 | case AUTO_RATE_05: /* Synchronous, 5 mega-transfers/second */ |
| 1039 | temp2 |= 0x8000; /* Fall through */ |
| 1040 | case AUTO_RATE_00: /* Asynchronous */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | break; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | if (temp & DISC_ENABLE_BIT) |
| 1045 | temp3 |= 0x8000; |
| 1046 | |
| 1047 | if (temp & WIDE_NEGO_BIT) |
| 1048 | temp4 |= 0x8000; |
| 1049 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | } |
| 1052 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1053 | pCardInfo->si_per_targ_init_sync = temp2; |
| 1054 | pCardInfo->si_per_targ_no_disc = temp3; |
| 1055 | pCardInfo->si_per_targ_wide_nego = temp4; |
| 1056 | pCardInfo->si_per_targ_fast_nego = temp5; |
| 1057 | pCardInfo->si_per_targ_ultra_nego = temp6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1059 | if (pCurrNvRam) |
| 1060 | i = pCurrNvRam->niSysConf; |
| 1061 | else |
| 1062 | i = (unsigned |
| 1063 | char)(FPT_utilEERead(ioport, (SYSTEM_CONFIG / 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1065 | if (pCurrNvRam) |
| 1066 | ScamFlg = pCurrNvRam->niScamConf; |
| 1067 | else |
| 1068 | ScamFlg = |
| 1069 | (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1071 | pCardInfo->si_flags = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1073 | if (i & 0x01) |
| 1074 | pCardInfo->si_flags |= SCSI_PARITY_ENA; |
| 1075 | |
| 1076 | if (!(i & 0x02)) |
| 1077 | pCardInfo->si_flags |= SOFT_RESET; |
| 1078 | |
| 1079 | if (i & 0x10) |
| 1080 | pCardInfo->si_flags |= EXTENDED_TRANSLATION; |
| 1081 | |
| 1082 | if (ScamFlg & SCAM_ENABLED) |
| 1083 | pCardInfo->si_flags |= FLAG_SCAM_ENABLED; |
| 1084 | |
| 1085 | if (ScamFlg & SCAM_LEVEL2) |
| 1086 | pCardInfo->si_flags |= FLAG_SCAM_LEVEL2; |
| 1087 | |
| 1088 | j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L); |
| 1089 | if (i & 0x04) { |
| 1090 | j |= SCSI_TERM_ENA_L; |
| 1091 | } |
| 1092 | WR_HARPOON(ioport + hp_bm_ctrl, j); |
| 1093 | |
| 1094 | j = (RD_HARPOON(ioport + hp_ee_ctrl) & ~SCSI_TERM_ENA_H); |
| 1095 | if (i & 0x08) { |
| 1096 | j |= SCSI_TERM_ENA_H; |
| 1097 | } |
| 1098 | WR_HARPOON(ioport + hp_ee_ctrl, j); |
| 1099 | |
| 1100 | if (!(RD_HARPOON(ioport + hp_page_ctrl) & NARROW_SCSI_CARD)) |
| 1101 | |
| 1102 | pCardInfo->si_flags |= SUPPORT_16TAR_32LUN; |
| 1103 | |
| 1104 | pCardInfo->si_card_family = HARPOON_FAMILY; |
| 1105 | pCardInfo->si_bustype = BUSTYPE_PCI; |
| 1106 | |
| 1107 | if (pCurrNvRam) { |
| 1108 | pCardInfo->si_card_model[0] = '9'; |
| 1109 | switch (pCurrNvRam->niModel & 0x0f) { |
| 1110 | case MODEL_LT: |
| 1111 | pCardInfo->si_card_model[1] = '3'; |
| 1112 | pCardInfo->si_card_model[2] = '0'; |
| 1113 | break; |
| 1114 | case MODEL_LW: |
| 1115 | pCardInfo->si_card_model[1] = '5'; |
| 1116 | pCardInfo->si_card_model[2] = '0'; |
| 1117 | break; |
| 1118 | case MODEL_DL: |
| 1119 | pCardInfo->si_card_model[1] = '3'; |
| 1120 | pCardInfo->si_card_model[2] = '2'; |
| 1121 | break; |
| 1122 | case MODEL_DW: |
| 1123 | pCardInfo->si_card_model[1] = '5'; |
| 1124 | pCardInfo->si_card_model[2] = '2'; |
| 1125 | break; |
| 1126 | } |
| 1127 | } else { |
| 1128 | temp = FPT_utilEERead(ioport, (MODEL_NUMB_0 / 2)); |
| 1129 | pCardInfo->si_card_model[0] = (unsigned char)(temp >> 8); |
| 1130 | temp = FPT_utilEERead(ioport, (MODEL_NUMB_2 / 2)); |
| 1131 | |
| 1132 | pCardInfo->si_card_model[1] = (unsigned char)(temp & 0x00FF); |
| 1133 | pCardInfo->si_card_model[2] = (unsigned char)(temp >> 8); |
| 1134 | } |
| 1135 | |
| 1136 | if (pCardInfo->si_card_model[1] == '3') { |
| 1137 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1138 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1139 | } else if (pCardInfo->si_card_model[2] == '0') { |
| 1140 | temp = RD_HARPOON(ioport + hp_xfer_pad); |
| 1141 | WR_HARPOON(ioport + hp_xfer_pad, (temp & ~BIT(4))); |
| 1142 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1143 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1144 | WR_HARPOON(ioport + hp_xfer_pad, (temp | BIT(4))); |
| 1145 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1146 | pCardInfo->si_flags |= HIGH_BYTE_TERM; |
| 1147 | WR_HARPOON(ioport + hp_xfer_pad, temp); |
| 1148 | } else { |
| 1149 | temp = RD_HARPOON(ioport + hp_ee_ctrl); |
| 1150 | temp2 = RD_HARPOON(ioport + hp_xfer_pad); |
| 1151 | WR_HARPOON(ioport + hp_ee_ctrl, (temp | SEE_CS)); |
| 1152 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 | BIT(4))); |
| 1153 | temp3 = 0; |
| 1154 | for (i = 0; i < 8; i++) { |
| 1155 | temp3 <<= 1; |
| 1156 | if (!(RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))) |
| 1157 | temp3 |= 1; |
| 1158 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 & ~BIT(4))); |
| 1159 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 | BIT(4))); |
| 1160 | } |
| 1161 | WR_HARPOON(ioport + hp_ee_ctrl, temp); |
| 1162 | WR_HARPOON(ioport + hp_xfer_pad, temp2); |
| 1163 | if (!(temp3 & BIT(7))) |
| 1164 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1165 | if (!(temp3 & BIT(6))) |
| 1166 | pCardInfo->si_flags |= HIGH_BYTE_TERM; |
| 1167 | } |
| 1168 | |
| 1169 | ARAM_ACCESS(ioport); |
| 1170 | |
| 1171 | for (i = 0; i < 4; i++) { |
| 1172 | |
| 1173 | pCardInfo->si_XlatInfo[i] = |
| 1174 | RD_HARPOON(ioport + hp_aramBase + BIOS_DATA_OFFSET + i); |
| 1175 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | |
| 1177 | /* return with -1 if no sort, else return with |
| 1178 | logical card number sorted by BIOS (zero-based) */ |
| 1179 | |
| 1180 | pCardInfo->si_relative_cardnum = |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1181 | (unsigned |
| 1182 | char)(RD_HARPOON(ioport + hp_aramBase + BIOS_RELATIVE_CARD) - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1184 | SGRAM_ACCESS(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1186 | FPT_s_PhaseTbl[0] = FPT_phaseDataOut; |
| 1187 | FPT_s_PhaseTbl[1] = FPT_phaseDataIn; |
| 1188 | FPT_s_PhaseTbl[2] = FPT_phaseIllegal; |
| 1189 | FPT_s_PhaseTbl[3] = FPT_phaseIllegal; |
| 1190 | FPT_s_PhaseTbl[4] = FPT_phaseCommand; |
| 1191 | FPT_s_PhaseTbl[5] = FPT_phaseStatus; |
| 1192 | FPT_s_PhaseTbl[6] = FPT_phaseMsgOut; |
| 1193 | FPT_s_PhaseTbl[7] = FPT_phaseMsgIn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1195 | pCardInfo->si_present = 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1197 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | } |
| 1199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | /*--------------------------------------------------------------------- |
| 1201 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1202 | * Function: FlashPoint_HardwareResetHostAdapter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | * |
| 1204 | * Description: Setup adapter for normal operation (hard reset). |
| 1205 | * |
| 1206 | *---------------------------------------------------------------------*/ |
| 1207 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1208 | static unsigned long FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info |
| 1209 | *pCardInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1211 | struct sccb_card *CurrCard = NULL; |
| 1212 | struct nvram_info *pCurrNvRam; |
| 1213 | unsigned char i, j, thisCard, ScamFlg; |
| 1214 | unsigned short temp, sync_bit_map, id; |
| 1215 | unsigned long ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1217 | ioport = pCardInfo->si_baseaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1219 | for (thisCard = 0; thisCard <= MAX_CARDS; thisCard++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1221 | if (thisCard == MAX_CARDS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1223 | return FAILURE; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1224 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1226 | if (FPT_BL_Card[thisCard].ioPort == ioport) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1228 | CurrCard = &FPT_BL_Card[thisCard]; |
| 1229 | FPT_SccbMgrTableInitCard(CurrCard, thisCard); |
| 1230 | break; |
| 1231 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1233 | else if (FPT_BL_Card[thisCard].ioPort == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1234 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1235 | FPT_BL_Card[thisCard].ioPort = ioport; |
| 1236 | CurrCard = &FPT_BL_Card[thisCard]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1238 | if (FPT_mbCards) |
| 1239 | for (i = 0; i < FPT_mbCards; i++) { |
| 1240 | if (CurrCard->ioPort == |
| 1241 | FPT_nvRamInfo[i].niBaseAddr) |
| 1242 | CurrCard->pNvRamInfo = |
| 1243 | &FPT_nvRamInfo[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1245 | FPT_SccbMgrTableInitCard(CurrCard, thisCard); |
| 1246 | CurrCard->cardIndex = thisCard; |
| 1247 | CurrCard->cardInfo = pCardInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1249 | break; |
| 1250 | } |
| 1251 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | |
| 1253 | pCurrNvRam = CurrCard->pNvRamInfo; |
| 1254 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1255 | if (pCurrNvRam) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | ScamFlg = pCurrNvRam->niScamConf; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1257 | } else { |
| 1258 | ScamFlg = |
| 1259 | (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | } |
| 1261 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1262 | FPT_BusMasterInit(ioport); |
| 1263 | FPT_XbowInit(ioport, ScamFlg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1265 | FPT_autoLoadDefaultMap(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1267 | for (i = 0, id = 0x01; i != pCardInfo->si_id; i++, id <<= 1) { |
| 1268 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1270 | WR_HARPOON(ioport + hp_selfid_0, id); |
| 1271 | WR_HARPOON(ioport + hp_selfid_1, 0x00); |
| 1272 | WR_HARPOON(ioport + hp_arb_id, pCardInfo->si_id); |
| 1273 | CurrCard->ourId = pCardInfo->si_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1275 | i = (unsigned char)pCardInfo->si_flags; |
| 1276 | if (i & SCSI_PARITY_ENA) |
| 1277 | WR_HARPOON(ioport + hp_portctrl_1, (HOST_MODE8 | CHK_SCSI_P)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1279 | j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L); |
| 1280 | if (i & LOW_BYTE_TERM) |
| 1281 | j |= SCSI_TERM_ENA_L; |
| 1282 | WR_HARPOON(ioport + hp_bm_ctrl, j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1284 | j = (RD_HARPOON(ioport + hp_ee_ctrl) & ~SCSI_TERM_ENA_H); |
| 1285 | if (i & HIGH_BYTE_TERM) |
| 1286 | j |= SCSI_TERM_ENA_H; |
| 1287 | WR_HARPOON(ioport + hp_ee_ctrl, j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1289 | if (!(pCardInfo->si_flags & SOFT_RESET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1290 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1291 | FPT_sresb(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1293 | FPT_scini(thisCard, pCardInfo->si_id, 0); |
| 1294 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1296 | if (pCardInfo->si_flags & POST_ALL_UNDERRRUNS) |
| 1297 | CurrCard->globalFlags |= F_NO_FILTER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1299 | if (pCurrNvRam) { |
| 1300 | if (pCurrNvRam->niSysConf & 0x10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | CurrCard->globalFlags |= F_GREEN_PC; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1302 | } else { |
| 1303 | if (FPT_utilEERead(ioport, (SYSTEM_CONFIG / 2)) & GREEN_PC_ENA) |
| 1304 | CurrCard->globalFlags |= F_GREEN_PC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | } |
| 1306 | |
| 1307 | /* Set global flag to indicate Re-Negotiation to be done on all |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1308 | ckeck condition */ |
| 1309 | if (pCurrNvRam) { |
| 1310 | if (pCurrNvRam->niScsiConf & 0x04) |
| 1311 | CurrCard->globalFlags |= F_DO_RENEGO; |
| 1312 | } else { |
| 1313 | if (FPT_utilEERead(ioport, (SCSI_CONFIG / 2)) & RENEGO_ENA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | CurrCard->globalFlags |= F_DO_RENEGO; |
| 1315 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1316 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1317 | if (pCurrNvRam) { |
| 1318 | if (pCurrNvRam->niScsiConf & 0x08) |
| 1319 | CurrCard->globalFlags |= F_CONLUN_IO; |
| 1320 | } else { |
| 1321 | if (FPT_utilEERead(ioport, (SCSI_CONFIG / 2)) & CONNIO_ENA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | CurrCard->globalFlags |= F_CONLUN_IO; |
| 1323 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1324 | |
| 1325 | temp = pCardInfo->si_per_targ_no_disc; |
| 1326 | |
| 1327 | for (i = 0, id = 1; i < MAX_SCSI_TAR; i++, id <<= 1) { |
| 1328 | |
| 1329 | if (temp & id) |
| 1330 | FPT_sccbMgrTbl[thisCard][i].TarStatus |= TAR_ALLOW_DISC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | } |
| 1332 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1333 | sync_bit_map = 0x0001; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1335 | for (id = 0; id < (MAX_SCSI_TAR / 2); id++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1337 | if (pCurrNvRam) { |
| 1338 | temp = (unsigned short)pCurrNvRam->niSyncTbl[id]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) + |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1340 | (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000)); |
| 1341 | } else |
| 1342 | temp = |
| 1343 | FPT_utilEERead(ioport, |
| 1344 | (unsigned short)((SYNC_RATE_TBL / 2) |
| 1345 | + id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1347 | for (i = 0; i < 2; temp >>= 8, i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1349 | if (pCardInfo->si_per_targ_init_sync & sync_bit_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1351 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1352 | i].TarEEValue = |
| 1353 | (unsigned char)temp; |
| 1354 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1356 | else { |
| 1357 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1358 | i].TarStatus |= |
| 1359 | SYNC_SUPPORTED; |
| 1360 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1361 | i].TarEEValue = |
| 1362 | (unsigned char)(temp & ~EE_SYNC_MASK); |
| 1363 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | /* if ((pCardInfo->si_per_targ_wide_nego & sync_bit_map) || |
| 1366 | (id*2+i >= 8)){ |
| 1367 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1368 | if (pCardInfo->si_per_targ_wide_nego & sync_bit_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1370 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1371 | i].TarEEValue |= |
| 1372 | EE_WIDE_SCSI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1373 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1374 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1376 | else { /* NARROW SCSI */ |
| 1377 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1378 | i].TarStatus |= |
| 1379 | WIDE_NEGOCIATED; |
| 1380 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1382 | sync_bit_map <<= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1384 | } |
| 1385 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1387 | WR_HARPOON((ioport + hp_semaphore), |
| 1388 | (unsigned char)(RD_HARPOON((ioport + hp_semaphore)) | |
| 1389 | SCCB_MGR_PRESENT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1391 | return (unsigned long)CurrCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | } |
| 1393 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1394 | static void FlashPoint_ReleaseHostAdapter(unsigned long pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1396 | unsigned char i; |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1397 | unsigned long portBase; |
| 1398 | unsigned long regOffset; |
| 1399 | unsigned long scamData; |
| 1400 | unsigned long *pScamTbl; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1401 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1403 | pCurrNvRam = ((struct sccb_card *)pCurrCard)->pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1405 | if (pCurrNvRam) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 1406 | FPT_WrStack(pCurrNvRam->niBaseAddr, 0, pCurrNvRam->niModel); |
| 1407 | FPT_WrStack(pCurrNvRam->niBaseAddr, 1, pCurrNvRam->niSysConf); |
| 1408 | FPT_WrStack(pCurrNvRam->niBaseAddr, 2, pCurrNvRam->niScsiConf); |
| 1409 | FPT_WrStack(pCurrNvRam->niBaseAddr, 3, pCurrNvRam->niScamConf); |
| 1410 | FPT_WrStack(pCurrNvRam->niBaseAddr, 4, pCurrNvRam->niAdapId); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1412 | for (i = 0; i < MAX_SCSI_TAR / 2; i++) |
| 1413 | FPT_WrStack(pCurrNvRam->niBaseAddr, |
| 1414 | (unsigned char)(i + 5), |
| 1415 | pCurrNvRam->niSyncTbl[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | |
| 1417 | portBase = pCurrNvRam->niBaseAddr; |
| 1418 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1419 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 1420 | regOffset = hp_aramBase + 64 + i * 4; |
| 1421 | pScamTbl = (unsigned long *)&pCurrNvRam->niScamTbl[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1422 | scamData = *pScamTbl; |
| 1423 | WR_HARP32(portBase, regOffset, scamData); |
| 1424 | } |
| 1425 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1426 | } else { |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1427 | FPT_WrStack(((struct sccb_card *)pCurrCard)->ioPort, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | } |
| 1429 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1431 | static void FPT_RNVRamData(struct nvram_info *pNvRamInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1432 | { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1433 | unsigned char i; |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1434 | unsigned long portBase; |
| 1435 | unsigned long regOffset; |
| 1436 | unsigned long scamData; |
| 1437 | unsigned long *pScamTbl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1439 | pNvRamInfo->niModel = FPT_RdStack(pNvRamInfo->niBaseAddr, 0); |
| 1440 | pNvRamInfo->niSysConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 1); |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 1441 | pNvRamInfo->niScsiConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 2); |
| 1442 | pNvRamInfo->niScamConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 3); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1443 | pNvRamInfo->niAdapId = FPT_RdStack(pNvRamInfo->niBaseAddr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1445 | for (i = 0; i < MAX_SCSI_TAR / 2; i++) |
| 1446 | pNvRamInfo->niSyncTbl[i] = |
| 1447 | FPT_RdStack(pNvRamInfo->niBaseAddr, (unsigned char)(i + 5)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | |
| 1449 | portBase = pNvRamInfo->niBaseAddr; |
| 1450 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1451 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 1452 | regOffset = hp_aramBase + 64 + i * 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | RD_HARP32(portBase, regOffset, scamData); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1454 | pScamTbl = (unsigned long *)&pNvRamInfo->niScamTbl[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | *pScamTbl = scamData; |
| 1456 | } |
| 1457 | |
| 1458 | } |
| 1459 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1460 | static unsigned char FPT_RdStack(unsigned long portBase, unsigned char index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1461 | { |
| 1462 | WR_HARPOON(portBase + hp_stack_addr, index); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1463 | return RD_HARPOON(portBase + hp_stack_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | } |
| 1465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1466 | static void FPT_WrStack(unsigned long portBase, unsigned char index, |
| 1467 | unsigned char data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | { |
| 1469 | WR_HARPOON(portBase + hp_stack_addr, index); |
| 1470 | WR_HARPOON(portBase + hp_stack_data, data); |
| 1471 | } |
| 1472 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1473 | static unsigned char FPT_ChkIfChipInitialized(unsigned long ioPort) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1475 | if ((RD_HARPOON(ioPort + hp_arb_id) & 0x0f) != FPT_RdStack(ioPort, 4)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1476 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1477 | if ((RD_HARPOON(ioPort + hp_clkctrl_0) & CLKCTRL_DEFAULT) |
| 1478 | != CLKCTRL_DEFAULT) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1479 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1480 | if ((RD_HARPOON(ioPort + hp_seltimeout) == TO_250ms) || |
| 1481 | (RD_HARPOON(ioPort + hp_seltimeout) == TO_290ms)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1482 | return 1; |
| 1483 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | |
| 1485 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1486 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | /*--------------------------------------------------------------------- |
| 1488 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1489 | * Function: FlashPoint_StartCCB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1490 | * |
| 1491 | * Description: Start a command pointed to by p_Sccb. When the |
| 1492 | * command is completed it will be returned via the |
| 1493 | * callback function. |
| 1494 | * |
| 1495 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1496 | static void FlashPoint_StartCCB(unsigned long pCurrCard, struct sccb *p_Sccb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1498 | unsigned long ioport; |
| 1499 | unsigned char thisCard, lun; |
| 1500 | struct sccb *pSaveSccb; |
| 1501 | CALL_BK_FN callback; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1503 | thisCard = ((struct sccb_card *)pCurrCard)->cardIndex; |
| 1504 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1506 | if ((p_Sccb->TargID > MAX_SCSI_TAR) || (p_Sccb->Lun > MAX_LUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1508 | p_Sccb->HostStatus = SCCB_COMPLETE; |
| 1509 | p_Sccb->SccbStatus = SCCB_ERROR; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1510 | callback = (CALL_BK_FN) p_Sccb->SccbCallback; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | if (callback) |
| 1512 | callback(p_Sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1513 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | return; |
| 1515 | } |
| 1516 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1517 | FPT_sinits(p_Sccb, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1518 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1519 | if (!((struct sccb_card *)pCurrCard)->cmdCounter) { |
| 1520 | WR_HARPOON(ioport + hp_semaphore, |
| 1521 | (RD_HARPOON(ioport + hp_semaphore) |
| 1522 | | SCCB_MGR_ACTIVE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1524 | if (((struct sccb_card *)pCurrCard)->globalFlags & F_GREEN_PC) { |
| 1525 | WR_HARPOON(ioport + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 1526 | WR_HARPOON(ioport + hp_sys_ctrl, 0x00); |
| 1527 | } |
| 1528 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1530 | ((struct sccb_card *)pCurrCard)->cmdCounter++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1531 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1532 | if (RD_HARPOON(ioport + hp_semaphore) & BIOS_IN_USE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1533 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1534 | WR_HARPOON(ioport + hp_semaphore, |
| 1535 | (RD_HARPOON(ioport + hp_semaphore) |
| 1536 | | TICKLE_ME)); |
| 1537 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1538 | pSaveSccb = |
| 1539 | ((struct sccb_card *)pCurrCard)->currentSCCB; |
| 1540 | ((struct sccb_card *)pCurrCard)->currentSCCB = p_Sccb; |
| 1541 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], thisCard); |
| 1542 | ((struct sccb_card *)pCurrCard)->currentSCCB = |
| 1543 | pSaveSccb; |
| 1544 | } else { |
| 1545 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1546 | } |
| 1547 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1549 | else if ((RD_HARPOON(ioport + hp_page_ctrl) & G_INT_DISABLE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1551 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1552 | pSaveSccb = |
| 1553 | ((struct sccb_card *)pCurrCard)->currentSCCB; |
| 1554 | ((struct sccb_card *)pCurrCard)->currentSCCB = p_Sccb; |
| 1555 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], thisCard); |
| 1556 | ((struct sccb_card *)pCurrCard)->currentSCCB = |
| 1557 | pSaveSccb; |
| 1558 | } else { |
| 1559 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1560 | } |
| 1561 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1562 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1563 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1564 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1565 | MDISABLE_INT(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1566 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1567 | if ((((struct sccb_card *)pCurrCard)->globalFlags & F_CONLUN_IO) |
| 1568 | && |
| 1569 | ((FPT_sccbMgrTbl[thisCard][p_Sccb->TargID]. |
| 1570 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | lun = p_Sccb->Lun; |
| 1572 | else |
| 1573 | lun = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1574 | if ((((struct sccb_card *)pCurrCard)->currentSCCB == NULL) && |
| 1575 | (FPT_sccbMgrTbl[thisCard][p_Sccb->TargID].TarSelQ_Cnt == 0) |
| 1576 | && (FPT_sccbMgrTbl[thisCard][p_Sccb->TargID].TarLUNBusy[lun] |
| 1577 | == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1579 | ((struct sccb_card *)pCurrCard)->currentSCCB = p_Sccb; |
| 1580 | FPT_ssel(p_Sccb->SccbIOPort, thisCard); |
| 1581 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1583 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1584 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1585 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1586 | pSaveSccb = |
| 1587 | ((struct sccb_card *)pCurrCard)-> |
| 1588 | currentSCCB; |
| 1589 | ((struct sccb_card *)pCurrCard)->currentSCCB = |
| 1590 | p_Sccb; |
| 1591 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], |
| 1592 | thisCard); |
| 1593 | ((struct sccb_card *)pCurrCard)->currentSCCB = |
| 1594 | pSaveSccb; |
| 1595 | } else { |
| 1596 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1597 | } |
| 1598 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1599 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1600 | MENABLE_INT(ioport); |
| 1601 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1602 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | } |
| 1604 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1605 | /*--------------------------------------------------------------------- |
| 1606 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1607 | * Function: FlashPoint_AbortCCB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1608 | * |
| 1609 | * Description: Abort the command pointed to by p_Sccb. When the |
| 1610 | * command is completed it will be returned via the |
| 1611 | * callback function. |
| 1612 | * |
| 1613 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1614 | static int FlashPoint_AbortCCB(unsigned long pCurrCard, struct sccb *p_Sccb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1615 | { |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1616 | unsigned long ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1618 | unsigned char thisCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1619 | CALL_BK_FN callback; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1620 | unsigned char TID; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1621 | struct sccb *pSaveSCCB; |
| 1622 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1623 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1624 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1626 | thisCard = ((struct sccb_card *)pCurrCard)->cardIndex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1628 | if (!(RD_HARPOON(ioport + hp_page_ctrl) & G_INT_DISABLE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1630 | if (FPT_queueFindSccb(p_Sccb, thisCard)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1631 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1632 | ((struct sccb_card *)pCurrCard)->cmdCounter--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1634 | if (!((struct sccb_card *)pCurrCard)->cmdCounter) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1635 | WR_HARPOON(ioport + hp_semaphore, |
| 1636 | (RD_HARPOON(ioport + hp_semaphore) |
| 1637 | & (unsigned |
| 1638 | char)(~(SCCB_MGR_ACTIVE | |
| 1639 | TICKLE_ME)))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | p_Sccb->SccbStatus = SCCB_ABORT; |
| 1642 | callback = p_Sccb->SccbCallback; |
| 1643 | callback(p_Sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1645 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | } |
| 1647 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1648 | else { |
| 1649 | if (((struct sccb_card *)pCurrCard)->currentSCCB == |
| 1650 | p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1652 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1653 | |
| 1654 | } |
| 1655 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1656 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | |
| 1658 | TID = p_Sccb->TargID; |
| 1659 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1660 | if (p_Sccb->Sccb_tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | MDISABLE_INT(ioport); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1662 | if (((struct sccb_card *)pCurrCard)-> |
| 1663 | discQ_Tbl[p_Sccb->Sccb_tag] == |
| 1664 | p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1666 | p_Sccb->Sccb_scsistat = |
| 1667 | ABORT_ST; |
| 1668 | p_Sccb->Sccb_scsimsg = |
| 1669 | SMABORT_TAG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1670 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1671 | if (((struct sccb_card *) |
| 1672 | pCurrCard)->currentSCCB == |
| 1673 | NULL) { |
| 1674 | ((struct sccb_card *) |
| 1675 | pCurrCard)-> |
| 1676 | currentSCCB = p_Sccb; |
| 1677 | FPT_ssel(ioport, |
| 1678 | thisCard); |
| 1679 | } else { |
| 1680 | pSaveSCCB = |
| 1681 | ((struct sccb_card |
| 1682 | *)pCurrCard)-> |
| 1683 | currentSCCB; |
| 1684 | ((struct sccb_card *) |
| 1685 | pCurrCard)-> |
| 1686 | currentSCCB = p_Sccb; |
| 1687 | FPT_queueSelectFail((struct sccb_card *)pCurrCard, thisCard); |
| 1688 | ((struct sccb_card *) |
| 1689 | pCurrCard)-> |
| 1690 | currentSCCB = pSaveSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1691 | } |
| 1692 | } |
| 1693 | MENABLE_INT(ioport); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1694 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1695 | } else { |
| 1696 | currTar_Info = |
| 1697 | &FPT_sccbMgrTbl[thisCard][p_Sccb-> |
| 1698 | TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1700 | if (FPT_BL_Card[thisCard]. |
| 1701 | discQ_Tbl[currTar_Info-> |
| 1702 | LunDiscQ_Idx[p_Sccb->Lun]] |
| 1703 | == p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1705 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1706 | } |
| 1707 | } |
| 1708 | } |
| 1709 | } |
| 1710 | } |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1711 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | } |
| 1713 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1714 | /*--------------------------------------------------------------------- |
| 1715 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1716 | * Function: FlashPoint_InterruptPending |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | * |
| 1718 | * Description: Do a quick check to determine if there is a pending |
| 1719 | * interrupt for this card and disable the IRQ Pin if so. |
| 1720 | * |
| 1721 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1722 | static unsigned char FlashPoint_InterruptPending(unsigned long pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1723 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1724 | unsigned long ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1725 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1726 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1727 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1728 | if (RD_HARPOON(ioport + hp_int_status) & INT_ASSERTED) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1729 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1730 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1732 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1734 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1735 | } |
| 1736 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | /*--------------------------------------------------------------------- |
| 1738 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1739 | * Function: FlashPoint_HandleInterrupt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1740 | * |
| 1741 | * Description: This is our entry point when an interrupt is generated |
| 1742 | * by the card and the upper level driver passes it on to |
| 1743 | * us. |
| 1744 | * |
| 1745 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 1746 | static int FlashPoint_HandleInterrupt(unsigned long pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1747 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1748 | struct sccb *currSCCB; |
| 1749 | unsigned char thisCard, result, bm_status, bm_int_st; |
| 1750 | unsigned short hp_int; |
| 1751 | unsigned char i, target; |
| 1752 | unsigned long ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1753 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1754 | thisCard = ((struct sccb_card *)pCurrCard)->cardIndex; |
| 1755 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1757 | MDISABLE_INT(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1758 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1759 | if ((bm_int_st = RD_HARPOON(ioport + hp_int_status)) & EXT_STATUS_ON) |
| 1760 | bm_status = |
| 1761 | RD_HARPOON(ioport + |
| 1762 | hp_ext_status) & (unsigned char)BAD_EXT_STATUS; |
| 1763 | else |
| 1764 | bm_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1765 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1766 | WR_HARPOON(ioport + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1767 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1768 | while ((hp_int = |
| 1769 | RDW_HARPOON((ioport + |
| 1770 | hp_intstat)) & FPT_default_intena) | bm_status) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1772 | currSCCB = ((struct sccb_card *)pCurrCard)->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1774 | if (hp_int & (FIFO | TIMEOUT | RESET | SCAM_SEL) || bm_status) { |
| 1775 | result = |
| 1776 | FPT_SccbMgr_bad_isr(ioport, thisCard, |
| 1777 | ((struct sccb_card *)pCurrCard), |
| 1778 | hp_int); |
| 1779 | WRW_HARPOON((ioport + hp_intstat), |
| 1780 | (FIFO | TIMEOUT | RESET | SCAM_SEL)); |
| 1781 | bm_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1783 | if (result) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1785 | MENABLE_INT(ioport); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1786 | return result; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1787 | } |
| 1788 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1789 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1790 | else if (hp_int & ICMD_COMP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1792 | if (!(hp_int & BUS_FREE)) { |
| 1793 | /* Wait for the BusFree before starting a new command. We |
| 1794 | must also check for being reselected since the BusFree |
| 1795 | may not show up if another device reselects us in 1.5us or |
| 1796 | less. SRR Wednesday, 3/8/1995. |
| 1797 | */ |
| 1798 | while (! |
| 1799 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1800 | (BUS_FREE | RSEL))) ; |
| 1801 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1802 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1803 | if (((struct sccb_card *)pCurrCard)-> |
| 1804 | globalFlags & F_HOST_XFER_ACT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1805 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1806 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1807 | |
| 1808 | /* WRW_HARPOON((ioport+hp_intstat), |
| 1809 | (BUS_FREE | ICMD_COMP | ITAR_DISC | XFER_CNT_0)); |
| 1810 | */ |
| 1811 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1812 | WRW_HARPOON((ioport + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1813 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1814 | FPT_autoCmdCmplt(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1815 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1816 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1817 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1818 | else if (hp_int & ITAR_DISC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1819 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1820 | if (((struct sccb_card *)pCurrCard)-> |
| 1821 | globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1823 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | } |
| 1826 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1827 | if (RD_HARPOON(ioport + hp_gp_reg_1) == SMSAVE_DATA_PTR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1828 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1829 | WR_HARPOON(ioport + hp_gp_reg_1, 0x00); |
| 1830 | currSCCB->Sccb_XferState |= F_NO_DATA_YET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1831 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1832 | currSCCB->Sccb_savedATC = currSCCB->Sccb_ATC; |
| 1833 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1834 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1835 | currSCCB->Sccb_scsistat = DISCONNECT_ST; |
| 1836 | FPT_queueDisconnect(currSCCB, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1837 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1838 | /* Wait for the BusFree before starting a new command. We |
| 1839 | must also check for being reselected since the BusFree |
| 1840 | may not show up if another device reselects us in 1.5us or |
| 1841 | less. SRR Wednesday, 3/8/1995. |
| 1842 | */ |
| 1843 | while (! |
| 1844 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1845 | (BUS_FREE | RSEL)) |
| 1846 | && !((RDW_HARPOON((ioport + hp_intstat)) & PHASE) |
| 1847 | && RD_HARPOON((ioport + hp_scsisig)) == |
| 1848 | (SCSI_BSY | SCSI_REQ | SCSI_CD | SCSI_MSG | |
| 1849 | SCSI_IOBIT))) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1850 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1851 | /* |
| 1852 | The additional loop exit condition above detects a timing problem |
| 1853 | with the revision D/E harpoon chips. The caller should reset the |
| 1854 | host adapter to recover when 0xFE is returned. |
| 1855 | */ |
| 1856 | if (! |
| 1857 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1858 | (BUS_FREE | RSEL))) { |
| 1859 | MENABLE_INT(ioport); |
| 1860 | return 0xFE; |
| 1861 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1862 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1863 | WRW_HARPOON((ioport + hp_intstat), |
| 1864 | (BUS_FREE | ITAR_DISC)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1865 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1866 | ((struct sccb_card *)pCurrCard)->globalFlags |= |
| 1867 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1868 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1869 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1870 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1871 | else if (hp_int & RSEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1872 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1873 | WRW_HARPOON((ioport + hp_intstat), |
| 1874 | (PROG_HLT | RSEL | PHASE | BUS_FREE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1875 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1876 | if (RDW_HARPOON((ioport + hp_intstat)) & ITAR_DISC) { |
| 1877 | if (((struct sccb_card *)pCurrCard)-> |
| 1878 | globalFlags & F_HOST_XFER_ACT) { |
| 1879 | FPT_phaseChkFifo(ioport, thisCard); |
| 1880 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1882 | if (RD_HARPOON(ioport + hp_gp_reg_1) == |
| 1883 | SMSAVE_DATA_PTR) { |
| 1884 | WR_HARPOON(ioport + hp_gp_reg_1, 0x00); |
| 1885 | currSCCB->Sccb_XferState |= |
| 1886 | F_NO_DATA_YET; |
| 1887 | currSCCB->Sccb_savedATC = |
| 1888 | currSCCB->Sccb_ATC; |
| 1889 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1890 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1891 | WRW_HARPOON((ioport + hp_intstat), |
| 1892 | (BUS_FREE | ITAR_DISC)); |
| 1893 | currSCCB->Sccb_scsistat = DISCONNECT_ST; |
| 1894 | FPT_queueDisconnect(currSCCB, thisCard); |
| 1895 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1897 | FPT_sres(ioport, thisCard, |
| 1898 | ((struct sccb_card *)pCurrCard)); |
| 1899 | FPT_phaseDecode(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1900 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1901 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1902 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1903 | else if ((hp_int & IDO_STRT) && (!(hp_int & BUS_FREE))) { |
| 1904 | |
| 1905 | WRW_HARPOON((ioport + hp_intstat), |
| 1906 | (IDO_STRT | XFER_CNT_0)); |
| 1907 | FPT_phaseDecode(ioport, thisCard); |
| 1908 | |
| 1909 | } |
| 1910 | |
| 1911 | else if ((hp_int & IUNKWN) || (hp_int & PROG_HLT)) { |
| 1912 | WRW_HARPOON((ioport + hp_intstat), |
| 1913 | (PHASE | IUNKWN | PROG_HLT)); |
| 1914 | if ((RD_HARPOON(ioport + hp_prgmcnt_0) & (unsigned char) |
| 1915 | 0x3f) < (unsigned char)SELCHK) { |
| 1916 | FPT_phaseDecode(ioport, thisCard); |
| 1917 | } else { |
| 1918 | /* Harpoon problem some SCSI target device respond to selection |
| 1919 | with short BUSY pulse (<400ns) this will make the Harpoon is not able |
| 1920 | to latch the correct Target ID into reg. x53. |
| 1921 | The work around require to correct this reg. But when write to this |
| 1922 | reg. (0x53) also increment the FIFO write addr reg (0x6f), thus we |
| 1923 | need to read this reg first then restore it later. After update to 0x53 */ |
| 1924 | |
| 1925 | i = (unsigned |
| 1926 | char)(RD_HARPOON(ioport + hp_fifowrite)); |
| 1927 | target = |
| 1928 | (unsigned |
| 1929 | char)(RD_HARPOON(ioport + hp_gp_reg_3)); |
| 1930 | WR_HARPOON(ioport + hp_xfer_pad, |
| 1931 | (unsigned char)ID_UNLOCK); |
| 1932 | WR_HARPOON(ioport + hp_select_id, |
| 1933 | (unsigned char)(target | target << |
| 1934 | 4)); |
| 1935 | WR_HARPOON(ioport + hp_xfer_pad, |
| 1936 | (unsigned char)0x00); |
| 1937 | WR_HARPOON(ioport + hp_fifowrite, i); |
| 1938 | WR_HARPOON(ioport + hp_autostart_3, |
| 1939 | (AUTO_IMMED + TAG_STRT)); |
| 1940 | } |
| 1941 | } |
| 1942 | |
| 1943 | else if (hp_int & XFER_CNT_0) { |
| 1944 | |
| 1945 | WRW_HARPOON((ioport + hp_intstat), XFER_CNT_0); |
| 1946 | |
| 1947 | FPT_schkdd(ioport, thisCard); |
| 1948 | |
| 1949 | } |
| 1950 | |
| 1951 | else if (hp_int & BUS_FREE) { |
| 1952 | |
| 1953 | WRW_HARPOON((ioport + hp_intstat), BUS_FREE); |
| 1954 | |
| 1955 | if (((struct sccb_card *)pCurrCard)-> |
| 1956 | globalFlags & F_HOST_XFER_ACT) { |
| 1957 | |
| 1958 | FPT_hostDataXferAbort(ioport, thisCard, |
| 1959 | currSCCB); |
| 1960 | } |
| 1961 | |
| 1962 | FPT_phaseBusFree(ioport, thisCard); |
| 1963 | } |
| 1964 | |
| 1965 | else if (hp_int & ITICKLE) { |
| 1966 | |
| 1967 | WRW_HARPOON((ioport + hp_intstat), ITICKLE); |
| 1968 | ((struct sccb_card *)pCurrCard)->globalFlags |= |
| 1969 | F_NEW_SCCB_CMD; |
| 1970 | } |
| 1971 | |
| 1972 | if (((struct sccb_card *)pCurrCard)-> |
| 1973 | globalFlags & F_NEW_SCCB_CMD) { |
| 1974 | |
| 1975 | ((struct sccb_card *)pCurrCard)->globalFlags &= |
| 1976 | ~F_NEW_SCCB_CMD; |
| 1977 | |
| 1978 | if (((struct sccb_card *)pCurrCard)->currentSCCB == |
| 1979 | NULL) { |
| 1980 | |
| 1981 | FPT_queueSearchSelect(((struct sccb_card *) |
| 1982 | pCurrCard), thisCard); |
| 1983 | } |
| 1984 | |
| 1985 | if (((struct sccb_card *)pCurrCard)->currentSCCB != |
| 1986 | NULL) { |
| 1987 | ((struct sccb_card *)pCurrCard)->globalFlags &= |
| 1988 | ~F_NEW_SCCB_CMD; |
| 1989 | FPT_ssel(ioport, thisCard); |
| 1990 | } |
| 1991 | |
| 1992 | break; |
| 1993 | |
| 1994 | } |
| 1995 | |
| 1996 | } /*end while */ |
| 1997 | |
| 1998 | MENABLE_INT(ioport); |
| 1999 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2000 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2001 | } |
| 2002 | |
| 2003 | /*--------------------------------------------------------------------- |
| 2004 | * |
| 2005 | * Function: Sccb_bad_isr |
| 2006 | * |
| 2007 | * Description: Some type of interrupt has occurred which is slightly |
| 2008 | * out of the ordinary. We will now decode it fully, in |
| 2009 | * this routine. This is broken up in an attempt to save |
| 2010 | * processing time. |
| 2011 | * |
| 2012 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2013 | static unsigned char FPT_SccbMgr_bad_isr(unsigned long p_port, |
| 2014 | unsigned char p_card, |
| 2015 | struct sccb_card *pCurrCard, |
| 2016 | unsigned short p_int) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2017 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2018 | unsigned char temp, ScamFlg; |
| 2019 | struct sccb_mgr_tar_info *currTar_Info; |
| 2020 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2022 | if (RD_HARPOON(p_port + hp_ext_status) & |
| 2023 | (BM_FORCE_OFF | PCI_DEV_TMOUT | BM_PARITY_ERR | PIO_OVERRUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2025 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2026 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2027 | FPT_hostDataXferAbort(p_port, p_card, |
| 2028 | pCurrCard->currentSCCB); |
| 2029 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2031 | if (RD_HARPOON(p_port + hp_pci_stat_cfg) & REC_MASTER_ABORT) |
| 2032 | { |
| 2033 | WR_HARPOON(p_port + hp_pci_stat_cfg, |
| 2034 | (RD_HARPOON(p_port + hp_pci_stat_cfg) & |
| 2035 | ~REC_MASTER_ABORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2036 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2037 | WR_HARPOON(p_port + hp_host_blk_cnt, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2038 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2039 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2041 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2043 | if (!pCurrCard->currentSCCB->HostStatus) |
| 2044 | pCurrCard->currentSCCB->HostStatus = |
| 2045 | SCCB_BM_ERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2046 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2047 | FPT_sxfrp(p_port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2048 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2049 | temp = (unsigned char)(RD_HARPOON(p_port + hp_ee_ctrl) & |
| 2050 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)); |
| 2051 | WR_HARPOON(p_port + hp_ee_ctrl, |
| 2052 | ((unsigned char)temp | SEE_MS | SEE_CS)); |
| 2053 | WR_HARPOON(p_port + hp_ee_ctrl, temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2055 | if (! |
| 2056 | (RDW_HARPOON((p_port + hp_intstat)) & |
| 2057 | (BUS_FREE | RESET))) { |
| 2058 | FPT_phaseDecode(p_port, p_card); |
| 2059 | } |
| 2060 | } |
| 2061 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2063 | else if (p_int & RESET) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2064 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2065 | WR_HARPOON(p_port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 2066 | WR_HARPOON(p_port + hp_sys_ctrl, 0x00); |
| 2067 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2069 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2071 | FPT_hostDataXferAbort(p_port, p_card, |
| 2072 | pCurrCard->currentSCCB); |
| 2073 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2075 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2077 | FPT_sresb(p_port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2079 | while (RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST) { |
| 2080 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2082 | pCurrNvRam = pCurrCard->pNvRamInfo; |
| 2083 | if (pCurrNvRam) { |
| 2084 | ScamFlg = pCurrNvRam->niScamConf; |
| 2085 | } else { |
| 2086 | ScamFlg = |
| 2087 | (unsigned char)FPT_utilEERead(p_port, |
| 2088 | SCAM_CONFIG / 2); |
| 2089 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2090 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2091 | FPT_XbowInit(p_port, ScamFlg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2092 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2093 | FPT_scini(p_card, pCurrCard->ourId, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2095 | return 0xFF; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2096 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2097 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2098 | else if (p_int & FIFO) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2099 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2100 | WRW_HARPOON((p_port + hp_intstat), FIFO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2101 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2102 | if (pCurrCard->currentSCCB != NULL) |
| 2103 | FPT_sxfrp(p_port, p_card); |
| 2104 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2106 | else if (p_int & TIMEOUT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2107 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2108 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2110 | WRW_HARPOON((p_port + hp_intstat), |
| 2111 | (PROG_HLT | TIMEOUT | SEL | BUS_FREE | PHASE | |
| 2112 | IUNKWN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2114 | pCurrCard->currentSCCB->HostStatus = SCCB_SELECTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2115 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2116 | currTar_Info = |
| 2117 | &FPT_sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID]; |
| 2118 | if ((pCurrCard->globalFlags & F_CONLUN_IO) |
| 2119 | && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 2120 | TAG_Q_TRYING)) |
| 2121 | currTar_Info->TarLUNBusy[pCurrCard->currentSCCB->Lun] = |
| 2122 | 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2124 | currTar_Info->TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2126 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 2127 | currTar_Info->TarSyncCtrl = 0; |
| 2128 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 2129 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2131 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 2132 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2133 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2135 | FPT_sssyncv(p_port, pCurrCard->currentSCCB->TargID, NARROW_SCSI, |
| 2136 | currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2137 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2138 | FPT_queueCmdComplete(pCurrCard, pCurrCard->currentSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2139 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2140 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2142 | else if (p_int & SCAM_SEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2144 | FPT_scarb(p_port, LEVEL2_TAR); |
| 2145 | FPT_scsel(p_port); |
| 2146 | FPT_scasid(p_card, p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2147 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2148 | FPT_scbusf(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2149 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2150 | WRW_HARPOON((p_port + hp_intstat), SCAM_SEL); |
| 2151 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2153 | return 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | } |
| 2155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2156 | /*--------------------------------------------------------------------- |
| 2157 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | * Function: SccbMgrTableInit |
| 2159 | * |
| 2160 | * Description: Initialize all Sccb manager data structures. |
| 2161 | * |
| 2162 | *---------------------------------------------------------------------*/ |
| 2163 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2164 | static void FPT_SccbMgrTableInitAll() |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2165 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2166 | unsigned char thisCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2168 | for (thisCard = 0; thisCard < MAX_CARDS; thisCard++) { |
| 2169 | FPT_SccbMgrTableInitCard(&FPT_BL_Card[thisCard], thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2171 | FPT_BL_Card[thisCard].ioPort = 0x00; |
| 2172 | FPT_BL_Card[thisCard].cardInfo = NULL; |
| 2173 | FPT_BL_Card[thisCard].cardIndex = 0xFF; |
| 2174 | FPT_BL_Card[thisCard].ourId = 0x00; |
| 2175 | FPT_BL_Card[thisCard].pNvRamInfo = NULL; |
| 2176 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | } |
| 2178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | /*--------------------------------------------------------------------- |
| 2180 | * |
| 2181 | * Function: SccbMgrTableInit |
| 2182 | * |
| 2183 | * Description: Initialize all Sccb manager data structures. |
| 2184 | * |
| 2185 | *---------------------------------------------------------------------*/ |
| 2186 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2187 | static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard, |
| 2188 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2190 | unsigned char scsiID, qtag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2192 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2193 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2194 | } |
| 2195 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2196 | for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++) { |
| 2197 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus = 0; |
| 2198 | FPT_sccbMgrTbl[p_card][scsiID].TarEEValue = 0; |
| 2199 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 2200 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2201 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2202 | pCurrCard->scanIndex = 0x00; |
| 2203 | pCurrCard->currentSCCB = NULL; |
| 2204 | pCurrCard->globalFlags = 0x00; |
| 2205 | pCurrCard->cmdCounter = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2206 | pCurrCard->tagQ_Lst = 0x01; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2207 | pCurrCard->discQCount = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | |
| 2209 | } |
| 2210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2211 | /*--------------------------------------------------------------------- |
| 2212 | * |
| 2213 | * Function: SccbMgrTableInit |
| 2214 | * |
| 2215 | * Description: Initialize all Sccb manager data structures. |
| 2216 | * |
| 2217 | *---------------------------------------------------------------------*/ |
| 2218 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2219 | static void FPT_SccbMgrTableInitTarget(unsigned char p_card, |
| 2220 | unsigned char target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2221 | { |
| 2222 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2223 | unsigned char lun, qtag; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2224 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2226 | currTar_Info = &FPT_sccbMgrTbl[p_card][target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2227 | |
| 2228 | currTar_Info->TarSelQ_Cnt = 0; |
| 2229 | currTar_Info->TarSyncCtrl = 0; |
| 2230 | |
| 2231 | currTar_Info->TarSelQ_Head = NULL; |
| 2232 | currTar_Info->TarSelQ_Tail = NULL; |
| 2233 | currTar_Info->TarTagQ_Cnt = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2234 | currTar_Info->TarLUN_CA = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2235 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2236 | for (lun = 0; lun < MAX_LUN; lun++) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2237 | currTar_Info->TarLUNBusy[lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | currTar_Info->LunDiscQ_Idx[lun] = 0; |
| 2239 | } |
| 2240 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2241 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
| 2242 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] != NULL) { |
| 2243 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == |
| 2244 | target) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2245 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 2246 | FPT_BL_Card[p_card].discQCount--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2247 | } |
| 2248 | } |
| 2249 | } |
| 2250 | } |
| 2251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2252 | /*--------------------------------------------------------------------- |
| 2253 | * |
| 2254 | * Function: sfetm |
| 2255 | * |
| 2256 | * Description: Read in a message byte from the SCSI bus, and check |
| 2257 | * for a parity error. |
| 2258 | * |
| 2259 | *---------------------------------------------------------------------*/ |
| 2260 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2261 | static unsigned char FPT_sfm(unsigned long port, struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2263 | unsigned char message; |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 2264 | unsigned short TimeOutLoop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | |
| 2266 | TimeOutLoop = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2267 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2268 | (TimeOutLoop++ < 20000)) { |
| 2269 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2271 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2273 | message = RD_HARPOON(port + hp_scsidata_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2274 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2275 | WR_HARPOON(port + hp_scsisig, SCSI_ACK + S_MSGI_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | |
| 2277 | if (TimeOutLoop > 20000) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2278 | message = 0x00; /* force message byte = 0 if Time Out on Req */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2280 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 2281 | (RD_HARPOON(port + hp_addstat) & SCSI_PAR_ERR)) { |
| 2282 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
| 2283 | WR_HARPOON(port + hp_xferstat, 0); |
| 2284 | WR_HARPOON(port + hp_fiforead, 0); |
| 2285 | WR_HARPOON(port + hp_fifowrite, 0); |
| 2286 | if (pCurrSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2287 | pCurrSCCB->Sccb_scsimsg = SMPARITY; |
| 2288 | } |
| 2289 | message = 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2290 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2291 | ACCEPT_MSG_ATN(port); |
| 2292 | TimeOutLoop = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2293 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2294 | (TimeOutLoop++ < 20000)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2295 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2296 | if (TimeOutLoop > 20000) { |
| 2297 | WRW_HARPOON((port + hp_intstat), PARITY); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2298 | return message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2299 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2300 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) != |
| 2301 | S_MSGI_PH) { |
| 2302 | WRW_HARPOON((port + hp_intstat), PARITY); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2303 | return message; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2304 | } |
| 2305 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2306 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2307 | RD_HARPOON(port + hp_scsidata_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2308 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2309 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2310 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2311 | } while (1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2312 | |
| 2313 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2314 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
| 2315 | WR_HARPOON(port + hp_xferstat, 0); |
| 2316 | WR_HARPOON(port + hp_fiforead, 0); |
| 2317 | WR_HARPOON(port + hp_fifowrite, 0); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2318 | return message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2319 | } |
| 2320 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | /*--------------------------------------------------------------------- |
| 2322 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2323 | * Function: FPT_ssel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2324 | * |
| 2325 | * Description: Load up automation and select target device. |
| 2326 | * |
| 2327 | *---------------------------------------------------------------------*/ |
| 2328 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 2329 | static void FPT_ssel(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | { |
| 2331 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2332 | unsigned char auto_loaded, i, target, *theCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2333 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2334 | unsigned long cdb_reg; |
| 2335 | struct sccb_card *CurrCard; |
| 2336 | struct sccb *currSCCB; |
| 2337 | struct sccb_mgr_tar_info *currTar_Info; |
| 2338 | unsigned char lastTag, lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2339 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2340 | CurrCard = &FPT_BL_Card[p_card]; |
| 2341 | currSCCB = CurrCard->currentSCCB; |
| 2342 | target = currSCCB->TargID; |
| 2343 | currTar_Info = &FPT_sccbMgrTbl[p_card][target]; |
| 2344 | lastTag = CurrCard->tagQ_Lst; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2346 | ARAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | |
| 2348 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT) |
| 2349 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
| 2350 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2351 | if (((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2352 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2354 | lun = currSCCB->Lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | else |
| 2356 | lun = 0; |
| 2357 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2358 | if (CurrCard->globalFlags & F_TAG_STARTED) { |
| 2359 | if (!(currSCCB->ControlByte & F_USE_CMD_Q)) { |
| 2360 | if ((currTar_Info->TarLUN_CA == 0) |
| 2361 | && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) |
| 2362 | == TAG_Q_TRYING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2364 | if (currTar_Info->TarTagQ_Cnt != 0) { |
| 2365 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2366 | FPT_queueSelectFail(CurrCard, p_card); |
| 2367 | SGRAM_ACCESS(port); |
| 2368 | return; |
| 2369 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2370 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2371 | else { |
| 2372 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2373 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2375 | } |
| 2376 | /*End non-tagged */ |
| 2377 | else { |
| 2378 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2379 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2381 | } |
| 2382 | /*!Use cmd Q Tagged */ |
| 2383 | else { |
| 2384 | if (currTar_Info->TarLUN_CA == 1) { |
| 2385 | FPT_queueSelectFail(CurrCard, p_card); |
| 2386 | SGRAM_ACCESS(port); |
| 2387 | return; |
| 2388 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2389 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2390 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2391 | |
| 2392 | } /*else use cmd Q tagged */ |
| 2393 | |
| 2394 | } |
| 2395 | /*if glob tagged started */ |
| 2396 | else { |
| 2397 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2398 | } |
| 2399 | |
| 2400 | if ((((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2401 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 2402 | || (!(currSCCB->ControlByte & F_USE_CMD_Q)))) { |
| 2403 | if (CurrCard->discQCount >= QUEUE_DEPTH) { |
| 2404 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2405 | FPT_queueSelectFail(CurrCard, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2406 | SGRAM_ACCESS(port); |
| 2407 | return; |
| 2408 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2409 | for (i = 1; i < QUEUE_DEPTH; i++) { |
| 2410 | if (++lastTag >= QUEUE_DEPTH) |
| 2411 | lastTag = 1; |
| 2412 | if (CurrCard->discQ_Tbl[lastTag] == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2413 | CurrCard->tagQ_Lst = lastTag; |
| 2414 | currTar_Info->LunDiscQ_Idx[lun] = lastTag; |
| 2415 | CurrCard->discQ_Tbl[lastTag] = currSCCB; |
| 2416 | CurrCard->discQCount++; |
| 2417 | break; |
| 2418 | } |
| 2419 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2420 | if (i == QUEUE_DEPTH) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2421 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2422 | FPT_queueSelectFail(CurrCard, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2423 | SGRAM_ACCESS(port); |
| 2424 | return; |
| 2425 | } |
| 2426 | } |
| 2427 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2428 | auto_loaded = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2430 | WR_HARPOON(port + hp_select_id, target); |
| 2431 | 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] | 2432 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2433 | if (currSCCB->OperationCode == RESET_COMMAND) { |
| 2434 | WRW_HARPOON((port + ID_MSG_STRT), (MPM_OP + AMSG_OUT + |
| 2435 | (currSCCB-> |
| 2436 | Sccb_idmsg & ~DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2438 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + NP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2440 | currSCCB->Sccb_scsimsg = SMDEV_RESET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2442 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
| 2443 | auto_loaded = 1; |
| 2444 | currSCCB->Sccb_scsistat = SELECT_BDR_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2446 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 2447 | currTar_Info->TarSyncCtrl = 0; |
| 2448 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2449 | } |
| 2450 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2451 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 2452 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2453 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2454 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2455 | FPT_sssyncv(port, target, NARROW_SCSI, currTar_Info); |
| 2456 | FPT_SccbMgrTableInitTarget(p_card, target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2458 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2459 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2460 | else if (currSCCB->Sccb_scsistat == ABORT_ST) { |
| 2461 | WRW_HARPOON((port + ID_MSG_STRT), (MPM_OP + AMSG_OUT + |
| 2462 | (currSCCB-> |
| 2463 | Sccb_idmsg & ~DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2464 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2465 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2466 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2467 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + |
| 2468 | (((unsigned |
| 2469 | char)(currSCCB-> |
| 2470 | ControlByte & |
| 2471 | TAG_TYPE_MASK) |
| 2472 | >> 6) | (unsigned char) |
| 2473 | 0x20))); |
| 2474 | WRW_HARPOON((port + SYNC_MSGS + 2), |
| 2475 | (MPM_OP + AMSG_OUT + currSCCB->Sccb_tag)); |
| 2476 | WRW_HARPOON((port + SYNC_MSGS + 4), (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2477 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2478 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
| 2479 | auto_loaded = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2480 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2481 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2482 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2483 | else if (!(currTar_Info->TarStatus & WIDE_NEGOCIATED)) { |
| 2484 | auto_loaded = FPT_siwidn(port, p_card); |
| 2485 | currSCCB->Sccb_scsistat = SELECT_WN_ST; |
| 2486 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2487 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2488 | else if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) |
| 2489 | == SYNC_SUPPORTED)) { |
| 2490 | auto_loaded = FPT_sisyncn(port, p_card, 0); |
| 2491 | currSCCB->Sccb_scsistat = SELECT_SN_ST; |
| 2492 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2493 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2494 | if (!auto_loaded) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2495 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2496 | if (currSCCB->ControlByte & F_USE_CMD_Q) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2498 | CurrCard->globalFlags |= F_TAG_STARTED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2499 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2500 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) |
| 2501 | == TAG_Q_REJECT) { |
| 2502 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2503 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2504 | /* Fix up the start instruction with a jump to |
| 2505 | Non-Tag-CMD handling */ |
| 2506 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2507 | BRH_OP + ALWAYS + NTCMD); |
| 2508 | |
| 2509 | WRW_HARPOON((port + NON_TAG_ID_MSG), |
| 2510 | (MPM_OP + AMSG_OUT + |
| 2511 | currSCCB->Sccb_idmsg)); |
| 2512 | |
| 2513 | WR_HARPOON(port + hp_autostart_3, |
| 2514 | (SELECT + SELCHK_STRT)); |
| 2515 | |
| 2516 | /* Setup our STATE so we know what happend when |
| 2517 | the wheels fall off. */ |
| 2518 | currSCCB->Sccb_scsistat = SELECT_ST; |
| 2519 | |
| 2520 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2521 | } |
| 2522 | |
| 2523 | else { |
| 2524 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2525 | (MPM_OP + AMSG_OUT + |
| 2526 | currSCCB->Sccb_idmsg)); |
| 2527 | |
| 2528 | WRW_HARPOON((port + ID_MSG_STRT + 2), |
| 2529 | (MPM_OP + AMSG_OUT + |
| 2530 | (((unsigned char)(currSCCB-> |
| 2531 | ControlByte & |
| 2532 | TAG_TYPE_MASK) |
| 2533 | >> 6) | (unsigned char)0x20))); |
| 2534 | |
| 2535 | for (i = 1; i < QUEUE_DEPTH; i++) { |
| 2536 | if (++lastTag >= QUEUE_DEPTH) |
| 2537 | lastTag = 1; |
| 2538 | if (CurrCard->discQ_Tbl[lastTag] == |
| 2539 | NULL) { |
| 2540 | WRW_HARPOON((port + |
| 2541 | ID_MSG_STRT + 6), |
| 2542 | (MPM_OP + AMSG_OUT + |
| 2543 | lastTag)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | CurrCard->tagQ_Lst = lastTag; |
| 2545 | currSCCB->Sccb_tag = lastTag; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2546 | CurrCard->discQ_Tbl[lastTag] = |
| 2547 | currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2548 | CurrCard->discQCount++; |
| 2549 | break; |
| 2550 | } |
| 2551 | } |
| 2552 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2553 | if (i == QUEUE_DEPTH) { |
| 2554 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2555 | FPT_queueSelectFail(CurrCard, p_card); |
| 2556 | SGRAM_ACCESS(port); |
| 2557 | return; |
| 2558 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2559 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2560 | currSCCB->Sccb_scsistat = SELECT_Q_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2561 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2562 | WR_HARPOON(port + hp_autostart_3, |
| 2563 | (SELECT + SELCHK_STRT)); |
| 2564 | } |
| 2565 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2566 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2567 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2569 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2570 | BRH_OP + ALWAYS + NTCMD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2572 | WRW_HARPOON((port + NON_TAG_ID_MSG), |
| 2573 | (MPM_OP + AMSG_OUT + currSCCB->Sccb_idmsg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2574 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2575 | currSCCB->Sccb_scsistat = SELECT_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2576 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2577 | WR_HARPOON(port + hp_autostart_3, |
| 2578 | (SELECT + SELCHK_STRT)); |
| 2579 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2580 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2581 | theCCB = (unsigned char *)&currSCCB->Cdb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2582 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2583 | cdb_reg = port + CMD_STRT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2584 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2585 | for (i = 0; i < currSCCB->CdbLength; i++) { |
| 2586 | WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + *theCCB)); |
| 2587 | cdb_reg += 2; |
| 2588 | theCCB++; |
| 2589 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2591 | if (currSCCB->CdbLength != TWELVE_BYTE_CMD) |
| 2592 | WRW_HARPOON(cdb_reg, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2593 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2594 | } |
| 2595 | /* auto_loaded */ |
| 2596 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
| 2597 | WR_HARPOON(port + hp_xferstat, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2598 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2599 | WRW_HARPOON((port + hp_intstat), (PROG_HLT | TIMEOUT | SEL | BUS_FREE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2600 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2601 | WR_HARPOON(port + hp_portctrl_0, (SCSI_PORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2602 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2603 | if (!(currSCCB->Sccb_MGRFlags & F_DEV_SELECTED)) { |
| 2604 | WR_HARPOON(port + hp_scsictrl_0, |
| 2605 | (SEL_TAR | ENA_ATN | ENA_RESEL | ENA_SCAM_SEL)); |
| 2606 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2607 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2608 | /* auto_loaded = (RD_HARPOON(port+hp_autostart_3) & (unsigned char)0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2609 | auto_loaded |= AUTO_IMMED; */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2610 | auto_loaded = AUTO_IMMED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2611 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2612 | DISABLE_AUTO(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2613 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2614 | WR_HARPOON(port + hp_autostart_3, auto_loaded); |
| 2615 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2617 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2618 | } |
| 2619 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2620 | /*--------------------------------------------------------------------- |
| 2621 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2622 | * Function: FPT_sres |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2623 | * |
| 2624 | * Description: Hookup the correct CCB and handle the incoming messages. |
| 2625 | * |
| 2626 | *---------------------------------------------------------------------*/ |
| 2627 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2628 | static void FPT_sres(unsigned long port, unsigned char p_card, |
| 2629 | struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2630 | { |
| 2631 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2632 | unsigned char our_target, message, lun = 0, tag, msgRetryCount; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2633 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2634 | struct sccb_mgr_tar_info *currTar_Info; |
| 2635 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2636 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2637 | if (pCurrCard->currentSCCB != NULL) { |
| 2638 | currTar_Info = |
| 2639 | &FPT_sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2640 | DISABLE_AUTO(port); |
| 2641 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2642 | WR_HARPOON((port + hp_scsictrl_0), (ENA_RESEL | ENA_SCAM_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2643 | |
| 2644 | currSCCB = pCurrCard->currentSCCB; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2645 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2646 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2647 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
| 2648 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2649 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2650 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 2651 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
| 2652 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2653 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 2654 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 2655 | TAG_Q_TRYING))) { |
| 2656 | currTar_Info->TarLUNBusy[currSCCB->Lun] = 0; |
| 2657 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2659 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 2660 | LunDiscQ_Idx[currSCCB-> |
| 2661 | Lun]] |
| 2662 | = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2663 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2664 | } else { |
| 2665 | currTar_Info->TarLUNBusy[0] = 0; |
| 2666 | if (currSCCB->Sccb_tag) { |
| 2667 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2668 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2669 | pCurrCard->discQ_Tbl[currSCCB-> |
| 2670 | Sccb_tag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2671 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2672 | } else { |
| 2673 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2674 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2675 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 2676 | LunDiscQ_Idx[0]] = |
| 2677 | NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2678 | } |
| 2679 | } |
| 2680 | } |
| 2681 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2682 | FPT_queueSelectFail(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | } |
| 2684 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2685 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2686 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2687 | our_target = (unsigned char)(RD_HARPOON(port + hp_select_id) >> 4); |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2688 | currTar_Info = &FPT_sccbMgrTbl[p_card][our_target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2689 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2690 | msgRetryCount = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2691 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2692 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2693 | currTar_Info = &FPT_sccbMgrTbl[p_card][our_target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2694 | tag = 0; |
| 2695 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2696 | while (!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) { |
| 2697 | if (!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2698 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2699 | WRW_HARPOON((port + hp_intstat), PHASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2700 | return; |
| 2701 | } |
| 2702 | } |
| 2703 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2704 | WRW_HARPOON((port + hp_intstat), PHASE); |
| 2705 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) == S_MSGI_PH) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2706 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2707 | message = FPT_sfm(port, pCurrCard->currentSCCB); |
| 2708 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2709 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2710 | if (message <= (0x80 | LUN_MASK)) { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2711 | lun = message & (unsigned char)LUN_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2712 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2713 | if ((currTar_Info-> |
| 2714 | TarStatus & TAR_TAG_Q_MASK) == |
| 2715 | TAG_Q_TRYING) { |
| 2716 | if (currTar_Info->TarTagQ_Cnt != |
| 2717 | 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2718 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2719 | if (! |
| 2720 | (currTar_Info-> |
| 2721 | TarLUN_CA)) { |
| 2722 | ACCEPT_MSG(port); /*Release the ACK for ID msg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2723 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2724 | message = |
| 2725 | FPT_sfm |
| 2726 | (port, |
| 2727 | pCurrCard-> |
| 2728 | currentSCCB); |
| 2729 | if (message) { |
| 2730 | ACCEPT_MSG |
| 2731 | (port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2732 | } |
| 2733 | |
| 2734 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2735 | message |
| 2736 | = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2737 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2738 | if (message != |
| 2739 | 0) { |
| 2740 | tag = |
| 2741 | FPT_sfm |
| 2742 | (port, |
| 2743 | pCurrCard-> |
| 2744 | currentSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2745 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2746 | if (! |
| 2747 | (tag)) |
| 2748 | message |
| 2749 | = |
| 2750 | 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2751 | } |
| 2752 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2753 | } |
| 2754 | /*C.A. exists! */ |
| 2755 | } |
| 2756 | /*End Q cnt != 0 */ |
| 2757 | } |
| 2758 | /*End Tag cmds supported! */ |
| 2759 | } |
| 2760 | /*End valid ID message. */ |
| 2761 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2762 | |
| 2763 | ACCEPT_MSG_ATN(port); |
| 2764 | } |
| 2765 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2766 | } |
| 2767 | /* End good id message. */ |
| 2768 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2769 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2770 | message = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2771 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2772 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2773 | ACCEPT_MSG_ATN(port); |
| 2774 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2775 | while (! |
| 2776 | (RDW_HARPOON((port + hp_intstat)) & |
| 2777 | (PHASE | RESET)) |
| 2778 | && !(RD_HARPOON(port + hp_scsisig) & SCSI_REQ) |
| 2779 | && (RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2780 | |
| 2781 | return; |
| 2782 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2783 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2784 | if (message == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2785 | msgRetryCount++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2786 | if (msgRetryCount == 1) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2787 | FPT_SendMsg(port, SMPARITY); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2788 | } else { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2789 | FPT_SendMsg(port, SMDEV_RESET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2790 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2791 | FPT_sssyncv(port, our_target, NARROW_SCSI, |
| 2792 | currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2793 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2794 | if (FPT_sccbMgrTbl[p_card][our_target]. |
| 2795 | TarEEValue & EE_SYNC_MASK) { |
| 2796 | |
| 2797 | FPT_sccbMgrTbl[p_card][our_target]. |
| 2798 | TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2799 | |
| 2800 | } |
| 2801 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2802 | if (FPT_sccbMgrTbl[p_card][our_target]. |
| 2803 | TarEEValue & EE_WIDE_SCSI) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2804 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2805 | FPT_sccbMgrTbl[p_card][our_target]. |
| 2806 | TarStatus &= ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2807 | } |
| 2808 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2809 | FPT_queueFlushTargSccb(p_card, our_target, |
| 2810 | SCCB_COMPLETE); |
| 2811 | FPT_SccbMgrTableInitTarget(p_card, our_target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2812 | return; |
| 2813 | } |
| 2814 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2815 | } while (message == 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2816 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2817 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 2818 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2819 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2820 | pCurrCard->currentSCCB = |
| 2821 | pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[lun]]; |
| 2822 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2823 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2824 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2825 | ACCEPT_MSG_ATN(port); |
| 2826 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2827 | } else { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2828 | currTar_Info->TarLUNBusy[0] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2829 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2830 | if (tag) { |
| 2831 | if (pCurrCard->discQ_Tbl[tag] != NULL) { |
| 2832 | pCurrCard->currentSCCB = |
| 2833 | pCurrCard->discQ_Tbl[tag]; |
| 2834 | currTar_Info->TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2835 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2836 | } else { |
| 2837 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2838 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2839 | } else { |
| 2840 | pCurrCard->currentSCCB = |
| 2841 | pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]]; |
| 2842 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2843 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2844 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2845 | ACCEPT_MSG_ATN(port); |
| 2846 | } |
| 2847 | } |
| 2848 | } |
| 2849 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2850 | if (pCurrCard->currentSCCB != NULL) { |
| 2851 | if (pCurrCard->currentSCCB->Sccb_scsistat == ABORT_ST) { |
| 2852 | /* During Abort Tag command, the target could have got re-selected |
| 2853 | and completed the command. Check the select Q and remove the CCB |
| 2854 | if it is in the Select Q */ |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2855 | FPT_queueFindSccb(pCurrCard->currentSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2856 | } |
| 2857 | } |
| 2858 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2859 | while (!(RDW_HARPOON((port + hp_intstat)) & (PHASE | RESET)) && |
| 2860 | !(RD_HARPOON(port + hp_scsisig) & SCSI_REQ) && |
| 2861 | (RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2862 | } |
| 2863 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 2864 | static void FPT_SendMsg(unsigned long port, unsigned char message) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2865 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2866 | while (!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) { |
| 2867 | if (!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2868 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2869 | WRW_HARPOON((port + hp_intstat), PHASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2870 | return; |
| 2871 | } |
| 2872 | } |
| 2873 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2874 | WRW_HARPOON((port + hp_intstat), PHASE); |
| 2875 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) == S_MSGO_PH) { |
| 2876 | WRW_HARPOON((port + hp_intstat), |
| 2877 | (BUS_FREE | PHASE | XFER_CNT_0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2878 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2879 | WR_HARPOON(port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2880 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2881 | WR_HARPOON(port + hp_scsidata_0, message); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2882 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2883 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2884 | |
| 2885 | ACCEPT_MSG(port); |
| 2886 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2887 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2888 | |
| 2889 | if ((message == SMABORT) || (message == SMDEV_RESET) || |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2890 | (message == SMABORT_TAG)) { |
| 2891 | while (! |
| 2892 | (RDW_HARPOON((port + hp_intstat)) & |
| 2893 | (BUS_FREE | PHASE))) { |
| 2894 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2895 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2896 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 2897 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2898 | } |
| 2899 | } |
| 2900 | } |
| 2901 | } |
| 2902 | |
| 2903 | /*--------------------------------------------------------------------- |
| 2904 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2905 | * Function: FPT_sdecm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2906 | * |
| 2907 | * Description: Determine the proper responce to the message from the |
| 2908 | * target device. |
| 2909 | * |
| 2910 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2911 | static void FPT_sdecm(unsigned char message, unsigned long port, |
| 2912 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2913 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2914 | struct sccb *currSCCB; |
| 2915 | struct sccb_card *CurrCard; |
| 2916 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2917 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2918 | CurrCard = &FPT_BL_Card[p_card]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2919 | currSCCB = CurrCard->currentSCCB; |
| 2920 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2921 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2922 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2923 | if (message == SMREST_DATA_PTR) { |
| 2924 | if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2925 | currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC; |
| 2926 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2927 | FPT_hostDataXferRestart(currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2928 | } |
| 2929 | |
| 2930 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2931 | WR_HARPOON(port + hp_autostart_1, |
| 2932 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2933 | } |
| 2934 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2935 | else if (message == SMCMD_COMP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2936 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2937 | if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { |
| 2938 | currTar_Info->TarStatus &= |
| 2939 | ~(unsigned char)TAR_TAG_Q_MASK; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2940 | currTar_Info->TarStatus |= (unsigned char)TAG_Q_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2941 | } |
| 2942 | |
| 2943 | ACCEPT_MSG(port); |
| 2944 | |
| 2945 | } |
| 2946 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2947 | else if ((message == SMNO_OP) || (message >= SMIDENT) |
| 2948 | || (message == SMINIT_RECOVERY) || (message == SMREL_RECOVERY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2949 | |
| 2950 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2951 | WR_HARPOON(port + hp_autostart_1, |
| 2952 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2953 | } |
| 2954 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2955 | else if (message == SMREJECT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2956 | |
| 2957 | if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) || |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2958 | (currSCCB->Sccb_scsistat == SELECT_WN_ST) || |
| 2959 | ((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING) |
| 2960 | || ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == |
| 2961 | TAG_Q_TRYING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2962 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2963 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2964 | |
| 2965 | ACCEPT_MSG(port); |
| 2966 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2967 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2968 | (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2969 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2970 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2971 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2972 | if (currSCCB->Lun == 0x00) { |
| 2973 | if ((currSCCB->Sccb_scsistat == SELECT_SN_ST)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2974 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2975 | currTar_Info->TarStatus |= |
| 2976 | (unsigned char)SYNC_SUPPORTED; |
| 2977 | |
| 2978 | currTar_Info->TarEEValue &= |
| 2979 | ~EE_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2980 | } |
| 2981 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2982 | else if ((currSCCB->Sccb_scsistat == |
| 2983 | SELECT_WN_ST)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2984 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2985 | currTar_Info->TarStatus = |
| 2986 | (currTar_Info-> |
| 2987 | TarStatus & ~WIDE_ENABLED) | |
| 2988 | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2989 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2990 | currTar_Info->TarEEValue &= |
| 2991 | ~EE_WIDE_SCSI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2992 | |
| 2993 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2994 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2995 | else if ((currTar_Info-> |
| 2996 | TarStatus & TAR_TAG_Q_MASK) == |
| 2997 | TAG_Q_TRYING) { |
| 2998 | currTar_Info->TarStatus = |
| 2999 | (currTar_Info-> |
| 3000 | TarStatus & ~(unsigned char) |
| 3001 | TAR_TAG_Q_MASK) | TAG_Q_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3002 | |
| 3003 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
| 3004 | CurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3005 | CurrCard->discQ_Tbl[currSCCB-> |
| 3006 | Sccb_tag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3007 | currSCCB->Sccb_tag = 0x00; |
| 3008 | |
| 3009 | } |
| 3010 | } |
| 3011 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3012 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3013 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3014 | if (currSCCB->Lun == 0x00) { |
| 3015 | WRW_HARPOON((port + hp_intstat), |
| 3016 | BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3017 | CurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 3018 | } |
| 3019 | } |
| 3020 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3021 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3022 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3023 | if ((CurrCard->globalFlags & F_CONLUN_IO) && |
| 3024 | ((currTar_Info-> |
| 3025 | TarStatus & TAR_TAG_Q_MASK) != |
| 3026 | TAG_Q_TRYING)) |
| 3027 | currTar_Info->TarLUNBusy[currSCCB-> |
| 3028 | Lun] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3029 | else |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3030 | currTar_Info->TarLUNBusy[0] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3031 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3032 | currSCCB->ControlByte &= |
| 3033 | ~(unsigned char)F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3034 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3035 | WR_HARPOON(port + hp_autostart_1, |
| 3036 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3037 | |
| 3038 | } |
| 3039 | } |
| 3040 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3041 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3042 | ACCEPT_MSG(port); |
| 3043 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3044 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 3045 | (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3046 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3047 | } |
| 3048 | |
| 3049 | if (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE)) { |
| 3050 | WR_HARPOON(port + hp_autostart_1, |
| 3051 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3052 | } |
| 3053 | } |
| 3054 | } |
| 3055 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3056 | else if (message == SMEXT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3057 | |
| 3058 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3059 | FPT_shandem(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3060 | } |
| 3061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3062 | else if (message == SMIGNORWR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3063 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3064 | ACCEPT_MSG(port); /* ACK the RESIDUE MSG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3065 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3066 | message = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3067 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3068 | if (currSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3069 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3070 | WR_HARPOON(port + hp_autostart_1, |
| 3071 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3072 | } |
| 3073 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3074 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3075 | |
| 3076 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 3077 | currSCCB->Sccb_scsimsg = SMREJECT; |
| 3078 | |
| 3079 | ACCEPT_MSG_ATN(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3080 | WR_HARPOON(port + hp_autostart_1, |
| 3081 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3082 | } |
| 3083 | } |
| 3084 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3085 | /*--------------------------------------------------------------------- |
| 3086 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3087 | * Function: FPT_shandem |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3088 | * |
| 3089 | * Description: Decide what to do with the extended message. |
| 3090 | * |
| 3091 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3092 | static void FPT_shandem(unsigned long port, unsigned char p_card, |
| 3093 | struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3094 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3095 | unsigned char length, message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3096 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3097 | length = FPT_sfm(port, pCurrSCCB); |
| 3098 | if (length) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3099 | |
| 3100 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3101 | message = FPT_sfm(port, pCurrSCCB); |
| 3102 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3103 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3104 | if (message == SMSYNC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3105 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3106 | if (length == 0x03) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3107 | |
| 3108 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3109 | FPT_stsyncn(port, p_card); |
| 3110 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3111 | |
| 3112 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3113 | ACCEPT_MSG_ATN(port); |
| 3114 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3115 | } else if (message == SMWDTR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3116 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3117 | if (length == 0x02) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3118 | |
| 3119 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3120 | FPT_stwidn(port, p_card); |
| 3121 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3122 | |
| 3123 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3124 | ACCEPT_MSG_ATN(port); |
| 3125 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3126 | WR_HARPOON(port + hp_autostart_1, |
| 3127 | (AUTO_IMMED + |
| 3128 | DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3129 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3130 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3131 | |
| 3132 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3133 | ACCEPT_MSG_ATN(port); |
| 3134 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3135 | WR_HARPOON(port + hp_autostart_1, |
| 3136 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3137 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3138 | } else { |
| 3139 | if (pCurrSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3140 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3141 | WR_HARPOON(port + hp_autostart_1, |
| 3142 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3143 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3144 | } else { |
| 3145 | if (pCurrSCCB->Sccb_scsimsg == SMPARITY) |
| 3146 | WR_HARPOON(port + hp_autostart_1, |
| 3147 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3148 | } |
| 3149 | } |
| 3150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3151 | /*--------------------------------------------------------------------- |
| 3152 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3153 | * Function: FPT_sisyncn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3154 | * |
| 3155 | * Description: Read in a message byte from the SCSI bus, and check |
| 3156 | * for a parity error. |
| 3157 | * |
| 3158 | *---------------------------------------------------------------------*/ |
| 3159 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3160 | static unsigned char FPT_sisyncn(unsigned long port, unsigned char p_card, |
| 3161 | unsigned char syncFlag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3162 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3163 | struct sccb *currSCCB; |
| 3164 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3165 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3166 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3167 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3168 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3169 | if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3170 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3171 | WRW_HARPOON((port + ID_MSG_STRT), |
| 3172 | (MPM_OP + AMSG_OUT + |
| 3173 | (currSCCB-> |
| 3174 | Sccb_idmsg & ~(unsigned char)DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3175 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3176 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3177 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3178 | WRW_HARPOON((port + SYNC_MSGS + 0), |
| 3179 | (MPM_OP + AMSG_OUT + SMEXT)); |
| 3180 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); |
| 3181 | WRW_HARPOON((port + SYNC_MSGS + 4), |
| 3182 | (MPM_OP + AMSG_OUT + SMSYNC)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3183 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3184 | if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3185 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3186 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3187 | (MPM_OP + AMSG_OUT + 12)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3188 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3189 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == |
| 3190 | EE_SYNC_10MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3191 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3192 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3193 | (MPM_OP + AMSG_OUT + 25)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3194 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3195 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == |
| 3196 | EE_SYNC_5MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3197 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3198 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3199 | (MPM_OP + AMSG_OUT + 50)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3200 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3201 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3202 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3203 | (MPM_OP + AMSG_OUT + 00)); |
| 3204 | |
| 3205 | WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); |
| 3206 | WRW_HARPOON((port + SYNC_MSGS + 10), |
| 3207 | (MPM_OP + AMSG_OUT + DEFAULT_OFFSET)); |
| 3208 | WRW_HARPOON((port + SYNC_MSGS + 12), (BRH_OP + ALWAYS + NP)); |
| 3209 | |
| 3210 | if (syncFlag == 0) { |
| 3211 | WR_HARPOON(port + hp_autostart_3, |
| 3212 | (SELECT + SELCHK_STRT)); |
| 3213 | currTar_Info->TarStatus = |
| 3214 | ((currTar_Info-> |
| 3215 | TarStatus & ~(unsigned char)TAR_SYNC_MASK) | |
| 3216 | (unsigned char)SYNC_TRYING); |
| 3217 | } else { |
| 3218 | WR_HARPOON(port + hp_autostart_3, |
| 3219 | (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3220 | } |
| 3221 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3222 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3223 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3224 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3225 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3226 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3227 | currTar_Info->TarStatus |= (unsigned char)SYNC_SUPPORTED; |
| 3228 | currTar_Info->TarEEValue &= ~EE_SYNC_MASK; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3229 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3230 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3231 | } |
| 3232 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3233 | /*--------------------------------------------------------------------- |
| 3234 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3235 | * Function: FPT_stsyncn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3236 | * |
| 3237 | * Description: The has sent us a Sync Nego message so handle it as |
| 3238 | * necessary. |
| 3239 | * |
| 3240 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3241 | static void FPT_stsyncn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3242 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3243 | unsigned char sync_msg, offset, sync_reg, our_sync_msg; |
| 3244 | struct sccb *currSCCB; |
| 3245 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3246 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3247 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3248 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3249 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3250 | sync_msg = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3251 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3252 | if ((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3253 | WR_HARPOON(port + hp_autostart_1, |
| 3254 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3255 | return; |
| 3256 | } |
| 3257 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3258 | ACCEPT_MSG(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3259 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3260 | offset = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3261 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3262 | if ((offset == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3263 | WR_HARPOON(port + hp_autostart_1, |
| 3264 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3265 | return; |
| 3266 | } |
| 3267 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3268 | if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3269 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3270 | our_sync_msg = 12; /* Setup our Message to 20mb/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3271 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3272 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_10MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3274 | our_sync_msg = 25; /* Setup our Message to 10mb/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3275 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3276 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_5MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3277 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3278 | our_sync_msg = 50; /* Setup our Message to 5mb/s */ |
| 3279 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3280 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3281 | our_sync_msg = 0; /* Message = Async */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3282 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3283 | if (sync_msg < our_sync_msg) { |
| 3284 | sync_msg = our_sync_msg; /*if faster, then set to max. */ |
| 3285 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3286 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3287 | if (offset == ASYNC) |
| 3288 | sync_msg = ASYNC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3289 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3290 | if (offset > MAX_OFFSET) |
| 3291 | offset = MAX_OFFSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3292 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3293 | sync_reg = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3294 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3295 | if (sync_msg > 12) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3296 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3297 | sync_reg = 0x20; /* Use 10MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3298 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3299 | if (sync_msg > 25) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3300 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3301 | sync_reg = 0x40; /* Use 6.6MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3302 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3303 | if (sync_msg > 38) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3304 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3305 | sync_reg = 0x60; /* Use 5MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3306 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3307 | if (sync_msg > 50) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3308 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3309 | sync_reg = 0x80; /* Use 4MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3310 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3311 | if (sync_msg > 62) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3312 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3313 | sync_reg = 0xA0; /* Use 3.33MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3314 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3315 | if (sync_msg > 75) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3316 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3317 | sync_reg = 0xC0; /* Use 2.85MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3318 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3319 | if (sync_msg > 87) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3320 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3321 | sync_reg = 0xE0; /* Use 2.5MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3322 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3323 | if (sync_msg > 100) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3324 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3325 | sync_reg = 0x00; /* Use ASYNC */ |
| 3326 | offset = 0x00; |
| 3327 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3328 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3329 | if (currTar_Info->TarStatus & WIDE_ENABLED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3330 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3331 | sync_reg |= offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3332 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3333 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3334 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3335 | sync_reg |= (offset | NARROW_SCSI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3336 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3337 | FPT_sssyncv(port, currSCCB->TargID, sync_reg, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3338 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3339 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3340 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3341 | ACCEPT_MSG(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3342 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3343 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3344 | ~(unsigned char)TAR_SYNC_MASK) | |
| 3345 | (unsigned char)SYNC_SUPPORTED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3346 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3347 | WR_HARPOON(port + hp_autostart_1, |
| 3348 | (AUTO_IMMED + DISCONNECT_START)); |
| 3349 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3350 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3351 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3352 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3353 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3354 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3355 | FPT_sisyncr(port, sync_msg, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3356 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3357 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3358 | ~(unsigned char)TAR_SYNC_MASK) | |
| 3359 | (unsigned char)SYNC_SUPPORTED); |
| 3360 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3361 | } |
| 3362 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3363 | /*--------------------------------------------------------------------- |
| 3364 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3365 | * Function: FPT_sisyncr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3366 | * |
| 3367 | * Description: Answer the targets sync message. |
| 3368 | * |
| 3369 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3370 | static void FPT_sisyncr(unsigned long port, unsigned char sync_pulse, |
| 3371 | unsigned char offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3372 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3373 | ARAM_ACCESS(port); |
| 3374 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); |
| 3375 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); |
| 3376 | WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMSYNC)); |
| 3377 | WRW_HARPOON((port + SYNC_MSGS + 6), (MPM_OP + AMSG_OUT + sync_pulse)); |
| 3378 | WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); |
| 3379 | WRW_HARPOON((port + SYNC_MSGS + 10), (MPM_OP + AMSG_OUT + offset)); |
| 3380 | WRW_HARPOON((port + SYNC_MSGS + 12), (BRH_OP + ALWAYS + NP)); |
| 3381 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3382 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3383 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
| 3384 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3385 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3386 | WR_HARPOON(port + hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3387 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3388 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | AUTO_INT))) { |
| 3389 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3390 | } |
| 3391 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3392 | /*--------------------------------------------------------------------- |
| 3393 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3394 | * Function: FPT_siwidn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3395 | * |
| 3396 | * Description: Read in a message byte from the SCSI bus, and check |
| 3397 | * for a parity error. |
| 3398 | * |
| 3399 | *---------------------------------------------------------------------*/ |
| 3400 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3401 | static unsigned char FPT_siwidn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3402 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3403 | struct sccb *currSCCB; |
| 3404 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3405 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3406 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3407 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3408 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3409 | if (!((currTar_Info->TarStatus & TAR_WIDE_MASK) == WIDE_NEGOCIATED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3410 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3411 | WRW_HARPOON((port + ID_MSG_STRT), |
| 3412 | (MPM_OP + AMSG_OUT + |
| 3413 | (currSCCB-> |
| 3414 | Sccb_idmsg & ~(unsigned char)DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3415 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3416 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3417 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3418 | WRW_HARPOON((port + SYNC_MSGS + 0), |
| 3419 | (MPM_OP + AMSG_OUT + SMEXT)); |
| 3420 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); |
| 3421 | WRW_HARPOON((port + SYNC_MSGS + 4), |
| 3422 | (MPM_OP + AMSG_OUT + SMWDTR)); |
| 3423 | WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); |
| 3424 | WRW_HARPOON((port + SYNC_MSGS + 8), |
| 3425 | (MPM_OP + AMSG_OUT + SM16BIT)); |
| 3426 | WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3427 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3428 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3430 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3431 | ~(unsigned char)TAR_WIDE_MASK) | |
| 3432 | (unsigned char)WIDE_ENABLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3433 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3434 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3435 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3437 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3439 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3440 | ~(unsigned char)TAR_WIDE_MASK) | |
| 3441 | WIDE_NEGOCIATED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3442 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3443 | currTar_Info->TarEEValue &= ~EE_WIDE_SCSI; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3444 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3445 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3446 | } |
| 3447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3448 | /*--------------------------------------------------------------------- |
| 3449 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3450 | * Function: FPT_stwidn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3451 | * |
| 3452 | * Description: The has sent us a Wide Nego message so handle it as |
| 3453 | * necessary. |
| 3454 | * |
| 3455 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3456 | static void FPT_stwidn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3457 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3458 | unsigned char width; |
| 3459 | struct sccb *currSCCB; |
| 3460 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3461 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3462 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3463 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3464 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3465 | width = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3466 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3467 | if ((width == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3468 | WR_HARPOON(port + hp_autostart_1, |
| 3469 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3470 | return; |
| 3471 | } |
| 3472 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3473 | if (!(currTar_Info->TarEEValue & EE_WIDE_SCSI)) |
| 3474 | width = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3475 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3476 | if (width) { |
| 3477 | currTar_Info->TarStatus |= WIDE_ENABLED; |
| 3478 | width = 0; |
| 3479 | } else { |
| 3480 | width = NARROW_SCSI; |
| 3481 | currTar_Info->TarStatus &= ~WIDE_ENABLED; |
| 3482 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3483 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3484 | FPT_sssyncv(port, currSCCB->TargID, width, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3485 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3486 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3487 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3488 | currTar_Info->TarStatus |= WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3489 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3490 | if (! |
| 3491 | ((currTar_Info->TarStatus & TAR_SYNC_MASK) == |
| 3492 | SYNC_SUPPORTED)) { |
| 3493 | ACCEPT_MSG_ATN(port); |
| 3494 | ARAM_ACCESS(port); |
| 3495 | FPT_sisyncn(port, p_card, 1); |
| 3496 | currSCCB->Sccb_scsistat = SELECT_SN_ST; |
| 3497 | SGRAM_ACCESS(port); |
| 3498 | } else { |
| 3499 | ACCEPT_MSG(port); |
| 3500 | WR_HARPOON(port + hp_autostart_1, |
| 3501 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3502 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3503 | } |
| 3504 | |
| 3505 | else { |
| 3506 | |
| 3507 | ACCEPT_MSG_ATN(port); |
| 3508 | |
| 3509 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) |
| 3510 | width = SM16BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3511 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3512 | width = SM8BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3513 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3514 | FPT_siwidr(port, width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3515 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3516 | currTar_Info->TarStatus |= (WIDE_NEGOCIATED | WIDE_ENABLED); |
| 3517 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3518 | } |
| 3519 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3520 | /*--------------------------------------------------------------------- |
| 3521 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3522 | * Function: FPT_siwidr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3523 | * |
| 3524 | * Description: Answer the targets Wide nego message. |
| 3525 | * |
| 3526 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3527 | static void FPT_siwidr(unsigned long port, unsigned char width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3528 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3529 | ARAM_ACCESS(port); |
| 3530 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); |
| 3531 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); |
| 3532 | WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMWDTR)); |
| 3533 | WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); |
| 3534 | WRW_HARPOON((port + SYNC_MSGS + 8), (MPM_OP + AMSG_OUT + width)); |
| 3535 | WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); |
| 3536 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3537 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3538 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
| 3539 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3540 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3541 | WR_HARPOON(port + hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3542 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3543 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | AUTO_INT))) { |
| 3544 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3545 | } |
| 3546 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3547 | /*--------------------------------------------------------------------- |
| 3548 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3549 | * Function: FPT_sssyncv |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3550 | * |
| 3551 | * Description: Write the desired value to the Sync Register for the |
| 3552 | * ID specified. |
| 3553 | * |
| 3554 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3555 | static void FPT_sssyncv(unsigned long p_port, unsigned char p_id, |
| 3556 | unsigned char p_sync_value, |
| 3557 | struct sccb_mgr_tar_info *currTar_Info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3558 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3559 | unsigned char index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3560 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3561 | index = p_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3562 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3563 | switch (index) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3564 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3565 | case 0: |
| 3566 | index = 12; /* hp_synctarg_0 */ |
| 3567 | break; |
| 3568 | case 1: |
| 3569 | index = 13; /* hp_synctarg_1 */ |
| 3570 | break; |
| 3571 | case 2: |
| 3572 | index = 14; /* hp_synctarg_2 */ |
| 3573 | break; |
| 3574 | case 3: |
| 3575 | index = 15; /* hp_synctarg_3 */ |
| 3576 | break; |
| 3577 | case 4: |
| 3578 | index = 8; /* hp_synctarg_4 */ |
| 3579 | break; |
| 3580 | case 5: |
| 3581 | index = 9; /* hp_synctarg_5 */ |
| 3582 | break; |
| 3583 | case 6: |
| 3584 | index = 10; /* hp_synctarg_6 */ |
| 3585 | break; |
| 3586 | case 7: |
| 3587 | index = 11; /* hp_synctarg_7 */ |
| 3588 | break; |
| 3589 | case 8: |
| 3590 | index = 4; /* hp_synctarg_8 */ |
| 3591 | break; |
| 3592 | case 9: |
| 3593 | index = 5; /* hp_synctarg_9 */ |
| 3594 | break; |
| 3595 | case 10: |
| 3596 | index = 6; /* hp_synctarg_10 */ |
| 3597 | break; |
| 3598 | case 11: |
| 3599 | index = 7; /* hp_synctarg_11 */ |
| 3600 | break; |
| 3601 | case 12: |
| 3602 | index = 0; /* hp_synctarg_12 */ |
| 3603 | break; |
| 3604 | case 13: |
| 3605 | index = 1; /* hp_synctarg_13 */ |
| 3606 | break; |
| 3607 | case 14: |
| 3608 | index = 2; /* hp_synctarg_14 */ |
| 3609 | break; |
| 3610 | case 15: |
| 3611 | index = 3; /* hp_synctarg_15 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3612 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3613 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3614 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3615 | WR_HARPOON(p_port + hp_synctarg_base + index, p_sync_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3616 | |
| 3617 | currTar_Info->TarSyncCtrl = p_sync_value; |
| 3618 | } |
| 3619 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3620 | /*--------------------------------------------------------------------- |
| 3621 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3622 | * Function: FPT_sresb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3623 | * |
| 3624 | * Description: Reset the desired card's SCSI bus. |
| 3625 | * |
| 3626 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3627 | static void FPT_sresb(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3628 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3629 | unsigned char scsiID, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3630 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3631 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3632 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3633 | WR_HARPOON(port + hp_page_ctrl, |
| 3634 | (RD_HARPOON(port + hp_page_ctrl) | G_INT_DISABLE)); |
| 3635 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3636 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3637 | WR_HARPOON(port + hp_scsictrl_0, SCSI_RST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3638 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3639 | scsiID = RD_HARPOON(port + hp_seltimeout); |
| 3640 | WR_HARPOON(port + hp_seltimeout, TO_5ms); |
| 3641 | WRW_HARPOON((port + hp_intstat), TIMEOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3642 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3643 | WR_HARPOON(port + hp_portctrl_0, (SCSI_PORT | START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3644 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3645 | while (!(RDW_HARPOON((port + hp_intstat)) & TIMEOUT)) { |
| 3646 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3647 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3648 | WR_HARPOON(port + hp_seltimeout, scsiID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3649 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3650 | WR_HARPOON(port + hp_scsictrl_0, ENA_SCAM_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3651 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3652 | FPT_Wait(port, TO_5ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3653 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3654 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3655 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3656 | 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] | 3657 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3658 | for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++) { |
| 3659 | currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3660 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3661 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 3662 | currTar_Info->TarSyncCtrl = 0; |
| 3663 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 3664 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3665 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3666 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 3667 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 3668 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3669 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3670 | FPT_sssyncv(port, scsiID, NARROW_SCSI, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3671 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3672 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 3673 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3674 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3675 | FPT_BL_Card[p_card].scanIndex = 0x00; |
| 3676 | FPT_BL_Card[p_card].currentSCCB = NULL; |
| 3677 | FPT_BL_Card[p_card].globalFlags &= ~(F_TAG_STARTED | F_HOST_XFER_ACT |
| 3678 | | F_NEW_SCCB_CMD); |
| 3679 | FPT_BL_Card[p_card].cmdCounter = 0x00; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3680 | FPT_BL_Card[p_card].discQCount = 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3681 | FPT_BL_Card[p_card].tagQ_Lst = 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3682 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3683 | for (i = 0; i < QUEUE_DEPTH; i++) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3684 | FPT_BL_Card[p_card].discQ_Tbl[i] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3685 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3686 | WR_HARPOON(port + hp_page_ctrl, |
| 3687 | (RD_HARPOON(port + hp_page_ctrl) & ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3688 | |
| 3689 | } |
| 3690 | |
| 3691 | /*--------------------------------------------------------------------- |
| 3692 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3693 | * Function: FPT_ssenss |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3694 | * |
| 3695 | * Description: Setup for the Auto Sense command. |
| 3696 | * |
| 3697 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3698 | static void FPT_ssenss(struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3699 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3700 | unsigned char i; |
| 3701 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3702 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3703 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3704 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3705 | currSCCB->Save_CdbLen = currSCCB->CdbLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3706 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3707 | for (i = 0; i < 6; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3708 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3709 | currSCCB->Save_Cdb[i] = currSCCB->Cdb[i]; |
| 3710 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3711 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3712 | currSCCB->CdbLength = SIX_BYTE_CMD; |
| 3713 | currSCCB->Cdb[0] = SCSI_REQUEST_SENSE; |
| 3714 | currSCCB->Cdb[1] = currSCCB->Cdb[1] & (unsigned char)0xE0; /*Keep LUN. */ |
| 3715 | currSCCB->Cdb[2] = 0x00; |
| 3716 | currSCCB->Cdb[3] = 0x00; |
| 3717 | currSCCB->Cdb[4] = currSCCB->RequestSenseLength; |
| 3718 | currSCCB->Cdb[5] = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3719 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3720 | currSCCB->Sccb_XferCnt = (unsigned long)currSCCB->RequestSenseLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3721 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3722 | currSCCB->Sccb_ATC = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3723 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3724 | currSCCB->Sccb_XferState |= F_AUTO_SENSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3725 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3726 | currSCCB->Sccb_XferState &= ~F_SG_XFER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3727 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3728 | currSCCB->Sccb_idmsg = currSCCB->Sccb_idmsg & ~(unsigned char)DISC_PRIV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3729 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3730 | currSCCB->ControlByte = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3731 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3732 | currSCCB->Sccb_MGRFlags &= F_STATUSLOADED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3733 | } |
| 3734 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3735 | /*--------------------------------------------------------------------- |
| 3736 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3737 | * Function: FPT_sxfrp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3738 | * |
| 3739 | * Description: Transfer data into the bit bucket until the device |
| 3740 | * decides to switch phase. |
| 3741 | * |
| 3742 | *---------------------------------------------------------------------*/ |
| 3743 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3744 | static void FPT_sxfrp(unsigned long p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3745 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3746 | unsigned char curr_phz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3747 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3748 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3749 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3750 | if (FPT_BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3751 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3752 | FPT_hostDataXferAbort(p_port, p_card, |
| 3753 | FPT_BL_Card[p_card].currentSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3754 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3755 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3756 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3757 | /* If the Automation handled the end of the transfer then do not |
| 3758 | 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] | 3759 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3760 | if (RDW_HARPOON((p_port + hp_intstat)) & |
| 3761 | (BUS_FREE | XFER_CNT_0 | AUTO_INT)) |
| 3762 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3763 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3764 | WR_HARPOON(p_port + hp_xfercnt_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3765 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3766 | 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] | 3767 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3768 | WRW_HARPOON((p_port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3769 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3770 | WR_HARPOON(p_port + hp_scsisig, curr_phz); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3771 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3772 | while (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET)) && |
| 3773 | (curr_phz == |
| 3774 | (RD_HARPOON(p_port + hp_scsisig) & (unsigned char)S_SCSI_PHZ))) |
| 3775 | { |
| 3776 | if (curr_phz & (unsigned char)SCSI_IOBIT) { |
| 3777 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3778 | (SCSI_PORT | HOST_PORT | SCSI_INBIT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3779 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3780 | if (!(RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY)) { |
| 3781 | RD_HARPOON(p_port + hp_fifodata_0); |
| 3782 | } |
| 3783 | } else { |
| 3784 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3785 | (SCSI_PORT | HOST_PORT | HOST_WRT)); |
| 3786 | if (RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY) { |
| 3787 | WR_HARPOON(p_port + hp_fifodata_0, 0xFA); |
| 3788 | } |
| 3789 | } |
| 3790 | } /* End of While loop for padding data I/O phase */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3791 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3792 | while (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET))) { |
| 3793 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_REQ) |
| 3794 | break; |
| 3795 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3796 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3797 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3798 | (SCSI_PORT | HOST_PORT | SCSI_INBIT)); |
| 3799 | while (!(RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY)) { |
| 3800 | RD_HARPOON(p_port + hp_fifodata_0); |
| 3801 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3802 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3803 | if (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET))) { |
| 3804 | WR_HARPOON(p_port + hp_autostart_0, |
| 3805 | (AUTO_IMMED + DISCONNECT_START)); |
| 3806 | while (!(RDW_HARPOON((p_port + hp_intstat)) & AUTO_INT)) { |
| 3807 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3808 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3809 | if (RDW_HARPOON((p_port + hp_intstat)) & |
| 3810 | (ICMD_COMP | ITAR_DISC)) |
| 3811 | while (! |
| 3812 | (RDW_HARPOON((p_port + hp_intstat)) & |
| 3813 | (BUS_FREE | RSEL))) ; |
| 3814 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3815 | } |
| 3816 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3817 | /*--------------------------------------------------------------------- |
| 3818 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3819 | * Function: FPT_schkdd |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3820 | * |
| 3821 | * Description: Make sure data has been flushed from both FIFOs and abort |
| 3822 | * the operations if necessary. |
| 3823 | * |
| 3824 | *---------------------------------------------------------------------*/ |
| 3825 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 3826 | static void FPT_schkdd(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3827 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3828 | unsigned short TimeOutLoop; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 3829 | unsigned char sPhase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3830 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3831 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3832 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3833 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3834 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3835 | if ((currSCCB->Sccb_scsistat != DATA_OUT_ST) && |
| 3836 | (currSCCB->Sccb_scsistat != DATA_IN_ST)) { |
| 3837 | return; |
| 3838 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3839 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3840 | if (currSCCB->Sccb_XferState & F_ODD_BALL_CNT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3841 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3842 | currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3843 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3844 | currSCCB->Sccb_XferCnt = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3845 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3846 | currSCCB->Sccb_XferState &= ~F_ODD_BALL_CNT; |
| 3847 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
| 3848 | WR_HARPOON(port + hp_xferstat, 0x00); |
| 3849 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3850 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3851 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3852 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3853 | currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3854 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3855 | currSCCB->Sccb_XferCnt = 0; |
| 3856 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3857 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3858 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 3859 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3860 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3861 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 3862 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 3863 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3865 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3866 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3867 | while (RD_HARPOON(port + hp_scsisig) & SCSI_ACK) { |
| 3868 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3869 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3870 | TimeOutLoop = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3871 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3872 | while (RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY) { |
| 3873 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 3874 | return; |
| 3875 | } |
| 3876 | if (RD_HARPOON(port + hp_offsetctr) & (unsigned char)0x1F) { |
| 3877 | break; |
| 3878 | } |
| 3879 | if (RDW_HARPOON((port + hp_intstat)) & RESET) { |
| 3880 | return; |
| 3881 | } |
| 3882 | if ((RD_HARPOON(port + hp_scsisig) & SCSI_REQ) |
| 3883 | || (TimeOutLoop++ > 0x3000)) |
| 3884 | break; |
| 3885 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3886 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3887 | sPhase = RD_HARPOON(port + hp_scsisig) & (SCSI_BSY | S_SCSI_PHZ); |
| 3888 | if ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) || |
| 3889 | (RD_HARPOON(port + hp_offsetctr) & (unsigned char)0x1F) || |
| 3890 | (sPhase == (SCSI_BSY | S_DATAO_PH)) || |
| 3891 | (sPhase == (SCSI_BSY | S_DATAI_PH))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3892 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3893 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3894 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3895 | if (!(currSCCB->Sccb_XferState & F_ALL_XFERRED)) { |
| 3896 | if (currSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
| 3897 | FPT_phaseDataIn(port, p_card); |
| 3898 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3899 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3900 | else { |
| 3901 | FPT_phaseDataOut(port, p_card); |
| 3902 | } |
| 3903 | } else { |
| 3904 | FPT_sxfrp(port, p_card); |
| 3905 | if (!(RDW_HARPOON((port + hp_intstat)) & |
| 3906 | (BUS_FREE | ICMD_COMP | ITAR_DISC | RESET))) { |
| 3907 | WRW_HARPOON((port + hp_intstat), AUTO_INT); |
| 3908 | FPT_phaseDecode(port, p_card); |
| 3909 | } |
| 3910 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3911 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3912 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3913 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3914 | else { |
| 3915 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
| 3916 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3917 | } |
| 3918 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3919 | /*--------------------------------------------------------------------- |
| 3920 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3921 | * Function: FPT_sinits |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3922 | * |
| 3923 | * Description: Setup SCCB manager fields in this SCCB. |
| 3924 | * |
| 3925 | *---------------------------------------------------------------------*/ |
| 3926 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3927 | static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3928 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3929 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3930 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3931 | if ((p_sccb->TargID > MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3932 | return; |
| 3933 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3934 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3935 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3936 | p_sccb->Sccb_XferState = 0x00; |
| 3937 | p_sccb->Sccb_XferCnt = p_sccb->DataLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3938 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3939 | if ((p_sccb->OperationCode == SCATTER_GATHER_COMMAND) || |
| 3940 | (p_sccb->OperationCode == RESIDUAL_SG_COMMAND)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3941 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3942 | p_sccb->Sccb_SGoffset = 0; |
| 3943 | p_sccb->Sccb_XferState = F_SG_XFER; |
| 3944 | p_sccb->Sccb_XferCnt = 0x00; |
| 3945 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3946 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3947 | if (p_sccb->DataLength == 0x00) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3948 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3949 | p_sccb->Sccb_XferState |= F_ALL_XFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3950 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3951 | if (p_sccb->ControlByte & F_USE_CMD_Q) { |
| 3952 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT) |
| 3953 | p_sccb->ControlByte &= ~F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3954 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3955 | else |
| 3956 | currTar_Info->TarStatus |= TAG_Q_TRYING; |
| 3957 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3958 | |
| 3959 | /* For !single SCSI device in system & device allow Disconnect |
| 3960 | or command is tag_q type then send Cmd with Disconnect Enable |
| 3961 | else send Cmd with Disconnect Disable */ |
| 3962 | |
| 3963 | /* |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3964 | if (((!(FPT_BL_Card[p_card].globalFlags & F_SINGLE_DEVICE)) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3965 | (currTar_Info->TarStatus & TAR_ALLOW_DISC)) || |
| 3966 | (currTar_Info->TarStatus & TAG_Q_TRYING)) { |
| 3967 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3968 | if ((currTar_Info->TarStatus & TAR_ALLOW_DISC) || |
| 3969 | (currTar_Info->TarStatus & TAG_Q_TRYING)) { |
| 3970 | p_sccb->Sccb_idmsg = |
| 3971 | (unsigned char)(SMIDENT | DISC_PRIV) | p_sccb->Lun; |
| 3972 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3973 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3974 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3975 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3976 | p_sccb->Sccb_idmsg = (unsigned char)SMIDENT | p_sccb->Lun; |
| 3977 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3978 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3979 | p_sccb->HostStatus = 0x00; |
| 3980 | p_sccb->TargetStatus = 0x00; |
| 3981 | p_sccb->Sccb_tag = 0x00; |
| 3982 | p_sccb->Sccb_MGRFlags = 0x00; |
| 3983 | p_sccb->Sccb_sgseg = 0x00; |
| 3984 | p_sccb->Sccb_ATC = 0x00; |
| 3985 | p_sccb->Sccb_savedATC = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3986 | /* |
| 3987 | p_sccb->SccbVirtDataPtr = 0x00; |
| 3988 | p_sccb->Sccb_forwardlink = NULL; |
| 3989 | p_sccb->Sccb_backlink = NULL; |
| 3990 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3991 | p_sccb->Sccb_scsistat = BUS_FREE_ST; |
| 3992 | p_sccb->SccbStatus = SCCB_IN_PROCESS; |
| 3993 | p_sccb->Sccb_scsimsg = SMNO_OP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3994 | |
| 3995 | } |
| 3996 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3997 | /*--------------------------------------------------------------------- |
| 3998 | * |
| 3999 | * Function: Phase Decode |
| 4000 | * |
| 4001 | * Description: Determine the phase and call the appropriate function. |
| 4002 | * |
| 4003 | *---------------------------------------------------------------------*/ |
| 4004 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4005 | static void FPT_phaseDecode(unsigned long p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4006 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4007 | unsigned char phase_ref; |
| 4008 | void (*phase) (unsigned long, unsigned char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4009 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4010 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4011 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4012 | phase_ref = |
| 4013 | (unsigned char)(RD_HARPOON(p_port + hp_scsisig) & S_SCSI_PHZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4014 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4015 | phase = FPT_s_PhaseTbl[phase_ref]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4016 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4017 | (*phase) (p_port, p_card); /* Call the correct phase func */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4018 | } |
| 4019 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4020 | /*--------------------------------------------------------------------- |
| 4021 | * |
| 4022 | * Function: Data Out Phase |
| 4023 | * |
| 4024 | * Description: Start up both the BusMaster and Xbow. |
| 4025 | * |
| 4026 | *---------------------------------------------------------------------*/ |
| 4027 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4028 | static void FPT_phaseDataOut(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4029 | { |
| 4030 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4031 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4033 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 4034 | if (currSCCB == NULL) { |
| 4035 | return; /* Exit if No SCCB record */ |
| 4036 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4037 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4038 | currSCCB->Sccb_scsistat = DATA_OUT_ST; |
| 4039 | currSCCB->Sccb_XferState &= ~(F_HOST_XFER_DIR | F_NO_DATA_YET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4040 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4041 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4043 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4044 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4045 | WR_HARPOON(port + hp_autostart_0, (END_DATA + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4046 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4047 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4048 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4049 | if (currSCCB->Sccb_XferCnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4050 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4051 | if ((currSCCB->ControlByte & SCCB_DATA_XFER_OUT) && |
| 4052 | (currSCCB->HostStatus == SCCB_COMPLETE)) |
| 4053 | currSCCB->HostStatus = SCCB_DATA_OVER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4054 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4055 | FPT_sxfrp(port, p_card); |
| 4056 | if (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | RESET))) |
| 4057 | FPT_phaseDecode(port, p_card); |
| 4058 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4059 | } |
| 4060 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4061 | /*--------------------------------------------------------------------- |
| 4062 | * |
| 4063 | * Function: Data In Phase |
| 4064 | * |
| 4065 | * Description: Startup the BusMaster and the XBOW. |
| 4066 | * |
| 4067 | *---------------------------------------------------------------------*/ |
| 4068 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4069 | static void FPT_phaseDataIn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4070 | { |
| 4071 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4072 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4073 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4074 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4075 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4076 | if (currSCCB == NULL) { |
| 4077 | return; /* Exit if No SCCB record */ |
| 4078 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4079 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4080 | currSCCB->Sccb_scsistat = DATA_IN_ST; |
| 4081 | currSCCB->Sccb_XferState |= F_HOST_XFER_DIR; |
| 4082 | currSCCB->Sccb_XferState &= ~F_NO_DATA_YET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4083 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4084 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4085 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4086 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4087 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4088 | WR_HARPOON(port + hp_autostart_0, (END_DATA + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4089 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4090 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4091 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4092 | if (currSCCB->Sccb_XferCnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4093 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4094 | if ((currSCCB->ControlByte & SCCB_DATA_XFER_IN) && |
| 4095 | (currSCCB->HostStatus == SCCB_COMPLETE)) |
| 4096 | currSCCB->HostStatus = SCCB_DATA_OVER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4097 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4098 | FPT_sxfrp(port, p_card); |
| 4099 | if (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | RESET))) |
| 4100 | FPT_phaseDecode(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4101 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4102 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4103 | } |
| 4104 | |
| 4105 | /*--------------------------------------------------------------------- |
| 4106 | * |
| 4107 | * Function: Command Phase |
| 4108 | * |
| 4109 | * Description: Load the CDB into the automation and start it up. |
| 4110 | * |
| 4111 | *---------------------------------------------------------------------*/ |
| 4112 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4113 | static void FPT_phaseCommand(unsigned long p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4114 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4115 | struct sccb *currSCCB; |
| 4116 | unsigned long cdb_reg; |
| 4117 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4118 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4119 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4120 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4121 | if (currSCCB->OperationCode == RESET_COMMAND) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4122 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4123 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4124 | currSCCB->CdbLength = SIX_BYTE_CMD; |
| 4125 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4126 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4127 | WR_HARPOON(p_port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4128 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4129 | ARAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4130 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4131 | cdb_reg = p_port + CMD_STRT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4132 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4133 | for (i = 0; i < currSCCB->CdbLength; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4134 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4135 | if (currSCCB->OperationCode == RESET_COMMAND) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4136 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4137 | WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + 0x00)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4138 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4139 | else |
| 4140 | WRW_HARPOON(cdb_reg, |
| 4141 | (MPM_OP + ACOMMAND + currSCCB->Cdb[i])); |
| 4142 | cdb_reg += 2; |
| 4143 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4144 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4145 | if (currSCCB->CdbLength != TWELVE_BYTE_CMD) |
| 4146 | WRW_HARPOON(cdb_reg, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4147 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4148 | WR_HARPOON(p_port + hp_portctrl_0, (SCSI_PORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4149 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4150 | currSCCB->Sccb_scsistat = COMMAND_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4151 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4152 | WR_HARPOON(p_port + hp_autostart_3, (AUTO_IMMED | CMD_ONLY_STRT)); |
| 4153 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4154 | } |
| 4155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4156 | /*--------------------------------------------------------------------- |
| 4157 | * |
| 4158 | * Function: Status phase |
| 4159 | * |
| 4160 | * Description: Bring in the status and command complete message bytes |
| 4161 | * |
| 4162 | *---------------------------------------------------------------------*/ |
| 4163 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4164 | static void FPT_phaseStatus(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4165 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4166 | /* Start-up the automation to finish off this command and let the |
| 4167 | isr handle the interrupt for command complete when it comes in. |
| 4168 | We could wait here for the interrupt to be generated? |
| 4169 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4170 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4171 | WR_HARPOON(port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4172 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4173 | WR_HARPOON(port + hp_autostart_0, (AUTO_IMMED + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4174 | } |
| 4175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4176 | /*--------------------------------------------------------------------- |
| 4177 | * |
| 4178 | * Function: Phase Message Out |
| 4179 | * |
| 4180 | * Description: Send out our message (if we have one) and handle whatever |
| 4181 | * else is involed. |
| 4182 | * |
| 4183 | *---------------------------------------------------------------------*/ |
| 4184 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4185 | static void FPT_phaseMsgOut(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4186 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4187 | unsigned char message, scsiID; |
| 4188 | struct sccb *currSCCB; |
| 4189 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4190 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4191 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4192 | |
| 4193 | if (currSCCB != NULL) { |
| 4194 | |
| 4195 | message = currSCCB->Sccb_scsimsg; |
| 4196 | scsiID = currSCCB->TargID; |
| 4197 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4198 | if (message == SMDEV_RESET) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4199 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4200 | currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4201 | currTar_Info->TarSyncCtrl = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4202 | FPT_sssyncv(port, scsiID, NARROW_SCSI, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4203 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4204 | if (FPT_sccbMgrTbl[p_card][scsiID]. |
| 4205 | TarEEValue & EE_SYNC_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4206 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4207 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus &= |
| 4208 | ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4209 | |
| 4210 | } |
| 4211 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4212 | if (FPT_sccbMgrTbl[p_card][scsiID]. |
| 4213 | TarEEValue & EE_WIDE_SCSI) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4214 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4215 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus &= |
| 4216 | ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4217 | } |
| 4218 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4219 | FPT_queueFlushSccb(p_card, SCCB_COMPLETE); |
| 4220 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 4221 | } else if (currSCCB->Sccb_scsistat == ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4222 | currSCCB->HostStatus = SCCB_COMPLETE; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4223 | if (FPT_BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] != |
| 4224 | NULL) { |
| 4225 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4226 | Sccb_tag] = NULL; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4227 | FPT_sccbMgrTbl[p_card][scsiID].TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4228 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4229 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4230 | } |
| 4231 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4232 | else if (currSCCB->Sccb_scsistat < COMMAND_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4233 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4234 | if (message == SMNO_OP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4235 | currSCCB->Sccb_MGRFlags |= F_DEV_SELECTED; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4236 | |
| 4237 | FPT_ssel(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4238 | return; |
| 4239 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4240 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4241 | |
| 4242 | if (message == SMABORT) |
| 4243 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4244 | FPT_queueFlushSccb(p_card, SCCB_COMPLETE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4245 | } |
| 4246 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4247 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4248 | message = SMABORT; |
| 4249 | } |
| 4250 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4251 | WRW_HARPOON((port + hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4252 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4253 | WR_HARPOON(port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4254 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4255 | WR_HARPOON(port + hp_scsidata_0, message); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4256 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4257 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4258 | |
| 4259 | ACCEPT_MSG(port); |
| 4260 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4261 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4262 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4263 | if ((message == SMABORT) || (message == SMDEV_RESET) || |
| 4264 | (message == SMABORT_TAG)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4266 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | PHASE))) { |
| 4267 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4268 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4269 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 4270 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4271 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4272 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4274 | if ((FPT_BL_Card[p_card]. |
| 4275 | globalFlags & F_CONLUN_IO) |
| 4276 | && |
| 4277 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4278 | TarStatus & TAR_TAG_Q_MASK) != |
| 4279 | TAG_Q_TRYING)) |
| 4280 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4281 | TargID]. |
| 4282 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4283 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4284 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4285 | TargID]. |
| 4286 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4287 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4288 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 4289 | currSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4290 | } |
| 4291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4292 | else { |
| 4293 | FPT_BL_Card[p_card].globalFlags |= |
| 4294 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4295 | } |
| 4296 | } |
| 4297 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4298 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4299 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4300 | FPT_sxfrp(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4301 | } |
| 4302 | } |
| 4303 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4304 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4305 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4306 | if (message == SMPARITY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4307 | currSCCB->Sccb_scsimsg = SMNO_OP; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4308 | WR_HARPOON(port + hp_autostart_1, |
| 4309 | (AUTO_IMMED + DISCONNECT_START)); |
| 4310 | } else { |
| 4311 | FPT_sxfrp(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4312 | } |
| 4313 | } |
| 4314 | } |
| 4315 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4316 | /*--------------------------------------------------------------------- |
| 4317 | * |
| 4318 | * Function: Message In phase |
| 4319 | * |
| 4320 | * Description: Bring in the message and determine what to do with it. |
| 4321 | * |
| 4322 | *---------------------------------------------------------------------*/ |
| 4323 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4324 | static void FPT_phaseMsgIn(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4325 | { |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 4326 | unsigned char message; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4327 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4328 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4329 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4330 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4331 | if (FPT_BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4332 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4333 | FPT_phaseChkFifo(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4334 | } |
| 4335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4336 | message = RD_HARPOON(port + hp_scsidata_0); |
| 4337 | if ((message == SMDISC) || (message == SMSAVE_DATA_PTR)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4338 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4339 | WR_HARPOON(port + hp_autostart_1, |
| 4340 | (AUTO_IMMED + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4341 | |
| 4342 | } |
| 4343 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4344 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4345 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4346 | message = FPT_sfm(port, currSCCB); |
| 4347 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4348 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4349 | FPT_sdecm(message, port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4350 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4351 | } else { |
| 4352 | if (currSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4353 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4354 | WR_HARPOON(port + hp_autostart_1, |
| 4355 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4356 | } |
| 4357 | } |
| 4358 | |
| 4359 | } |
| 4360 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4361 | /*--------------------------------------------------------------------- |
| 4362 | * |
| 4363 | * Function: Illegal phase |
| 4364 | * |
| 4365 | * Description: Target switched to some illegal phase, so all we can do |
| 4366 | * is report an error back to the host (if that is possible) |
| 4367 | * and send an ABORT message to the misbehaving target. |
| 4368 | * |
| 4369 | *---------------------------------------------------------------------*/ |
| 4370 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4371 | static void FPT_phaseIllegal(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4372 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4373 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4375 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4376 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4377 | WR_HARPOON(port + hp_scsisig, RD_HARPOON(port + hp_scsisig)); |
| 4378 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4379 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4380 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4381 | currSCCB->Sccb_scsistat = ABORT_ST; |
| 4382 | currSCCB->Sccb_scsimsg = SMABORT; |
| 4383 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4384 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4385 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4386 | } |
| 4387 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4388 | /*--------------------------------------------------------------------- |
| 4389 | * |
| 4390 | * Function: Phase Check FIFO |
| 4391 | * |
| 4392 | * Description: Make sure data has been flushed from both FIFOs and abort |
| 4393 | * the operations if necessary. |
| 4394 | * |
| 4395 | *---------------------------------------------------------------------*/ |
| 4396 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4397 | static void FPT_phaseChkFifo(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4398 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4399 | unsigned long xfercnt; |
| 4400 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4401 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4402 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4403 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4404 | if (currSCCB->Sccb_scsistat == DATA_IN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4405 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4406 | while ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) && |
| 4407 | (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY)) { |
| 4408 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4409 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4410 | if (!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) { |
| 4411 | currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4412 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4413 | currSCCB->Sccb_XferCnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4414 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4415 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 4416 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
| 4417 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 4418 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 4419 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4420 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4421 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4422 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4423 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4424 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4425 | while ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) |
| 4426 | && (RD_HARPOON(port + hp_ext_status) & |
| 4427 | BM_CMD_BUSY)) { |
| 4428 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4430 | } |
| 4431 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4432 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4433 | /*End Data In specific code. */ |
| 4434 | GET_XFER_CNT(port, xfercnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4435 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4436 | WR_HARPOON(port + hp_xfercnt_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4438 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4439 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4440 | currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - xfercnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4442 | currSCCB->Sccb_XferCnt = xfercnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4443 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4444 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 4445 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4446 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4447 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 4448 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 4449 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4450 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4451 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4452 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4453 | WR_HARPOON(port + hp_fifowrite, 0x00); |
| 4454 | WR_HARPOON(port + hp_fiforead, 0x00); |
| 4455 | WR_HARPOON(port + hp_xferstat, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4456 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4457 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4458 | } |
| 4459 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4460 | /*--------------------------------------------------------------------- |
| 4461 | * |
| 4462 | * Function: Phase Bus Free |
| 4463 | * |
| 4464 | * Description: We just went bus free so figure out if it was |
| 4465 | * because of command complete or from a disconnect. |
| 4466 | * |
| 4467 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4468 | static void FPT_phaseBusFree(unsigned long port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4469 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4470 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4471 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4472 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4473 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4474 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4475 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4476 | DISABLE_AUTO(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4477 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4478 | if (currSCCB->OperationCode == RESET_COMMAND) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4479 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4480 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4481 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4482 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4483 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4484 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4485 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4486 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4487 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4488 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4489 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, |
| 4490 | p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4492 | FPT_queueSearchSelect(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4493 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4494 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4495 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4496 | else if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
| 4497 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= |
| 4498 | (unsigned char)SYNC_SUPPORTED; |
| 4499 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4500 | ~EE_SYNC_MASK; |
| 4501 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4502 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4503 | else if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
| 4504 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus = |
| 4505 | (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4506 | TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4507 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4508 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4509 | ~EE_WIDE_SCSI; |
| 4510 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4511 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4512 | else if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { |
| 4513 | /* Make sure this is not a phony BUS_FREE. If we were |
| 4514 | reselected or if BUSY is NOT on then this is a |
| 4515 | valid BUS FREE. SRR Wednesday, 5/10/1995. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4516 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4517 | if ((!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) || |
| 4518 | (RDW_HARPOON((port + hp_intstat)) & RSEL)) { |
| 4519 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4520 | TarStatus &= ~TAR_TAG_Q_MASK; |
| 4521 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4522 | TarStatus |= TAG_Q_REJECT; |
| 4523 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4524 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4525 | else { |
| 4526 | return; |
| 4527 | } |
| 4528 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4529 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4530 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4531 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4532 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4533 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4534 | if (!currSCCB->HostStatus) { |
| 4535 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4536 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4537 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4538 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4539 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4540 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4541 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4542 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4543 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4544 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4545 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4546 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4547 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, |
| 4548 | p_card); |
| 4549 | return; |
| 4550 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4551 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4552 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4553 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4554 | } /*end if !=null */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4555 | } |
| 4556 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4557 | /*--------------------------------------------------------------------- |
| 4558 | * |
| 4559 | * Function: Auto Load Default Map |
| 4560 | * |
| 4561 | * Description: Load the Automation RAM with the defualt map values. |
| 4562 | * |
| 4563 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4564 | static void FPT_autoLoadDefaultMap(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4565 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4566 | unsigned long map_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4567 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4568 | ARAM_ACCESS(p_port); |
| 4569 | map_addr = p_port + hp_aramBase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4570 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4571 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0xC0)); /*ID MESSAGE */ |
| 4572 | map_addr += 2; |
| 4573 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0x20)); /*SIMPLE TAG QUEUEING MSG */ |
| 4574 | map_addr += 2; |
| 4575 | WRW_HARPOON(map_addr, RAT_OP); /*RESET ATTENTION */ |
| 4576 | map_addr += 2; |
| 4577 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0x00)); /*TAG ID MSG */ |
| 4578 | map_addr += 2; |
| 4579 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 0 */ |
| 4580 | map_addr += 2; |
| 4581 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 1 */ |
| 4582 | map_addr += 2; |
| 4583 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 2 */ |
| 4584 | map_addr += 2; |
| 4585 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 3 */ |
| 4586 | map_addr += 2; |
| 4587 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 4 */ |
| 4588 | map_addr += 2; |
| 4589 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 5 */ |
| 4590 | map_addr += 2; |
| 4591 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 6 */ |
| 4592 | map_addr += 2; |
| 4593 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 7 */ |
| 4594 | map_addr += 2; |
| 4595 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 8 */ |
| 4596 | map_addr += 2; |
| 4597 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 9 */ |
| 4598 | map_addr += 2; |
| 4599 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 10 */ |
| 4600 | map_addr += 2; |
| 4601 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 11 */ |
| 4602 | map_addr += 2; |
| 4603 | WRW_HARPOON(map_addr, (CPE_OP + ADATA_OUT + DINT)); /*JUMP IF DATA OUT */ |
| 4604 | map_addr += 2; |
| 4605 | WRW_HARPOON(map_addr, (TCB_OP + FIFO_0 + DI)); /*JUMP IF NO DATA IN FIFO */ |
| 4606 | map_addr += 2; /*This means AYNC DATA IN */ |
| 4607 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IDO_STRT)); /*STOP AND INTERRUPT */ |
| 4608 | map_addr += 2; |
| 4609 | WRW_HARPOON(map_addr, (CPE_OP + ADATA_IN + DINT)); /*JUMP IF NOT DATA IN PHZ */ |
| 4610 | map_addr += 2; |
| 4611 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + ST)); /*IF NOT MSG IN CHECK 4 DATA IN */ |
| 4612 | map_addr += 2; |
| 4613 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x02)); /*SAVE DATA PTR MSG? */ |
| 4614 | map_addr += 2; |
| 4615 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + DC)); /*GO CHECK FOR DISCONNECT MSG */ |
| 4616 | map_addr += 2; |
| 4617 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_AR1)); /*SAVE DATA PTRS MSG */ |
| 4618 | map_addr += 2; |
| 4619 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + ST)); /*IF NOT MSG IN CHECK DATA IN */ |
| 4620 | map_addr += 2; |
| 4621 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x04)); /*DISCONNECT MSG? */ |
| 4622 | map_addr += 2; |
| 4623 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + UNKNWN)); /*UKNKNOWN MSG */ |
| 4624 | map_addr += 2; |
| 4625 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_BUCKET)); /*XFER DISCONNECT MSG */ |
| 4626 | map_addr += 2; |
| 4627 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ITAR_DISC)); /*STOP AND INTERRUPT */ |
| 4628 | map_addr += 2; |
| 4629 | WRW_HARPOON(map_addr, (CPN_OP + ASTATUS + UNKNWN)); /*JUMP IF NOT STATUS PHZ. */ |
| 4630 | map_addr += 2; |
| 4631 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_AR0)); /*GET STATUS BYTE */ |
| 4632 | map_addr += 2; |
| 4633 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + CC)); /*ERROR IF NOT MSG IN PHZ */ |
| 4634 | map_addr += 2; |
| 4635 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x00)); /*CHECK FOR CMD COMPLETE MSG. */ |
| 4636 | map_addr += 2; |
| 4637 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + CC)); /*ERROR IF NOT CMD COMPLETE MSG. */ |
| 4638 | map_addr += 2; |
| 4639 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_BUCKET)); /*GET CMD COMPLETE MSG */ |
| 4640 | map_addr += 2; |
| 4641 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ICMD_COMP)); /*END OF COMMAND */ |
| 4642 | map_addr += 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4643 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4644 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IUNKWN)); /*RECEIVED UNKNOWN MSG BYTE */ |
| 4645 | map_addr += 2; |
| 4646 | WRW_HARPOON(map_addr, (SSI_OP + SSI_INO_CC)); /*NO COMMAND COMPLETE AFTER STATUS */ |
| 4647 | map_addr += 2; |
| 4648 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ITICKLE)); /*BIOS Tickled the Mgr */ |
| 4649 | map_addr += 2; |
| 4650 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IRFAIL)); /*EXPECTED ID/TAG MESSAGES AND */ |
| 4651 | map_addr += 2; /* DIDN'T GET ONE */ |
| 4652 | WRW_HARPOON(map_addr, (CRR_OP + AR3 + S_IDREG)); /* comp SCSI SEL ID & AR3 */ |
| 4653 | map_addr += 2; |
| 4654 | WRW_HARPOON(map_addr, (BRH_OP + EQUAL + 0x00)); /*SEL ID OK then Conti. */ |
| 4655 | map_addr += 2; |
| 4656 | 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] | 4657 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4658 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4659 | } |
| 4660 | |
| 4661 | /*--------------------------------------------------------------------- |
| 4662 | * |
| 4663 | * Function: Auto Command Complete |
| 4664 | * |
| 4665 | * Description: Post command back to host and find another command |
| 4666 | * to execute. |
| 4667 | * |
| 4668 | *---------------------------------------------------------------------*/ |
| 4669 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 4670 | static void FPT_autoCmdCmplt(unsigned long p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4671 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4672 | struct sccb *currSCCB; |
| 4673 | unsigned char status_byte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4674 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4675 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4676 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4677 | status_byte = RD_HARPOON(p_port + hp_gp_reg_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4678 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4679 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUN_CA = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4680 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4681 | if (status_byte != SSGOOD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4682 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4683 | if (status_byte == SSQ_FULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4684 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4685 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4686 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4687 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4688 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4689 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4690 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4691 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4692 | FPT_BL_Card[p_card]. |
| 4693 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4694 | [currSCCB->TargID]. |
| 4695 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4696 | NULL; |
| 4697 | } else { |
| 4698 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4699 | TarLUNBusy[0] = 1; |
| 4700 | if (currSCCB->Sccb_tag) { |
| 4701 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4702 | FPT_BL_Card[p_card]. |
| 4703 | discQCount--; |
| 4704 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4705 | Sccb_tag] |
| 4706 | = NULL; |
| 4707 | } else { |
| 4708 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4709 | FPT_BL_Card[p_card]. |
| 4710 | discQCount--; |
| 4711 | FPT_BL_Card[p_card]. |
| 4712 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4713 | [currSCCB->TargID]. |
| 4714 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4715 | } |
| 4716 | } |
| 4717 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4718 | currSCCB->Sccb_MGRFlags |= F_STATUSLOADED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4719 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4720 | FPT_queueSelectFail(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4721 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4722 | return; |
| 4723 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4724 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4725 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
| 4726 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= |
| 4727 | (unsigned char)SYNC_SUPPORTED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4728 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4729 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4730 | ~EE_SYNC_MASK; |
| 4731 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4732 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4733 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4734 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4735 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4736 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4737 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4738 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4739 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4740 | FPT_BL_Card[p_card]. |
| 4741 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4742 | [currSCCB->TargID]. |
| 4743 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4744 | NULL; |
| 4745 | } else { |
| 4746 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4747 | TarLUNBusy[0] = 1; |
| 4748 | if (currSCCB->Sccb_tag) { |
| 4749 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4750 | FPT_BL_Card[p_card]. |
| 4751 | discQCount--; |
| 4752 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4753 | Sccb_tag] |
| 4754 | = NULL; |
| 4755 | } else { |
| 4756 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4757 | FPT_BL_Card[p_card]. |
| 4758 | discQCount--; |
| 4759 | FPT_BL_Card[p_card]. |
| 4760 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4761 | [currSCCB->TargID]. |
| 4762 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4763 | } |
| 4764 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4765 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4766 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4767 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4768 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4769 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4770 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4771 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus = |
| 4772 | (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4773 | TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4774 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4775 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4776 | ~EE_WIDE_SCSI; |
| 4777 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4778 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4779 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4780 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4781 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4782 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4783 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4784 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4785 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4786 | FPT_BL_Card[p_card]. |
| 4787 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4788 | [currSCCB->TargID]. |
| 4789 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4790 | NULL; |
| 4791 | } else { |
| 4792 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4793 | TarLUNBusy[0] = 1; |
| 4794 | if (currSCCB->Sccb_tag) { |
| 4795 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4796 | FPT_BL_Card[p_card]. |
| 4797 | discQCount--; |
| 4798 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4799 | Sccb_tag] |
| 4800 | = NULL; |
| 4801 | } else { |
| 4802 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4803 | FPT_BL_Card[p_card]. |
| 4804 | discQCount--; |
| 4805 | FPT_BL_Card[p_card]. |
| 4806 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4807 | [currSCCB->TargID]. |
| 4808 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4809 | } |
| 4810 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4811 | return; |
| 4812 | |
| 4813 | } |
| 4814 | |
| 4815 | if (status_byte == SSCHECK) { |
| 4816 | if (FPT_BL_Card[p_card].globalFlags & F_DO_RENEGO) { |
| 4817 | if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4818 | TarEEValue & EE_SYNC_MASK) { |
| 4819 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4820 | TargID]. |
| 4821 | TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4822 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4823 | if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4824 | TarEEValue & EE_WIDE_SCSI) { |
| 4825 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4826 | TargID]. |
| 4827 | TarStatus &= ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4828 | } |
| 4829 | } |
| 4830 | } |
| 4831 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4832 | if (!(currSCCB->Sccb_XferState & F_AUTO_SENSE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4833 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4834 | currSCCB->SccbStatus = SCCB_ERROR; |
| 4835 | currSCCB->TargetStatus = status_byte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4836 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4837 | if (status_byte == SSCHECK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4838 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4839 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4840 | TarLUN_CA = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4841 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4842 | if (currSCCB->RequestSenseLength != |
| 4843 | NO_AUTO_REQUEST_SENSE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4844 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4845 | if (currSCCB->RequestSenseLength == 0) |
| 4846 | currSCCB->RequestSenseLength = |
| 4847 | 14; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4848 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4849 | FPT_ssenss(&FPT_BL_Card[p_card]); |
| 4850 | FPT_BL_Card[p_card].globalFlags |= |
| 4851 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4852 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4853 | if (((FPT_BL_Card[p_card]. |
| 4854 | globalFlags & F_CONLUN_IO) |
| 4855 | && |
| 4856 | ((FPT_sccbMgrTbl[p_card] |
| 4857 | [currSCCB->TargID]. |
| 4858 | TarStatus & TAR_TAG_Q_MASK) != |
| 4859 | TAG_Q_TRYING))) { |
| 4860 | FPT_sccbMgrTbl[p_card] |
| 4861 | [currSCCB->TargID]. |
| 4862 | TarLUNBusy[currSCCB->Lun] = |
| 4863 | 1; |
| 4864 | if (FPT_BL_Card[p_card]. |
| 4865 | discQCount != 0) |
| 4866 | FPT_BL_Card[p_card]. |
| 4867 | discQCount--; |
| 4868 | FPT_BL_Card[p_card]. |
| 4869 | discQ_Tbl[FPT_sccbMgrTbl |
| 4870 | [p_card] |
| 4871 | [currSCCB-> |
| 4872 | TargID]. |
| 4873 | LunDiscQ_Idx |
| 4874 | [currSCCB->Lun]] = |
| 4875 | NULL; |
| 4876 | } else { |
| 4877 | FPT_sccbMgrTbl[p_card] |
| 4878 | [currSCCB->TargID]. |
| 4879 | TarLUNBusy[0] = 1; |
| 4880 | if (currSCCB->Sccb_tag) { |
| 4881 | if (FPT_BL_Card[p_card]. |
| 4882 | discQCount != 0) |
| 4883 | FPT_BL_Card |
| 4884 | [p_card]. |
| 4885 | discQCount--; |
| 4886 | FPT_BL_Card[p_card]. |
| 4887 | discQ_Tbl[currSCCB-> |
| 4888 | Sccb_tag] |
| 4889 | = NULL; |
| 4890 | } else { |
| 4891 | if (FPT_BL_Card[p_card]. |
| 4892 | discQCount != 0) |
| 4893 | FPT_BL_Card |
| 4894 | [p_card]. |
| 4895 | discQCount--; |
| 4896 | FPT_BL_Card[p_card]. |
| 4897 | discQ_Tbl |
| 4898 | [FPT_sccbMgrTbl |
| 4899 | [p_card][currSCCB-> |
| 4900 | TargID]. |
| 4901 | LunDiscQ_Idx[0]] = |
| 4902 | NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4903 | } |
| 4904 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4905 | return; |
| 4906 | } |
| 4907 | } |
| 4908 | } |
| 4909 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4910 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4911 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4912 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4913 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4914 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB-> |
| 4915 | Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4916 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4917 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4918 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4919 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4920 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4921 | |
| 4922 | #define SHORT_WAIT 0x0000000F |
| 4923 | #define LONG_WAIT 0x0000FFFFL |
| 4924 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4925 | /*--------------------------------------------------------------------- |
| 4926 | * |
| 4927 | * Function: Data Transfer Processor |
| 4928 | * |
| 4929 | * Description: This routine performs two tasks. |
| 4930 | * (1) Start data transfer by calling HOST_DATA_XFER_START |
| 4931 | * function. Once data transfer is started, (2) Depends |
| 4932 | * on the type of data transfer mode Scatter/Gather mode |
| 4933 | * or NON Scatter/Gather mode. In NON Scatter/Gather mode, |
| 4934 | * this routine checks Sccb_MGRFlag (F_HOST_XFER_ACT bit) for |
| 4935 | * data transfer done. In Scatter/Gather mode, this routine |
| 4936 | * checks bus master command complete and dual rank busy |
| 4937 | * bit to keep chaining SC transfer command. Similarly, |
| 4938 | * in Scatter/Gather mode, it checks Sccb_MGRFlag |
| 4939 | * (F_HOST_XFER_ACT bit) for data transfer done. |
| 4940 | * |
| 4941 | *---------------------------------------------------------------------*/ |
| 4942 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4943 | static void FPT_dataXferProcessor(unsigned long port, |
| 4944 | struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4945 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4946 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4947 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4948 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4949 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4950 | if (currSCCB->Sccb_XferState & F_SG_XFER) { |
| 4951 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
| 4952 | { |
| 4953 | currSCCB->Sccb_sgseg += (unsigned char)SG_BUF_CNT; |
| 4954 | currSCCB->Sccb_SGoffset = 0x00; |
| 4955 | } |
| 4956 | pCurrCard->globalFlags |= F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4957 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4958 | FPT_busMstrSGDataXferStart(port, currSCCB); |
| 4959 | } |
| 4960 | |
| 4961 | else { |
| 4962 | if (!(pCurrCard->globalFlags & F_HOST_XFER_ACT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4963 | pCurrCard->globalFlags |= F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4964 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4965 | FPT_busMstrDataXferStart(port, currSCCB); |
| 4966 | } |
| 4967 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4968 | } |
| 4969 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4970 | /*--------------------------------------------------------------------- |
| 4971 | * |
| 4972 | * Function: BusMaster Scatter Gather Data Transfer Start |
| 4973 | * |
| 4974 | * Description: |
| 4975 | * |
| 4976 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4977 | static void FPT_busMstrSGDataXferStart(unsigned long p_port, |
| 4978 | struct sccb *pcurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4979 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4980 | unsigned long count, addr, tmpSGCnt; |
| 4981 | unsigned int sg_index; |
| 4982 | unsigned char sg_count, i; |
| 4983 | unsigned long reg_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4984 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4985 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4986 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4987 | count = ((unsigned long)HOST_RD_CMD) << 24; |
| 4988 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4989 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4990 | else { |
| 4991 | count = ((unsigned long)HOST_WRT_CMD) << 24; |
| 4992 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4993 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4994 | sg_count = 0; |
| 4995 | tmpSGCnt = 0; |
| 4996 | sg_index = pcurrSCCB->Sccb_sgseg; |
| 4997 | reg_offset = hp_aramBase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4998 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4999 | i = (unsigned char)(RD_HARPOON(p_port + hp_page_ctrl) & |
| 5000 | ~(SGRAM_ARAM | SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5001 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5002 | WR_HARPOON(p_port + hp_page_ctrl, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5003 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5004 | while ((sg_count < (unsigned char)SG_BUF_CNT) && |
| 5005 | ((unsigned long)(sg_index * (unsigned int)SG_ELEMENT_SIZE) < |
| 5006 | pcurrSCCB->DataLength)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5007 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5008 | tmpSGCnt += *(((unsigned long *)pcurrSCCB->DataPointer) + |
| 5009 | (sg_index * 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5010 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5011 | count |= *(((unsigned long *)pcurrSCCB->DataPointer) + |
| 5012 | (sg_index * 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5013 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5014 | addr = *(((unsigned long *)pcurrSCCB->DataPointer) + |
| 5015 | ((sg_index * 2) + 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5016 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5017 | if ((!sg_count) && (pcurrSCCB->Sccb_SGoffset)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5018 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5019 | addr += |
| 5020 | ((count & 0x00FFFFFFL) - pcurrSCCB->Sccb_SGoffset); |
| 5021 | count = |
| 5022 | (count & 0xFF000000L) | pcurrSCCB->Sccb_SGoffset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5023 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5024 | tmpSGCnt = count & 0x00FFFFFFL; |
| 5025 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5026 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5027 | WR_HARP32(p_port, reg_offset, addr); |
| 5028 | reg_offset += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5029 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5030 | WR_HARP32(p_port, reg_offset, count); |
| 5031 | reg_offset += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5033 | count &= 0xFF000000L; |
| 5034 | sg_index++; |
| 5035 | sg_count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5036 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5037 | } /*End While */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5038 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5039 | pcurrSCCB->Sccb_XferCnt = tmpSGCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5040 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5041 | WR_HARPOON(p_port + hp_sg_addr, (sg_count << 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5043 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5044 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5045 | WR_HARP32(p_port, hp_xfercnt_0, tmpSGCnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5046 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5047 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5048 | (DMA_PORT | SCSI_PORT | SCSI_INBIT)); |
| 5049 | WR_HARPOON(p_port + hp_scsisig, S_DATAI_PH); |
| 5050 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5051 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5052 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5053 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5054 | if ((!(RD_HARPOON(p_port + hp_synctarg_0) & NARROW_SCSI)) && |
| 5055 | (tmpSGCnt & 0x000000001)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5056 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5057 | pcurrSCCB->Sccb_XferState |= F_ODD_BALL_CNT; |
| 5058 | tmpSGCnt--; |
| 5059 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5060 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5061 | WR_HARP32(p_port, hp_xfercnt_0, tmpSGCnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5062 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5063 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5064 | (SCSI_PORT | DMA_PORT | DMA_RD)); |
| 5065 | WR_HARPOON(p_port + hp_scsisig, S_DATAO_PH); |
| 5066 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5067 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5068 | WR_HARPOON(p_port + hp_page_ctrl, (unsigned char)(i | SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5069 | |
| 5070 | } |
| 5071 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5072 | /*--------------------------------------------------------------------- |
| 5073 | * |
| 5074 | * Function: BusMaster Data Transfer Start |
| 5075 | * |
| 5076 | * Description: |
| 5077 | * |
| 5078 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5079 | static void FPT_busMstrDataXferStart(unsigned long p_port, |
| 5080 | struct sccb *pcurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5081 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5082 | unsigned long addr, count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5083 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5084 | if (!(pcurrSCCB->Sccb_XferState & F_AUTO_SENSE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5085 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5086 | count = pcurrSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5087 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5088 | addr = |
| 5089 | (unsigned long)pcurrSCCB->DataPointer + pcurrSCCB->Sccb_ATC; |
| 5090 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5091 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5092 | else { |
| 5093 | addr = pcurrSCCB->SensePointer; |
| 5094 | count = pcurrSCCB->RequestSenseLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5095 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5096 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5097 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5098 | HP_SETUP_ADDR_CNT(p_port, addr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5099 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5100 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5101 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5102 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5103 | (DMA_PORT | SCSI_PORT | SCSI_INBIT)); |
| 5104 | WR_HARPOON(p_port + hp_scsisig, S_DATAI_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5105 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5106 | WR_HARPOON(p_port + hp_xfer_cmd, |
| 5107 | (XFER_DMA_HOST | XFER_HOST_AUTO | XFER_DMA_8BIT)); |
| 5108 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5109 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5110 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5111 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5112 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5113 | (SCSI_PORT | DMA_PORT | DMA_RD)); |
| 5114 | WR_HARPOON(p_port + hp_scsisig, S_DATAO_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5115 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5116 | WR_HARPOON(p_port + hp_xfer_cmd, |
| 5117 | (XFER_HOST_DMA | XFER_HOST_AUTO | XFER_DMA_8BIT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5118 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5119 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5120 | } |
| 5121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5122 | /*--------------------------------------------------------------------- |
| 5123 | * |
| 5124 | * Function: BusMaster Timeout Handler |
| 5125 | * |
| 5126 | * Description: This function is called after a bus master command busy time |
| 5127 | * out is detected. This routines issue halt state machine |
| 5128 | * with a software time out for command busy. If command busy |
| 5129 | * is still asserted at the end of the time out, it issues |
| 5130 | * hard abort with another software time out. It hard abort |
| 5131 | * command busy is also time out, it'll just give up. |
| 5132 | * |
| 5133 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5134 | static unsigned char FPT_busMstrTimeOut(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5135 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5136 | unsigned long timeout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5137 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5138 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5139 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5140 | WR_HARPOON(p_port + hp_sys_ctrl, HALT_MACH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5141 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5142 | while ((!(RD_HARPOON(p_port + hp_ext_status) & CMD_ABORTED)) |
| 5143 | && timeout--) { |
| 5144 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5145 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5146 | if (RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) { |
| 5147 | WR_HARPOON(p_port + hp_sys_ctrl, HARD_ABORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5148 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5149 | timeout = LONG_WAIT; |
| 5150 | while ((RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) |
| 5151 | && timeout--) { |
| 5152 | } |
| 5153 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5154 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5155 | RD_HARPOON(p_port + hp_int_status); /*Clear command complete */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5156 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5157 | if (RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5158 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5159 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5160 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5161 | else { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5162 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5164 | } |
| 5165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5166 | /*--------------------------------------------------------------------- |
| 5167 | * |
| 5168 | * Function: Host Data Transfer Abort |
| 5169 | * |
| 5170 | * Description: Abort any in progress transfer. |
| 5171 | * |
| 5172 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5173 | static void FPT_hostDataXferAbort(unsigned long port, unsigned char p_card, |
| 5174 | struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5175 | { |
| 5176 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5177 | unsigned long timeout; |
| 5178 | unsigned long remain_cnt; |
| 5179 | unsigned int sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5180 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5181 | FPT_BL_Card[p_card].globalFlags &= ~F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5182 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5183 | if (pCurrSCCB->Sccb_XferState & F_AUTO_SENSE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5184 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5185 | if (!(RD_HARPOON(port + hp_int_status) & INT_CMD_COMPL)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5186 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5187 | WR_HARPOON(port + hp_bm_ctrl, |
| 5188 | (RD_HARPOON(port + hp_bm_ctrl) | |
| 5189 | FLUSH_XFER_CNTR)); |
| 5190 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5191 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5192 | while ((RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) |
| 5193 | && timeout--) { |
| 5194 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5195 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5196 | WR_HARPOON(port + hp_bm_ctrl, |
| 5197 | (RD_HARPOON(port + hp_bm_ctrl) & |
| 5198 | ~FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5199 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5200 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5201 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5202 | if (FPT_busMstrTimeOut(port)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5203 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5204 | if (pCurrSCCB->HostStatus == 0x00) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5205 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5206 | pCurrSCCB->HostStatus = |
| 5207 | SCCB_BM_ERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5208 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5209 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5210 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5211 | if (RD_HARPOON(port + hp_int_status) & |
| 5212 | INT_EXT_STATUS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5213 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5214 | if (RD_HARPOON(port + hp_ext_status) & |
| 5215 | BAD_EXT_STATUS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5216 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5217 | if (pCurrSCCB->HostStatus == |
| 5218 | 0x00) |
| 5219 | { |
| 5220 | pCurrSCCB->HostStatus = |
| 5221 | SCCB_BM_ERR; |
| 5222 | } |
| 5223 | } |
| 5224 | } |
| 5225 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5226 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5227 | else if (pCurrSCCB->Sccb_XferCnt) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5228 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5229 | if (pCurrSCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5230 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5231 | WR_HARPOON(port + hp_page_ctrl, |
| 5232 | (RD_HARPOON(port + hp_page_ctrl) & |
| 5233 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5234 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5235 | WR_HARPOON(port + hp_sg_addr, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5236 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5237 | sg_ptr = pCurrSCCB->Sccb_sgseg + SG_BUF_CNT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5238 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5239 | if (sg_ptr > |
| 5240 | (unsigned int)(pCurrSCCB->DataLength / |
| 5241 | SG_ELEMENT_SIZE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5242 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5243 | sg_ptr = |
| 5244 | (unsigned int)(pCurrSCCB->DataLength / |
| 5245 | SG_ELEMENT_SIZE); |
| 5246 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5247 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5248 | remain_cnt = pCurrSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5249 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5250 | while (remain_cnt < 0x01000000L) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5251 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5252 | sg_ptr--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5253 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5254 | if (remain_cnt > |
| 5255 | (unsigned |
| 5256 | long)(*(((unsigned long *)pCurrSCCB-> |
| 5257 | DataPointer) + (sg_ptr * 2)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5258 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5259 | remain_cnt -= |
| 5260 | (unsigned |
| 5261 | long)(*(((unsigned long *) |
| 5262 | pCurrSCCB->DataPointer) + |
| 5263 | (sg_ptr * 2))); |
| 5264 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5266 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5267 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5268 | break; |
| 5269 | } |
| 5270 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5271 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5272 | if (remain_cnt < 0x01000000L) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5274 | pCurrSCCB->Sccb_SGoffset = remain_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5275 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5276 | pCurrSCCB->Sccb_sgseg = (unsigned short)sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5277 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5278 | if ((unsigned long)(sg_ptr * SG_ELEMENT_SIZE) == |
| 5279 | pCurrSCCB->DataLength && (remain_cnt == 0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5280 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5281 | pCurrSCCB->Sccb_XferState |= |
| 5282 | F_ALL_XFERRED; |
| 5283 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5284 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5285 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5286 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5287 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5288 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5289 | pCurrSCCB->HostStatus = |
| 5290 | SCCB_GROSS_FW_ERR; |
| 5291 | } |
| 5292 | } |
| 5293 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5294 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5295 | if (!(pCurrSCCB->Sccb_XferState & F_HOST_XFER_DIR)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5296 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5297 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5298 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5299 | FPT_busMstrTimeOut(port); |
| 5300 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5301 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5302 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5303 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5304 | if (RD_HARPOON(port + hp_int_status) & |
| 5305 | INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5306 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5307 | if (RD_HARPOON(port + hp_ext_status) & |
| 5308 | BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5309 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5310 | if (pCurrSCCB->HostStatus == |
| 5311 | 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5312 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5313 | pCurrSCCB->HostStatus = |
| 5314 | SCCB_BM_ERR; |
| 5315 | } |
| 5316 | } |
| 5317 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5318 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5319 | } |
| 5320 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5321 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5322 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5323 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5324 | if ((RD_HARPOON(port + hp_fifo_cnt)) >= BM_THRESHOLD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5325 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5326 | timeout = SHORT_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5327 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5328 | while ((RD_HARPOON(port + hp_ext_status) & |
| 5329 | BM_CMD_BUSY) |
| 5330 | && ((RD_HARPOON(port + hp_fifo_cnt)) >= |
| 5331 | BM_THRESHOLD) && timeout--) { |
| 5332 | } |
| 5333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5334 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5335 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5336 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5337 | WR_HARPOON(port + hp_bm_ctrl, |
| 5338 | (RD_HARPOON(port + hp_bm_ctrl) | |
| 5339 | FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5340 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5341 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5342 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5343 | while ((RD_HARPOON(port + hp_ext_status) & |
| 5344 | BM_CMD_BUSY) && timeout--) { |
| 5345 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5346 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5347 | WR_HARPOON(port + hp_bm_ctrl, |
| 5348 | (RD_HARPOON(port + hp_bm_ctrl) & |
| 5349 | ~FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5350 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5351 | if (RD_HARPOON(port + hp_ext_status) & |
| 5352 | BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5353 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5354 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5355 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5356 | pCurrSCCB->HostStatus = |
| 5357 | SCCB_BM_ERR; |
| 5358 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5359 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5360 | FPT_busMstrTimeOut(port); |
| 5361 | } |
| 5362 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5363 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5364 | if (RD_HARPOON(port + hp_int_status) & INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5365 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5366 | if (RD_HARPOON(port + hp_ext_status) & |
| 5367 | BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5368 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5369 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5370 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5371 | pCurrSCCB->HostStatus = |
| 5372 | SCCB_BM_ERR; |
| 5373 | } |
| 5374 | } |
| 5375 | } |
| 5376 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5377 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5378 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5379 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5380 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5381 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5382 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5383 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5384 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5385 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5386 | while ((RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) |
| 5387 | && timeout--) { |
| 5388 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5389 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5390 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5391 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5392 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5393 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5394 | pCurrSCCB->HostStatus = SCCB_BM_ERR; |
| 5395 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5396 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5397 | FPT_busMstrTimeOut(port); |
| 5398 | } |
| 5399 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5400 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5401 | if (RD_HARPOON(port + hp_int_status) & INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5402 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5403 | if (RD_HARPOON(port + hp_ext_status) & BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5404 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5405 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5406 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5407 | pCurrSCCB->HostStatus = SCCB_BM_ERR; |
| 5408 | } |
| 5409 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5410 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5411 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5412 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5413 | if (pCurrSCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5414 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5415 | WR_HARPOON(port + hp_page_ctrl, |
| 5416 | (RD_HARPOON(port + hp_page_ctrl) & |
| 5417 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5418 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5419 | WR_HARPOON(port + hp_sg_addr, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5420 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5421 | pCurrSCCB->Sccb_sgseg += SG_BUF_CNT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5422 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5423 | pCurrSCCB->Sccb_SGoffset = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5424 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5425 | if ((unsigned long)(pCurrSCCB->Sccb_sgseg * |
| 5426 | SG_ELEMENT_SIZE) >= |
| 5427 | pCurrSCCB->DataLength) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5429 | pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5430 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5431 | pCurrSCCB->Sccb_sgseg = |
| 5432 | (unsigned short)(pCurrSCCB->DataLength / |
| 5433 | SG_ELEMENT_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5434 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5435 | } |
| 5436 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5438 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5439 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5440 | if (!(pCurrSCCB->Sccb_XferState & F_AUTO_SENSE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5442 | pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED; |
| 5443 | } |
| 5444 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5445 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5446 | WR_HARPOON(port + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5447 | } |
| 5448 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5449 | /*--------------------------------------------------------------------- |
| 5450 | * |
| 5451 | * Function: Host Data Transfer Restart |
| 5452 | * |
| 5453 | * Description: Reset the available count due to a restore data |
| 5454 | * pointers message. |
| 5455 | * |
| 5456 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5457 | static void FPT_hostDataXferRestart(struct sccb *currSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5458 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5459 | unsigned long data_count; |
| 5460 | unsigned int sg_index; |
| 5461 | unsigned long *sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5462 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5463 | if (currSCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5464 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5465 | currSCCB->Sccb_XferCnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5466 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5467 | sg_index = 0xffff; /*Index by long words into sg list. */ |
| 5468 | data_count = 0; /*Running count of SG xfer counts. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5469 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5470 | sg_ptr = (unsigned long *)currSCCB->DataPointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5471 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5472 | while (data_count < currSCCB->Sccb_ATC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5473 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5474 | sg_index++; |
| 5475 | data_count += *(sg_ptr + (sg_index * 2)); |
| 5476 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5477 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5478 | if (data_count == currSCCB->Sccb_ATC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5479 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5480 | currSCCB->Sccb_SGoffset = 0; |
| 5481 | sg_index++; |
| 5482 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5483 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5484 | else { |
| 5485 | currSCCB->Sccb_SGoffset = |
| 5486 | data_count - currSCCB->Sccb_ATC; |
| 5487 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5488 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5489 | currSCCB->Sccb_sgseg = (unsigned short)sg_index; |
| 5490 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5492 | else { |
| 5493 | currSCCB->Sccb_XferCnt = |
| 5494 | currSCCB->DataLength - currSCCB->Sccb_ATC; |
| 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5498 | /*--------------------------------------------------------------------- |
| 5499 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5500 | * Function: FPT_scini |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5501 | * |
| 5502 | * Description: Setup all data structures necessary for SCAM selection. |
| 5503 | * |
| 5504 | *---------------------------------------------------------------------*/ |
| 5505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5506 | static void FPT_scini(unsigned char p_card, unsigned char p_our_id, |
| 5507 | unsigned char p_power_up) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5508 | { |
| 5509 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5510 | unsigned char loser, assigned_id; |
| 5511 | unsigned long p_port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5512 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5513 | unsigned char i, k, ScamFlg; |
| 5514 | struct sccb_card *currCard; |
| 5515 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5516 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5517 | currCard = &FPT_BL_Card[p_card]; |
| 5518 | p_port = currCard->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5519 | pCurrNvRam = currCard->pNvRamInfo; |
| 5520 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5521 | if (pCurrNvRam) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5522 | ScamFlg = pCurrNvRam->niScamConf; |
| 5523 | i = pCurrNvRam->niSysConf; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5524 | } else { |
| 5525 | ScamFlg = |
| 5526 | (unsigned char)FPT_utilEERead(p_port, SCAM_CONFIG / 2); |
| 5527 | i = (unsigned |
| 5528 | char)(FPT_utilEERead(p_port, (SYSTEM_CONFIG / 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5529 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5530 | if (!(i & 0x02)) /* check if reset bus in AutoSCSI parameter set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5531 | return; |
| 5532 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5533 | FPT_inisci(p_card, p_port, p_our_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5534 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5535 | /* Force to wait 1 sec after SCSI bus reset. Some SCAM device FW |
| 5536 | too slow to return to SCAM selection */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5537 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5538 | /* if (p_power_up) |
| 5539 | FPT_Wait1Second(p_port); |
| 5540 | else |
| 5541 | FPT_Wait(p_port, TO_250ms); */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5542 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5543 | FPT_Wait1Second(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5544 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5545 | if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2)) { |
| 5546 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5547 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5548 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5549 | FPT_scsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5550 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5551 | do { |
| 5552 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5553 | FPT_scxferc(p_port, DOM_MSTR); |
| 5554 | loser = |
| 5555 | FPT_scsendi(p_port, |
| 5556 | &FPT_scamInfo[p_our_id].id_string[0]); |
| 5557 | } while (loser == 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5558 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5559 | FPT_scbusf(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5560 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5561 | if ((p_power_up) && (!loser)) { |
| 5562 | FPT_sresb(p_port, p_card); |
| 5563 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5564 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5565 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5566 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5567 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5568 | FPT_scsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5569 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5570 | do { |
| 5571 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5572 | FPT_scxferc(p_port, DOM_MSTR); |
| 5573 | loser = |
| 5574 | FPT_scsendi(p_port, |
| 5575 | &FPT_scamInfo[p_our_id]. |
| 5576 | id_string[0]); |
| 5577 | } while (loser == 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5578 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5579 | FPT_scbusf(p_port); |
| 5580 | } |
| 5581 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5582 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5583 | else { |
| 5584 | loser = 0; |
| 5585 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5586 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5587 | if (!loser) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5588 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5589 | FPT_scamInfo[p_our_id].state = ID_ASSIGNED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5590 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5591 | if (ScamFlg & SCAM_ENABLED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5592 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5593 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 5594 | if ((FPT_scamInfo[i].state == ID_UNASSIGNED) || |
| 5595 | (FPT_scamInfo[i].state == ID_UNUSED)) { |
| 5596 | if (FPT_scsell(p_port, i)) { |
| 5597 | FPT_scamInfo[i].state = LEGACY; |
| 5598 | if ((FPT_scamInfo[i]. |
| 5599 | id_string[0] != 0xFF) |
| 5600 | || (FPT_scamInfo[i]. |
| 5601 | id_string[1] != 0xFA)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5602 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5603 | FPT_scamInfo[i]. |
| 5604 | id_string[0] = 0xFF; |
| 5605 | FPT_scamInfo[i]. |
| 5606 | id_string[1] = 0xFA; |
| 5607 | if (pCurrNvRam == NULL) |
| 5608 | currCard-> |
| 5609 | globalFlags |
| 5610 | |= |
| 5611 | F_UPDATE_EEPROM; |
| 5612 | } |
| 5613 | } |
| 5614 | } |
| 5615 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5616 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5617 | FPT_sresb(p_port, p_card); |
| 5618 | FPT_Wait1Second(p_port); |
| 5619 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5620 | } |
| 5621 | FPT_scsel(p_port); |
| 5622 | FPT_scasid(p_card, p_port); |
| 5623 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5624 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5625 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5626 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5627 | else if ((loser) && (ScamFlg & SCAM_ENABLED)) { |
| 5628 | FPT_scamInfo[p_our_id].id_string[0] = SLV_TYPE_CODE0; |
| 5629 | assigned_id = 0; |
| 5630 | FPT_scwtsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5631 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5632 | do { |
| 5633 | while (FPT_scxferc(p_port, 0x00) != SYNC_PTRN) { |
| 5634 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5635 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5636 | i = FPT_scxferc(p_port, 0x00); |
| 5637 | if (i == ASSIGN_ID) { |
| 5638 | if (! |
| 5639 | (FPT_scsendi |
| 5640 | (p_port, |
| 5641 | &FPT_scamInfo[p_our_id].id_string[0]))) { |
| 5642 | i = FPT_scxferc(p_port, 0x00); |
| 5643 | if (FPT_scvalq(i)) { |
| 5644 | k = FPT_scxferc(p_port, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5645 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5646 | if (FPT_scvalq(k)) { |
| 5647 | currCard->ourId = |
| 5648 | ((unsigned char)(i |
| 5649 | << |
| 5650 | 3) |
| 5651 | + |
| 5652 | (k & |
| 5653 | (unsigned char)7)) |
| 5654 | & (unsigned char) |
| 5655 | 0x3F; |
| 5656 | FPT_inisci(p_card, |
| 5657 | p_port, |
| 5658 | p_our_id); |
| 5659 | FPT_scamInfo[currCard-> |
| 5660 | ourId]. |
| 5661 | state = ID_ASSIGNED; |
| 5662 | FPT_scamInfo[currCard-> |
| 5663 | ourId]. |
| 5664 | id_string[0] |
| 5665 | = SLV_TYPE_CODE0; |
| 5666 | assigned_id = 1; |
| 5667 | } |
| 5668 | } |
| 5669 | } |
| 5670 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5671 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5672 | else if (i == SET_P_FLAG) { |
| 5673 | if (!(FPT_scsendi(p_port, |
| 5674 | &FPT_scamInfo[p_our_id]. |
| 5675 | id_string[0]))) |
| 5676 | FPT_scamInfo[p_our_id].id_string[0] |= |
| 5677 | 0x80; |
| 5678 | } |
| 5679 | } while (!assigned_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5680 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5681 | while (FPT_scxferc(p_port, 0x00) != CFG_CMPLT) { |
| 5682 | } |
| 5683 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5684 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5685 | if (ScamFlg & SCAM_ENABLED) { |
| 5686 | FPT_scbusf(p_port); |
| 5687 | if (currCard->globalFlags & F_UPDATE_EEPROM) { |
| 5688 | FPT_scsavdi(p_card, p_port); |
| 5689 | currCard->globalFlags &= ~F_UPDATE_EEPROM; |
| 5690 | } |
| 5691 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5692 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5693 | /* |
| 5694 | for (i=0,k=0; i < MAX_SCSI_TAR; i++) |
| 5695 | { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5696 | if ((FPT_scamInfo[i].state == ID_ASSIGNED) || |
| 5697 | (FPT_scamInfo[i].state == LEGACY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5698 | k++; |
| 5699 | } |
| 5700 | |
| 5701 | if (k==2) |
| 5702 | currCard->globalFlags |= F_SINGLE_DEVICE; |
| 5703 | else |
| 5704 | currCard->globalFlags &= ~F_SINGLE_DEVICE; |
| 5705 | */ |
| 5706 | } |
| 5707 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5708 | /*--------------------------------------------------------------------- |
| 5709 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5710 | * Function: FPT_scarb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5711 | * |
| 5712 | * Description: Gain control of the bus and wait SCAM select time (250ms) |
| 5713 | * |
| 5714 | *---------------------------------------------------------------------*/ |
| 5715 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5716 | 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] | 5717 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5718 | if (p_sel_type == INIT_SELTD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5719 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5720 | while (RD_HARPOON(p_port + hp_scsisig) & (SCSI_SEL | SCSI_BSY)) { |
| 5721 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5722 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5723 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_SEL) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5724 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5725 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5726 | if (RD_HARPOON(p_port + hp_scsidata_0) != 00) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5727 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5728 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5729 | WR_HARPOON(p_port + hp_scsisig, |
| 5730 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5731 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5732 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_SEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5733 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5734 | WR_HARPOON(p_port + hp_scsisig, |
| 5735 | (RD_HARPOON(p_port + hp_scsisig) & |
| 5736 | ~SCSI_BSY)); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5737 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5738 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5739 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5740 | WR_HARPOON(p_port + hp_scsisig, |
| 5741 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5742 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5743 | if (RD_HARPOON(p_port + hp_scsidata_0) != 00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5744 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5745 | WR_HARPOON(p_port + hp_scsisig, |
| 5746 | (RD_HARPOON(p_port + hp_scsisig) & |
| 5747 | ~(SCSI_BSY | SCSI_SEL))); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5748 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5749 | } |
| 5750 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5751 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5752 | WR_HARPOON(p_port + hp_clkctrl_0, (RD_HARPOON(p_port + hp_clkctrl_0) |
| 5753 | & ~ACTdeassert)); |
| 5754 | WR_HARPOON(p_port + hp_scsireset, SCAM_EN); |
| 5755 | WR_HARPOON(p_port + hp_scsidata_0, 0x00); |
| 5756 | WR_HARPOON(p_port + hp_scsidata_1, 0x00); |
| 5757 | WR_HARPOON(p_port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5758 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5759 | WR_HARPOON(p_port + hp_scsisig, |
| 5760 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_MSG)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5761 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5762 | WR_HARPOON(p_port + hp_scsisig, (RD_HARPOON(p_port + hp_scsisig) |
| 5763 | & ~SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5764 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5765 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5766 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5767 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5768 | } |
| 5769 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5770 | /*--------------------------------------------------------------------- |
| 5771 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5772 | * Function: FPT_scbusf |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5773 | * |
| 5774 | * Description: Release the SCSI bus and disable SCAM selection. |
| 5775 | * |
| 5776 | *---------------------------------------------------------------------*/ |
| 5777 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5778 | static void FPT_scbusf(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5779 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5780 | WR_HARPOON(p_port + hp_page_ctrl, |
| 5781 | (RD_HARPOON(p_port + hp_page_ctrl) | G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5782 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5783 | WR_HARPOON(p_port + hp_scsidata_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5784 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5785 | WR_HARPOON(p_port + hp_portctrl_0, (RD_HARPOON(p_port + hp_portctrl_0) |
| 5786 | & ~SCSI_BUS_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5787 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5788 | WR_HARPOON(p_port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5789 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5790 | WR_HARPOON(p_port + hp_scsireset, (RD_HARPOON(p_port + hp_scsireset) |
| 5791 | & ~SCAM_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5792 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5793 | WR_HARPOON(p_port + hp_clkctrl_0, (RD_HARPOON(p_port + hp_clkctrl_0) |
| 5794 | | ACTdeassert)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5795 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5796 | WRW_HARPOON((p_port + hp_intstat), (BUS_FREE | AUTO_INT | SCAM_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5797 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5798 | WR_HARPOON(p_port + hp_page_ctrl, |
| 5799 | (RD_HARPOON(p_port + hp_page_ctrl) & ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5800 | } |
| 5801 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5802 | /*--------------------------------------------------------------------- |
| 5803 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5804 | * Function: FPT_scasid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5805 | * |
| 5806 | * Description: Assign an ID to all the SCAM devices. |
| 5807 | * |
| 5808 | *---------------------------------------------------------------------*/ |
| 5809 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5810 | static void FPT_scasid(unsigned char p_card, unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5811 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5812 | unsigned char temp_id_string[ID_STRING_LENGTH]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5813 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5814 | unsigned char i, k, scam_id; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 5815 | unsigned char crcBytes[3]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5816 | struct nvram_info *pCurrNvRam; |
| 5817 | unsigned short *pCrcBytes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5818 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5819 | pCurrNvRam = FPT_BL_Card[p_card].pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5820 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5821 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5822 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5823 | while (!i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5824 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5825 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 5826 | temp_id_string[k] = (unsigned char)0x00; |
| 5827 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5828 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5829 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5830 | FPT_scxferc(p_port, ASSIGN_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5831 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5832 | if (!(FPT_sciso(p_port, &temp_id_string[0]))) { |
| 5833 | if (pCurrNvRam) { |
Alexey Dobriyan | fd1e29e | 2006-03-08 00:14:27 -0800 | [diff] [blame] | 5834 | pCrcBytes = (unsigned short *)&crcBytes[0]; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5835 | *pCrcBytes = FPT_CalcCrc16(&temp_id_string[0]); |
| 5836 | crcBytes[2] = FPT_CalcLrc(&temp_id_string[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5837 | temp_id_string[1] = crcBytes[2]; |
| 5838 | temp_id_string[2] = crcBytes[0]; |
| 5839 | temp_id_string[3] = crcBytes[1]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5840 | for (k = 4; k < ID_STRING_LENGTH; k++) |
| 5841 | temp_id_string[k] = (unsigned char)0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5842 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5843 | i = FPT_scmachid(p_card, temp_id_string); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5844 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5845 | if (i == CLR_PRIORITY) { |
| 5846 | FPT_scxferc(p_port, MISC_CODE); |
| 5847 | FPT_scxferc(p_port, CLR_P_FLAG); |
| 5848 | i = 0; /*Not the last ID yet. */ |
| 5849 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5850 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5851 | else if (i != NO_ID_AVAIL) { |
| 5852 | if (i < 8) |
| 5853 | FPT_scxferc(p_port, ID_0_7); |
| 5854 | else |
| 5855 | FPT_scxferc(p_port, ID_8_F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5856 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5857 | scam_id = (i & (unsigned char)0x07); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5858 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5859 | for (k = 1; k < 0x08; k <<= 1) |
| 5860 | if (!(k & i)) |
| 5861 | scam_id += 0x08; /*Count number of zeros in DB0-3. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5862 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5863 | FPT_scxferc(p_port, scam_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5864 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5865 | i = 0; /*Not the last ID yet. */ |
| 5866 | } |
| 5867 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5868 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5869 | else { |
| 5870 | i = 1; |
| 5871 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5872 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5873 | } /*End while */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5874 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5875 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5876 | FPT_scxferc(p_port, CFG_CMPLT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5877 | } |
| 5878 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5879 | /*--------------------------------------------------------------------- |
| 5880 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5881 | * Function: FPT_scsel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5882 | * |
| 5883 | * Description: Select all the SCAM devices. |
| 5884 | * |
| 5885 | *---------------------------------------------------------------------*/ |
| 5886 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5887 | static void FPT_scsel(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5888 | { |
| 5889 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5890 | WR_HARPOON(p_port + hp_scsisig, SCSI_SEL); |
| 5891 | FPT_scwiros(p_port, SCSI_MSG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5892 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5893 | WR_HARPOON(p_port + hp_scsisig, (SCSI_SEL | SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5894 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5895 | WR_HARPOON(p_port + hp_scsisig, |
| 5896 | (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
| 5897 | WR_HARPOON(p_port + hp_scsidata_0, |
| 5898 | (unsigned char)(RD_HARPOON(p_port + hp_scsidata_0) | |
| 5899 | (unsigned char)(BIT(7) + BIT(6)))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5900 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5901 | WR_HARPOON(p_port + hp_scsisig, (SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
| 5902 | FPT_scwiros(p_port, SCSI_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5903 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5904 | WR_HARPOON(p_port + hp_scsidata_0, |
| 5905 | (unsigned char)(RD_HARPOON(p_port + hp_scsidata_0) & |
| 5906 | ~(unsigned char)BIT(6))); |
| 5907 | FPT_scwirod(p_port, BIT(6)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5908 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5909 | WR_HARPOON(p_port + hp_scsisig, |
| 5910 | (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5911 | } |
| 5912 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5913 | /*--------------------------------------------------------------------- |
| 5914 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5915 | * Function: FPT_scxferc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5916 | * |
| 5917 | * Description: Handshake the p_data (DB4-0) across the bus. |
| 5918 | * |
| 5919 | *---------------------------------------------------------------------*/ |
| 5920 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 5921 | 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] | 5922 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5923 | unsigned char curr_data, ret_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5924 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5925 | 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] | 5926 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5927 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5928 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5929 | curr_data &= ~BIT(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5930 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5931 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5932 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5933 | FPT_scwirod(p_port, BIT(7)); /*Wait for DB7 to be released. */ |
| 5934 | while (!(RD_HARPOON(p_port + hp_scsidata_0) & BIT(5))) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5935 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5936 | ret_data = (RD_HARPOON(p_port + hp_scsidata_0) & (unsigned char)0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5937 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5938 | curr_data |= BIT(6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5939 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5940 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5941 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5942 | curr_data &= ~BIT(5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5943 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5944 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5945 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5946 | FPT_scwirod(p_port, BIT(5)); /*Wait for DB5 to be released. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5947 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5948 | curr_data &= ~(BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0)); /*Release data bits */ |
| 5949 | curr_data |= BIT(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5950 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5951 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5952 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5953 | curr_data &= ~BIT(6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5954 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5955 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5956 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5957 | FPT_scwirod(p_port, BIT(6)); /*Wait for DB6 to be released. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5958 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5959 | return ret_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5960 | } |
| 5961 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5962 | /*--------------------------------------------------------------------- |
| 5963 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5964 | * Function: FPT_scsendi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5965 | * |
| 5966 | * Description: Transfer our Identification string to determine if we |
| 5967 | * will be the dominant master. |
| 5968 | * |
| 5969 | *---------------------------------------------------------------------*/ |
| 5970 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5971 | static unsigned char FPT_scsendi(unsigned long p_port, |
| 5972 | unsigned char p_id_string[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5973 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5974 | unsigned char ret_data, byte_cnt, bit_cnt, defer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5975 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5976 | defer = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5977 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5978 | for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5979 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5980 | for (bit_cnt = 0x80; bit_cnt != 0; bit_cnt >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5981 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5982 | if (defer) |
| 5983 | ret_data = FPT_scxferc(p_port, 00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5984 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5985 | else if (p_id_string[byte_cnt] & bit_cnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5986 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5987 | ret_data = FPT_scxferc(p_port, 02); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5988 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5989 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5990 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5991 | ret_data = FPT_scxferc(p_port, 01); |
| 5992 | if (ret_data & 02) |
| 5993 | defer = 1; |
| 5994 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5995 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5996 | if ((ret_data & 0x1C) == 0x10) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5997 | return 0x00; /*End of isolation stage, we won! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5998 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5999 | if (ret_data & 0x1C) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6000 | return 0xFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6001 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6002 | if ((defer) && (!(ret_data & 0x1F))) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6003 | return 0x01; /*End of isolation stage, we lost. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6004 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6005 | } /*bit loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6006 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6007 | } /*byte loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6008 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6009 | if (defer) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6010 | return 0x01; /*We lost */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6011 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6012 | return 0; /*We WON! Yeeessss! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6013 | } |
| 6014 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6015 | /*--------------------------------------------------------------------- |
| 6016 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6017 | * Function: FPT_sciso |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6018 | * |
| 6019 | * Description: Transfer the Identification string. |
| 6020 | * |
| 6021 | *---------------------------------------------------------------------*/ |
| 6022 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6023 | static unsigned char FPT_sciso(unsigned long p_port, |
| 6024 | unsigned char p_id_string[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6025 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6026 | unsigned char ret_data, the_data, byte_cnt, bit_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6027 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6028 | the_data = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6029 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6030 | for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6031 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6032 | for (bit_cnt = 0; bit_cnt < 8; bit_cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6033 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6034 | ret_data = FPT_scxferc(p_port, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6035 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6036 | if (ret_data & 0xFC) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6037 | return 0xFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6038 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6039 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6040 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6041 | the_data <<= 1; |
| 6042 | if (ret_data & BIT(1)) { |
| 6043 | the_data |= 1; |
| 6044 | } |
| 6045 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6046 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6047 | if ((ret_data & 0x1F) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6048 | /* |
| 6049 | if(bit_cnt != 0 || bit_cnt != 8) |
| 6050 | { |
| 6051 | byte_cnt = 0; |
| 6052 | bit_cnt = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6053 | FPT_scxferc(p_port, SYNC_PTRN); |
| 6054 | FPT_scxferc(p_port, ASSIGN_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6055 | continue; |
| 6056 | } |
| 6057 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6058 | if (byte_cnt) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6059 | return 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6060 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6061 | return 0xFF; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6062 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6063 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6064 | } /*bit loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6065 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6066 | p_id_string[byte_cnt] = the_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6067 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6068 | } /*byte loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6069 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6070 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6071 | } |
| 6072 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6073 | /*--------------------------------------------------------------------- |
| 6074 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6075 | * Function: FPT_scwirod |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6076 | * |
| 6077 | * Description: Sample the SCSI data bus making sure the signal has been |
| 6078 | * deasserted for the correct number of consecutive samples. |
| 6079 | * |
| 6080 | *---------------------------------------------------------------------*/ |
| 6081 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6082 | 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] | 6083 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6084 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6085 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6086 | i = 0; |
| 6087 | while (i < MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6088 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6089 | if (RD_HARPOON(p_port + hp_scsidata_0) & p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6090 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6091 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6092 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6093 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6094 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6095 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6096 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6097 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6098 | } |
| 6099 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6100 | /*--------------------------------------------------------------------- |
| 6101 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6102 | * Function: FPT_scwiros |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6103 | * |
| 6104 | * Description: Sample the SCSI Signal lines making sure the signal has been |
| 6105 | * deasserted for the correct number of consecutive samples. |
| 6106 | * |
| 6107 | *---------------------------------------------------------------------*/ |
| 6108 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6109 | 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] | 6110 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6111 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6112 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6113 | i = 0; |
| 6114 | while (i < MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6115 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6116 | if (RD_HARPOON(p_port + hp_scsisig) & p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6117 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6118 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6119 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6120 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6121 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6122 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6123 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6124 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6125 | } |
| 6126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6127 | /*--------------------------------------------------------------------- |
| 6128 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6129 | * Function: FPT_scvalq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6130 | * |
| 6131 | * Description: Make sure we received a valid data byte. |
| 6132 | * |
| 6133 | *---------------------------------------------------------------------*/ |
| 6134 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 6135 | static unsigned char FPT_scvalq(unsigned char p_quintet) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6136 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6137 | unsigned char count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6138 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6139 | for (count = 1; count < 0x08; count <<= 1) { |
| 6140 | if (!(p_quintet & count)) |
| 6141 | p_quintet -= 0x80; |
| 6142 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6143 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6144 | if (p_quintet & 0x18) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6145 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6146 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6147 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6148 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6149 | } |
| 6150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6151 | /*--------------------------------------------------------------------- |
| 6152 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6153 | * Function: FPT_scsell |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6154 | * |
| 6155 | * Description: Select the specified device ID using a selection timeout |
| 6156 | * less than 4ms. If somebody responds then it is a legacy |
| 6157 | * drive and this ID must be marked as such. |
| 6158 | * |
| 6159 | *---------------------------------------------------------------------*/ |
| 6160 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6161 | 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] | 6162 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6163 | unsigned long i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6164 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6165 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6166 | (RD_HARPOON(p_port + hp_page_ctrl) | G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6167 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6168 | ARAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6169 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6170 | WR_HARPOON(p_port + hp_addstat, |
| 6171 | (RD_HARPOON(p_port + hp_addstat) | SCAM_TIMER)); |
| 6172 | WR_HARPOON(p_port + hp_seltimeout, TO_4ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6173 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6174 | for (i = p_port + CMD_STRT; i < p_port + CMD_STRT + 12; i += 2) { |
| 6175 | WRW_HARPOON(i, (MPM_OP + ACOMMAND)); |
| 6176 | } |
| 6177 | WRW_HARPOON(i, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6178 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6179 | WRW_HARPOON((p_port + hp_intstat), |
| 6180 | (RESET | TIMEOUT | SEL | BUS_FREE | AUTO_INT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6181 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6182 | WR_HARPOON(p_port + hp_select_id, targ_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6183 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6184 | WR_HARPOON(p_port + hp_portctrl_0, SCSI_PORT); |
| 6185 | WR_HARPOON(p_port + hp_autostart_3, (SELECT | CMD_ONLY_STRT)); |
| 6186 | WR_HARPOON(p_port + hp_scsictrl_0, (SEL_TAR | ENA_RESEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6187 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6188 | while (!(RDW_HARPOON((p_port + hp_intstat)) & |
| 6189 | (RESET | PROG_HLT | TIMEOUT | AUTO_INT))) { |
| 6190 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6191 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6192 | if (RDW_HARPOON((p_port + hp_intstat)) & RESET) |
| 6193 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6194 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6195 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6196 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6197 | WR_HARPOON(p_port + hp_addstat, |
| 6198 | (RD_HARPOON(p_port + hp_addstat) & ~SCAM_TIMER)); |
| 6199 | WR_HARPOON(p_port + hp_seltimeout, TO_290ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6200 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6201 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6202 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6203 | if (RDW_HARPOON((p_port + hp_intstat)) & (RESET | TIMEOUT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6204 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6205 | WRW_HARPOON((p_port + hp_intstat), |
| 6206 | (RESET | TIMEOUT | SEL | BUS_FREE | PHASE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6207 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6208 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6209 | (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6210 | ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6211 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6212 | return 0; /*No legacy device */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6213 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6214 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6215 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6216 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6217 | while (!(RDW_HARPOON((p_port + hp_intstat)) & BUS_FREE)) { |
| 6218 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_REQ) { |
| 6219 | WR_HARPOON(p_port + hp_scsisig, |
| 6220 | (SCSI_ACK + S_ILL_PH)); |
| 6221 | ACCEPT_MSG(p_port); |
| 6222 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6223 | } |
| 6224 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6225 | WRW_HARPOON((p_port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6226 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6227 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6228 | (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6229 | ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6230 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6231 | return 1; /*Found one of them oldies! */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6232 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6233 | } |
| 6234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6235 | /*--------------------------------------------------------------------- |
| 6236 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6237 | * Function: FPT_scwtsel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6238 | * |
| 6239 | * Description: Wait to be selected by another SCAM initiator. |
| 6240 | * |
| 6241 | *---------------------------------------------------------------------*/ |
| 6242 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6243 | static void FPT_scwtsel(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6244 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6245 | while (!(RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) { |
| 6246 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6247 | } |
| 6248 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6249 | /*--------------------------------------------------------------------- |
| 6250 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6251 | * Function: FPT_inisci |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6252 | * |
| 6253 | * Description: Setup the data Structure with the info from the EEPROM. |
| 6254 | * |
| 6255 | *---------------------------------------------------------------------*/ |
| 6256 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6257 | static void FPT_inisci(unsigned char p_card, unsigned long p_port, |
| 6258 | unsigned char p_our_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6259 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6260 | unsigned char i, k, max_id; |
| 6261 | unsigned short ee_data; |
| 6262 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6263 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6264 | pCurrNvRam = FPT_BL_Card[p_card].pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6266 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6267 | max_id = 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6268 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6269 | else |
| 6270 | max_id = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6271 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6272 | if (pCurrNvRam) { |
| 6273 | for (i = 0; i < max_id; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6274 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6275 | for (k = 0; k < 4; k++) |
| 6276 | FPT_scamInfo[i].id_string[k] = |
| 6277 | pCurrNvRam->niScamTbl[i][k]; |
| 6278 | for (k = 4; k < ID_STRING_LENGTH; k++) |
| 6279 | FPT_scamInfo[i].id_string[k] = |
| 6280 | (unsigned char)0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6281 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6282 | if (FPT_scamInfo[i].id_string[0] == 0x00) |
| 6283 | FPT_scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */ |
| 6284 | else |
| 6285 | FPT_scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6286 | |
| 6287 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6288 | } else { |
| 6289 | for (i = 0; i < max_id; i++) { |
| 6290 | for (k = 0; k < ID_STRING_LENGTH; k += 2) { |
| 6291 | ee_data = |
| 6292 | FPT_utilEERead(p_port, |
| 6293 | (unsigned |
| 6294 | short)((EE_SCAMBASE / 2) + |
| 6295 | (unsigned short)(i * |
| 6296 | ((unsigned short)ID_STRING_LENGTH / 2)) + (unsigned short)(k / 2))); |
| 6297 | FPT_scamInfo[i].id_string[k] = |
| 6298 | (unsigned char)ee_data; |
| 6299 | ee_data >>= 8; |
| 6300 | FPT_scamInfo[i].id_string[k + 1] = |
| 6301 | (unsigned char)ee_data; |
| 6302 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6303 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6304 | if ((FPT_scamInfo[i].id_string[0] == 0x00) || |
| 6305 | (FPT_scamInfo[i].id_string[0] == 0xFF)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6306 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6307 | FPT_scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6308 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6309 | else |
| 6310 | FPT_scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6311 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6312 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6313 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6314 | for (k = 0; k < ID_STRING_LENGTH; k++) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6315 | FPT_scamInfo[p_our_id].id_string[k] = FPT_scamHAString[k]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6316 | |
| 6317 | } |
| 6318 | |
| 6319 | /*--------------------------------------------------------------------- |
| 6320 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6321 | * Function: FPT_scmachid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6322 | * |
| 6323 | * Description: Match the Device ID string with our values stored in |
| 6324 | * the EEPROM. |
| 6325 | * |
| 6326 | *---------------------------------------------------------------------*/ |
| 6327 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6328 | static unsigned char FPT_scmachid(unsigned char p_card, |
| 6329 | unsigned char p_id_string[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6330 | { |
| 6331 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6332 | unsigned char i, k, match; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6333 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6334 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6336 | match = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6337 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6338 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6339 | if (p_id_string[k] != FPT_scamInfo[i].id_string[k]) |
| 6340 | match = 0; |
| 6341 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6342 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6343 | if (match) { |
| 6344 | FPT_scamInfo[i].state = ID_ASSIGNED; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6345 | return i; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [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 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6349 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6350 | if (p_id_string[0] & BIT(5)) |
| 6351 | i = 8; |
| 6352 | else |
| 6353 | i = MAX_SCSI_TAR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6354 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6355 | if (((p_id_string[0] & 0x06) == 0x02) |
| 6356 | || ((p_id_string[0] & 0x06) == 0x04)) |
| 6357 | match = p_id_string[1] & (unsigned char)0x1F; |
| 6358 | else |
| 6359 | match = 7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6360 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6361 | while (i > 0) { |
| 6362 | i--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6363 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6364 | if (FPT_scamInfo[match].state == ID_UNUSED) { |
| 6365 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6366 | FPT_scamInfo[match].id_string[k] = |
| 6367 | p_id_string[k]; |
| 6368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6369 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6370 | FPT_scamInfo[match].state = ID_ASSIGNED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6371 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6372 | if (FPT_BL_Card[p_card].pNvRamInfo == NULL) |
| 6373 | FPT_BL_Card[p_card].globalFlags |= |
| 6374 | F_UPDATE_EEPROM; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6375 | return match; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6376 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6377 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6379 | match--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6381 | if (match == 0xFF) { |
| 6382 | if (p_id_string[0] & BIT(5)) |
| 6383 | match = 7; |
| 6384 | else |
| 6385 | match = MAX_SCSI_TAR - 1; |
| 6386 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6387 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6388 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6389 | if (p_id_string[0] & BIT(7)) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6390 | return CLR_PRIORITY; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6391 | } |
| 6392 | |
| 6393 | if (p_id_string[0] & BIT(5)) |
| 6394 | i = 8; |
| 6395 | else |
| 6396 | i = MAX_SCSI_TAR; |
| 6397 | |
| 6398 | if (((p_id_string[0] & 0x06) == 0x02) |
| 6399 | || ((p_id_string[0] & 0x06) == 0x04)) |
| 6400 | match = p_id_string[1] & (unsigned char)0x1F; |
| 6401 | else |
| 6402 | match = 7; |
| 6403 | |
| 6404 | while (i > 0) { |
| 6405 | |
| 6406 | i--; |
| 6407 | |
| 6408 | if (FPT_scamInfo[match].state == ID_UNASSIGNED) { |
| 6409 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6410 | FPT_scamInfo[match].id_string[k] = |
| 6411 | p_id_string[k]; |
| 6412 | } |
| 6413 | |
| 6414 | FPT_scamInfo[match].id_string[0] |= BIT(7); |
| 6415 | FPT_scamInfo[match].state = ID_ASSIGNED; |
| 6416 | if (FPT_BL_Card[p_card].pNvRamInfo == NULL) |
| 6417 | FPT_BL_Card[p_card].globalFlags |= |
| 6418 | F_UPDATE_EEPROM; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6419 | return match; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6420 | |
| 6421 | } |
| 6422 | |
| 6423 | match--; |
| 6424 | |
| 6425 | if (match == 0xFF) { |
| 6426 | if (p_id_string[0] & BIT(5)) |
| 6427 | match = 7; |
| 6428 | else |
| 6429 | match = MAX_SCSI_TAR - 1; |
| 6430 | } |
| 6431 | } |
| 6432 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6433 | return NO_ID_AVAIL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6434 | } |
| 6435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6436 | /*--------------------------------------------------------------------- |
| 6437 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6438 | * Function: FPT_scsavdi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6439 | * |
| 6440 | * Description: Save off the device SCAM ID strings. |
| 6441 | * |
| 6442 | *---------------------------------------------------------------------*/ |
| 6443 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6444 | static void FPT_scsavdi(unsigned char p_card, unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6445 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6446 | unsigned char i, k, max_id; |
| 6447 | unsigned short ee_data, sum_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6448 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6449 | sum_data = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6450 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6451 | for (i = 1; i < EE_SCAMBASE / 2; i++) { |
| 6452 | sum_data += FPT_utilEERead(p_port, i); |
| 6453 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6454 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6455 | FPT_utilEEWriteOnOff(p_port, 1); /* Enable write access to the EEPROM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6456 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6457 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6458 | max_id = 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6459 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6460 | else |
| 6461 | max_id = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6462 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6463 | for (i = 0; i < max_id; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6464 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6465 | for (k = 0; k < ID_STRING_LENGTH; k += 2) { |
| 6466 | ee_data = FPT_scamInfo[i].id_string[k + 1]; |
| 6467 | ee_data <<= 8; |
| 6468 | ee_data |= FPT_scamInfo[i].id_string[k]; |
| 6469 | sum_data += ee_data; |
| 6470 | FPT_utilEEWrite(p_port, ee_data, |
| 6471 | (unsigned short)((EE_SCAMBASE / 2) + |
| 6472 | (unsigned short)(i * |
| 6473 | ((unsigned short)ID_STRING_LENGTH / 2)) + (unsigned short)(k / 2))); |
| 6474 | } |
| 6475 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6476 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6477 | FPT_utilEEWrite(p_port, sum_data, EEPROM_CHECK_SUM / 2); |
| 6478 | FPT_utilEEWriteOnOff(p_port, 0); /* Turn off write access */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6479 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6480 | |
| 6481 | /*--------------------------------------------------------------------- |
| 6482 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6483 | * Function: FPT_XbowInit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6484 | * |
| 6485 | * Description: Setup the Xbow for normal operation. |
| 6486 | * |
| 6487 | *---------------------------------------------------------------------*/ |
| 6488 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6489 | static void FPT_XbowInit(unsigned long port, unsigned char ScamFlg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6490 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6491 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6492 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6493 | i = RD_HARPOON(port + hp_page_ctrl); |
| 6494 | WR_HARPOON(port + hp_page_ctrl, (unsigned char)(i | G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6495 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6496 | WR_HARPOON(port + hp_scsireset, 0x00); |
| 6497 | WR_HARPOON(port + hp_portctrl_1, HOST_MODE8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6498 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6499 | WR_HARPOON(port + hp_scsireset, (DMA_RESET | HPSCSI_RESET | PROG_RESET | |
| 6500 | FIFO_CLR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6501 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6502 | WR_HARPOON(port + hp_scsireset, SCSI_INI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6503 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6504 | WR_HARPOON(port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6506 | WR_HARPOON(port + hp_scsisig, 0x00); /* Clear any signals we might */ |
| 6507 | WR_HARPOON(port + hp_scsictrl_0, ENA_SCAM_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6508 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6509 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6510 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6511 | FPT_default_intena = RESET | RSEL | PROG_HLT | TIMEOUT | |
| 6512 | BUS_FREE | XFER_CNT_0 | AUTO_INT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6513 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6514 | if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2)) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6515 | FPT_default_intena |= SCAM_SEL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6516 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6517 | WRW_HARPOON((port + hp_intena), FPT_default_intena); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6518 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6519 | WR_HARPOON(port + hp_seltimeout, TO_290ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6520 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6521 | /* Turn on SCSI_MODE8 for narrow cards to fix the |
| 6522 | strapping issue with the DUAL CHANNEL card */ |
| 6523 | if (RD_HARPOON(port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6524 | WR_HARPOON(port + hp_addstat, SCSI_MODE8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6525 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6526 | WR_HARPOON(port + hp_page_ctrl, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6527 | |
| 6528 | } |
| 6529 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6530 | /*--------------------------------------------------------------------- |
| 6531 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6532 | * Function: FPT_BusMasterInit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6533 | * |
| 6534 | * Description: Initialize the BusMaster for normal operations. |
| 6535 | * |
| 6536 | *---------------------------------------------------------------------*/ |
| 6537 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6538 | static void FPT_BusMasterInit(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6539 | { |
| 6540 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6541 | WR_HARPOON(p_port + hp_sys_ctrl, DRVR_RST); |
| 6542 | WR_HARPOON(p_port + hp_sys_ctrl, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6543 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6544 | WR_HARPOON(p_port + hp_host_blk_cnt, XFER_BLK64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6545 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6546 | WR_HARPOON(p_port + hp_bm_ctrl, (BMCTRL_DEFAULT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6547 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6548 | WR_HARPOON(p_port + hp_ee_ctrl, (SCSI_TERM_ENA_H)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6549 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6550 | RD_HARPOON(p_port + hp_int_status); /*Clear interrupts. */ |
| 6551 | WR_HARPOON(p_port + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
| 6552 | WR_HARPOON(p_port + hp_page_ctrl, (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6553 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6554 | } |
| 6555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6556 | /*--------------------------------------------------------------------- |
| 6557 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6558 | * Function: FPT_DiagEEPROM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6559 | * |
| 6560 | * Description: Verfiy checksum and 'Key' and initialize the EEPROM if |
| 6561 | * necessary. |
| 6562 | * |
| 6563 | *---------------------------------------------------------------------*/ |
| 6564 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 6565 | static void FPT_DiagEEPROM(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6566 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6567 | unsigned short index, temp, max_wd_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6568 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6569 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6570 | max_wd_cnt = EEPROM_WD_CNT; |
| 6571 | else |
| 6572 | max_wd_cnt = EEPROM_WD_CNT * 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6573 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6574 | temp = FPT_utilEERead(p_port, FW_SIGNATURE / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6575 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6576 | if (temp == 0x4641) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6577 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6578 | for (index = 2; index < max_wd_cnt; index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6579 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6580 | temp += FPT_utilEERead(p_port, index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6581 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6582 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6583 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6584 | if (temp == FPT_utilEERead(p_port, EEPROM_CHECK_SUM / 2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6585 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6586 | return; /*EEPROM is Okay so return now! */ |
| 6587 | } |
| 6588 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6589 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6590 | FPT_utilEEWriteOnOff(p_port, (unsigned char)1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6591 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6592 | for (index = 0; index < max_wd_cnt; index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6593 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6594 | FPT_utilEEWrite(p_port, 0x0000, index); |
| 6595 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6596 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6597 | temp = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6598 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6599 | FPT_utilEEWrite(p_port, 0x4641, FW_SIGNATURE / 2); |
| 6600 | temp += 0x4641; |
| 6601 | FPT_utilEEWrite(p_port, 0x3920, MODEL_NUMB_0 / 2); |
| 6602 | temp += 0x3920; |
| 6603 | FPT_utilEEWrite(p_port, 0x3033, MODEL_NUMB_2 / 2); |
| 6604 | temp += 0x3033; |
| 6605 | FPT_utilEEWrite(p_port, 0x2020, MODEL_NUMB_4 / 2); |
| 6606 | temp += 0x2020; |
| 6607 | FPT_utilEEWrite(p_port, 0x70D3, SYSTEM_CONFIG / 2); |
| 6608 | temp += 0x70D3; |
| 6609 | FPT_utilEEWrite(p_port, 0x0010, BIOS_CONFIG / 2); |
| 6610 | temp += 0x0010; |
| 6611 | FPT_utilEEWrite(p_port, 0x0003, SCAM_CONFIG / 2); |
| 6612 | temp += 0x0003; |
| 6613 | FPT_utilEEWrite(p_port, 0x0007, ADAPTER_SCSI_ID / 2); |
| 6614 | temp += 0x0007; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6615 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6616 | FPT_utilEEWrite(p_port, 0x0000, IGNORE_B_SCAN / 2); |
| 6617 | temp += 0x0000; |
| 6618 | FPT_utilEEWrite(p_port, 0x0000, SEND_START_ENA / 2); |
| 6619 | temp += 0x0000; |
| 6620 | FPT_utilEEWrite(p_port, 0x0000, DEVICE_ENABLE / 2); |
| 6621 | temp += 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6622 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6623 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL01 / 2); |
| 6624 | temp += 0x4242; |
| 6625 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL23 / 2); |
| 6626 | temp += 0x4242; |
| 6627 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL45 / 2); |
| 6628 | temp += 0x4242; |
| 6629 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL67 / 2); |
| 6630 | temp += 0x4242; |
| 6631 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL89 / 2); |
| 6632 | temp += 0x4242; |
| 6633 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLab / 2); |
| 6634 | temp += 0x4242; |
| 6635 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLcd / 2); |
| 6636 | temp += 0x4242; |
| 6637 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLef / 2); |
| 6638 | temp += 0x4242; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6639 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6640 | FPT_utilEEWrite(p_port, 0x6C46, 64 / 2); /*PRODUCT ID */ |
| 6641 | temp += 0x6C46; |
| 6642 | FPT_utilEEWrite(p_port, 0x7361, 66 / 2); /* FlashPoint LT */ |
| 6643 | temp += 0x7361; |
| 6644 | FPT_utilEEWrite(p_port, 0x5068, 68 / 2); |
| 6645 | temp += 0x5068; |
| 6646 | FPT_utilEEWrite(p_port, 0x696F, 70 / 2); |
| 6647 | temp += 0x696F; |
| 6648 | FPT_utilEEWrite(p_port, 0x746E, 72 / 2); |
| 6649 | temp += 0x746E; |
| 6650 | FPT_utilEEWrite(p_port, 0x4C20, 74 / 2); |
| 6651 | temp += 0x4C20; |
| 6652 | FPT_utilEEWrite(p_port, 0x2054, 76 / 2); |
| 6653 | temp += 0x2054; |
| 6654 | FPT_utilEEWrite(p_port, 0x2020, 78 / 2); |
| 6655 | temp += 0x2020; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6656 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6657 | index = ((EE_SCAMBASE / 2) + (7 * 16)); |
| 6658 | FPT_utilEEWrite(p_port, (0x0700 + TYPE_CODE0), index); |
| 6659 | temp += (0x0700 + TYPE_CODE0); |
| 6660 | index++; |
| 6661 | FPT_utilEEWrite(p_port, 0x5542, index); /*Vendor ID code */ |
| 6662 | temp += 0x5542; /* BUSLOGIC */ |
| 6663 | index++; |
| 6664 | FPT_utilEEWrite(p_port, 0x4C53, index); |
| 6665 | temp += 0x4C53; |
| 6666 | index++; |
| 6667 | FPT_utilEEWrite(p_port, 0x474F, index); |
| 6668 | temp += 0x474F; |
| 6669 | index++; |
| 6670 | FPT_utilEEWrite(p_port, 0x4349, index); |
| 6671 | temp += 0x4349; |
| 6672 | index++; |
| 6673 | FPT_utilEEWrite(p_port, 0x5442, index); /*Vendor unique code */ |
| 6674 | temp += 0x5442; /* BT- 930 */ |
| 6675 | index++; |
| 6676 | FPT_utilEEWrite(p_port, 0x202D, index); |
| 6677 | temp += 0x202D; |
| 6678 | index++; |
| 6679 | FPT_utilEEWrite(p_port, 0x3339, index); |
| 6680 | temp += 0x3339; |
| 6681 | index++; /*Serial # */ |
| 6682 | FPT_utilEEWrite(p_port, 0x2030, index); /* 01234567 */ |
| 6683 | temp += 0x2030; |
| 6684 | index++; |
| 6685 | FPT_utilEEWrite(p_port, 0x5453, index); |
| 6686 | temp += 0x5453; |
| 6687 | index++; |
| 6688 | FPT_utilEEWrite(p_port, 0x5645, index); |
| 6689 | temp += 0x5645; |
| 6690 | index++; |
| 6691 | FPT_utilEEWrite(p_port, 0x2045, index); |
| 6692 | temp += 0x2045; |
| 6693 | index++; |
| 6694 | FPT_utilEEWrite(p_port, 0x202F, index); |
| 6695 | temp += 0x202F; |
| 6696 | index++; |
| 6697 | FPT_utilEEWrite(p_port, 0x4F4A, index); |
| 6698 | temp += 0x4F4A; |
| 6699 | index++; |
| 6700 | FPT_utilEEWrite(p_port, 0x204E, index); |
| 6701 | temp += 0x204E; |
| 6702 | index++; |
| 6703 | FPT_utilEEWrite(p_port, 0x3539, index); |
| 6704 | temp += 0x3539; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6705 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6706 | FPT_utilEEWrite(p_port, temp, EEPROM_CHECK_SUM / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6707 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6708 | FPT_utilEEWriteOnOff(p_port, (unsigned char)0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6709 | |
| 6710 | } |
| 6711 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6712 | /*--------------------------------------------------------------------- |
| 6713 | * |
| 6714 | * Function: Queue Search Select |
| 6715 | * |
| 6716 | * Description: Try to find a new command to execute. |
| 6717 | * |
| 6718 | *---------------------------------------------------------------------*/ |
| 6719 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6720 | static void FPT_queueSearchSelect(struct sccb_card *pCurrCard, |
| 6721 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6722 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6723 | unsigned char scan_ptr, lun; |
| 6724 | struct sccb_mgr_tar_info *currTar_Info; |
| 6725 | struct sccb *pOldSccb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6726 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6727 | scan_ptr = pCurrCard->scanIndex; |
| 6728 | do { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6729 | currTar_Info = &FPT_sccbMgrTbl[p_card][scan_ptr]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6730 | if ((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 6731 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 6732 | TAG_Q_TRYING)) { |
| 6733 | if (currTar_Info->TarSelQ_Cnt != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6734 | |
| 6735 | scan_ptr++; |
| 6736 | if (scan_ptr == MAX_SCSI_TAR) |
| 6737 | scan_ptr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6738 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6739 | for (lun = 0; lun < MAX_LUN; lun++) { |
| 6740 | if (currTar_Info->TarLUNBusy[lun] == 0) { |
| 6741 | |
| 6742 | pCurrCard->currentSCCB = |
| 6743 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6744 | pOldSccb = NULL; |
| 6745 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6746 | while ((pCurrCard-> |
| 6747 | currentSCCB != NULL) |
| 6748 | && (lun != |
| 6749 | pCurrCard-> |
| 6750 | currentSCCB->Lun)) { |
| 6751 | pOldSccb = |
| 6752 | pCurrCard-> |
| 6753 | currentSCCB; |
| 6754 | pCurrCard->currentSCCB = |
| 6755 | (struct sccb |
| 6756 | *)(pCurrCard-> |
| 6757 | currentSCCB)-> |
| 6758 | Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6759 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6760 | if (pCurrCard->currentSCCB == |
| 6761 | NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6762 | continue; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6763 | if (pOldSccb != NULL) { |
| 6764 | pOldSccb-> |
| 6765 | Sccb_forwardlink = |
| 6766 | (struct sccb |
| 6767 | *)(pCurrCard-> |
| 6768 | currentSCCB)-> |
| 6769 | Sccb_forwardlink; |
| 6770 | pOldSccb-> |
| 6771 | Sccb_backlink = |
| 6772 | (struct sccb |
| 6773 | *)(pCurrCard-> |
| 6774 | currentSCCB)-> |
| 6775 | Sccb_backlink; |
| 6776 | currTar_Info-> |
| 6777 | TarSelQ_Cnt--; |
| 6778 | } else { |
| 6779 | currTar_Info-> |
| 6780 | TarSelQ_Head = |
| 6781 | (struct sccb |
| 6782 | *)(pCurrCard-> |
| 6783 | currentSCCB)-> |
| 6784 | Sccb_forwardlink; |
| 6785 | |
| 6786 | if (currTar_Info-> |
| 6787 | TarSelQ_Head == |
| 6788 | NULL) { |
| 6789 | currTar_Info-> |
| 6790 | TarSelQ_Tail |
| 6791 | = NULL; |
| 6792 | currTar_Info-> |
| 6793 | TarSelQ_Cnt |
| 6794 | = 0; |
| 6795 | } else { |
| 6796 | currTar_Info-> |
| 6797 | TarSelQ_Cnt--; |
| 6798 | currTar_Info-> |
| 6799 | TarSelQ_Head-> |
| 6800 | Sccb_backlink |
| 6801 | = |
| 6802 | (struct sccb |
| 6803 | *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6804 | } |
| 6805 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6806 | pCurrCard->scanIndex = scan_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6807 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6808 | pCurrCard->globalFlags |= |
| 6809 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6810 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6811 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6812 | } |
| 6813 | } |
| 6814 | } |
| 6815 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6816 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6817 | scan_ptr++; |
| 6818 | if (scan_ptr == MAX_SCSI_TAR) { |
| 6819 | scan_ptr = 0; |
| 6820 | } |
| 6821 | } |
| 6822 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6823 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6824 | if ((currTar_Info->TarSelQ_Cnt != 0) && |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6825 | (currTar_Info->TarLUNBusy[0] == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6826 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6827 | pCurrCard->currentSCCB = |
| 6828 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6829 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6830 | currTar_Info->TarSelQ_Head = |
| 6831 | (struct sccb *)(pCurrCard->currentSCCB)-> |
| 6832 | Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6833 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6834 | if (currTar_Info->TarSelQ_Head == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6835 | currTar_Info->TarSelQ_Tail = NULL; |
| 6836 | currTar_Info->TarSelQ_Cnt = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6837 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6838 | currTar_Info->TarSelQ_Cnt--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6839 | currTar_Info->TarSelQ_Head-> |
| 6840 | Sccb_backlink = (struct sccb *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6841 | } |
| 6842 | |
| 6843 | scan_ptr++; |
| 6844 | if (scan_ptr == MAX_SCSI_TAR) |
| 6845 | scan_ptr = 0; |
| 6846 | |
| 6847 | pCurrCard->scanIndex = scan_ptr; |
| 6848 | |
| 6849 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 6850 | |
| 6851 | break; |
| 6852 | } |
| 6853 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6854 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6855 | scan_ptr++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6856 | if (scan_ptr == MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6857 | scan_ptr = 0; |
| 6858 | } |
| 6859 | } |
| 6860 | } |
| 6861 | } while (scan_ptr != pCurrCard->scanIndex); |
| 6862 | } |
| 6863 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6864 | /*--------------------------------------------------------------------- |
| 6865 | * |
| 6866 | * Function: Queue Select Fail |
| 6867 | * |
| 6868 | * Description: Add the current SCCB to the head of the Queue. |
| 6869 | * |
| 6870 | *---------------------------------------------------------------------*/ |
| 6871 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6872 | static void FPT_queueSelectFail(struct sccb_card *pCurrCard, |
| 6873 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6874 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6875 | unsigned char thisTarg; |
| 6876 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6877 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6878 | if (pCurrCard->currentSCCB != NULL) { |
| 6879 | thisTarg = |
| 6880 | (unsigned char)(((struct sccb *)(pCurrCard->currentSCCB))-> |
| 6881 | TargID); |
| 6882 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6883 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6884 | pCurrCard->currentSCCB->Sccb_backlink = (struct sccb *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6885 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6886 | pCurrCard->currentSCCB->Sccb_forwardlink = |
| 6887 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6888 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6889 | if (currTar_Info->TarSelQ_Cnt == 0) { |
| 6890 | currTar_Info->TarSelQ_Tail = pCurrCard->currentSCCB; |
| 6891 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6892 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6893 | else { |
| 6894 | currTar_Info->TarSelQ_Head->Sccb_backlink = |
| 6895 | pCurrCard->currentSCCB; |
| 6896 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6897 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6898 | currTar_Info->TarSelQ_Head = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6899 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6900 | pCurrCard->currentSCCB = NULL; |
| 6901 | currTar_Info->TarSelQ_Cnt++; |
| 6902 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6903 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6904 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6905 | /*--------------------------------------------------------------------- |
| 6906 | * |
| 6907 | * Function: Queue Command Complete |
| 6908 | * |
| 6909 | * Description: Call the callback function with the current SCCB. |
| 6910 | * |
| 6911 | *---------------------------------------------------------------------*/ |
| 6912 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6913 | static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, |
| 6914 | struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6915 | { |
| 6916 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6917 | unsigned char i, SCSIcmd; |
| 6918 | CALL_BK_FN callback; |
| 6919 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6920 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6921 | SCSIcmd = p_sccb->Cdb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6922 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6923 | if (!(p_sccb->Sccb_XferState & F_ALL_XFERRED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6924 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6925 | if ((p_sccb-> |
| 6926 | ControlByte & (SCCB_DATA_XFER_OUT | SCCB_DATA_XFER_IN)) |
| 6927 | && (p_sccb->HostStatus == SCCB_COMPLETE) |
| 6928 | && (p_sccb->TargetStatus != SSCHECK)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6929 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6930 | if ((SCSIcmd == SCSI_READ) || |
| 6931 | (SCSIcmd == SCSI_WRITE) || |
| 6932 | (SCSIcmd == SCSI_READ_EXTENDED) || |
| 6933 | (SCSIcmd == SCSI_WRITE_EXTENDED) || |
| 6934 | (SCSIcmd == SCSI_WRITE_AND_VERIFY) || |
| 6935 | (SCSIcmd == SCSI_START_STOP_UNIT) || |
| 6936 | (pCurrCard->globalFlags & F_NO_FILTER) |
| 6937 | ) |
| 6938 | p_sccb->HostStatus = SCCB_DATA_UNDER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6939 | } |
| 6940 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6941 | if (p_sccb->SccbStatus == SCCB_IN_PROCESS) { |
| 6942 | if (p_sccb->HostStatus || p_sccb->TargetStatus) |
| 6943 | p_sccb->SccbStatus = SCCB_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6944 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6945 | p_sccb->SccbStatus = SCCB_SUCCESS; |
| 6946 | } |
| 6947 | |
| 6948 | if (p_sccb->Sccb_XferState & F_AUTO_SENSE) { |
| 6949 | |
| 6950 | p_sccb->CdbLength = p_sccb->Save_CdbLen; |
| 6951 | for (i = 0; i < 6; i++) { |
| 6952 | p_sccb->Cdb[i] = p_sccb->Save_Cdb[i]; |
| 6953 | } |
| 6954 | } |
| 6955 | |
| 6956 | if ((p_sccb->OperationCode == RESIDUAL_SG_COMMAND) || |
| 6957 | (p_sccb->OperationCode == RESIDUAL_COMMAND)) { |
| 6958 | |
| 6959 | FPT_utilUpdateResidual(p_sccb); |
| 6960 | } |
| 6961 | |
| 6962 | pCurrCard->cmdCounter--; |
| 6963 | if (!pCurrCard->cmdCounter) { |
| 6964 | |
| 6965 | if (pCurrCard->globalFlags & F_GREEN_PC) { |
| 6966 | WR_HARPOON(pCurrCard->ioPort + hp_clkctrl_0, |
| 6967 | (PWR_DWN | CLKCTRL_DEFAULT)); |
| 6968 | WR_HARPOON(pCurrCard->ioPort + hp_sys_ctrl, STOP_CLK); |
| 6969 | } |
| 6970 | |
| 6971 | WR_HARPOON(pCurrCard->ioPort + hp_semaphore, |
| 6972 | (RD_HARPOON(pCurrCard->ioPort + hp_semaphore) & |
| 6973 | ~SCCB_MGR_ACTIVE)); |
| 6974 | |
| 6975 | } |
| 6976 | |
| 6977 | if (pCurrCard->discQCount != 0) { |
| 6978 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
| 6979 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 6980 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 6981 | TAG_Q_TRYING))) { |
| 6982 | pCurrCard->discQCount--; |
| 6983 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 6984 | LunDiscQ_Idx[p_sccb->Lun]] = NULL; |
| 6985 | } else { |
| 6986 | if (p_sccb->Sccb_tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6987 | pCurrCard->discQCount--; |
| 6988 | pCurrCard->discQ_Tbl[p_sccb->Sccb_tag] = NULL; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6989 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6990 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6991 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 6992 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6993 | } |
| 6994 | } |
| 6995 | |
| 6996 | } |
| 6997 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6998 | callback = (CALL_BK_FN) p_sccb->SccbCallback; |
| 6999 | callback(p_sccb); |
| 7000 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 7001 | pCurrCard->currentSCCB = NULL; |
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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7004 | /*--------------------------------------------------------------------- |
| 7005 | * |
| 7006 | * Function: Queue Disconnect |
| 7007 | * |
| 7008 | * Description: Add SCCB to our disconnect array. |
| 7009 | * |
| 7010 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7011 | static void FPT_queueDisconnect(struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7012 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7013 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7014 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7015 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7016 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7017 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 7018 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 7019 | FPT_BL_Card[p_card].discQ_Tbl[currTar_Info-> |
| 7020 | LunDiscQ_Idx[p_sccb->Lun]] = |
| 7021 | p_sccb; |
| 7022 | } else { |
| 7023 | if (p_sccb->Sccb_tag) { |
| 7024 | FPT_BL_Card[p_card].discQ_Tbl[p_sccb->Sccb_tag] = |
| 7025 | p_sccb; |
| 7026 | FPT_sccbMgrTbl[p_card][p_sccb->TargID].TarLUNBusy[0] = |
| 7027 | 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7028 | FPT_sccbMgrTbl[p_card][p_sccb->TargID].TarTagQ_Cnt++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7029 | } else { |
| 7030 | FPT_BL_Card[p_card].discQ_Tbl[currTar_Info-> |
| 7031 | LunDiscQ_Idx[0]] = p_sccb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7032 | } |
| 7033 | } |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7034 | FPT_BL_Card[p_card].currentSCCB = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7035 | } |
| 7036 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7037 | /*--------------------------------------------------------------------- |
| 7038 | * |
| 7039 | * Function: Queue Flush SCCB |
| 7040 | * |
| 7041 | * Description: Flush all SCCB's back to the host driver for this target. |
| 7042 | * |
| 7043 | *---------------------------------------------------------------------*/ |
| 7044 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7045 | static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7046 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7047 | unsigned char qtag, thisTarg; |
| 7048 | struct sccb *currSCCB; |
| 7049 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7050 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7051 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 7052 | if (currSCCB != NULL) { |
| 7053 | thisTarg = (unsigned char)currSCCB->TargID; |
| 7054 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7055 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7056 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7057 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7058 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] && |
| 7059 | (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == |
| 7060 | thisTarg)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7062 | FPT_BL_Card[p_card].discQ_Tbl[qtag]-> |
| 7063 | HostStatus = (unsigned char)error_code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7064 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7065 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 7066 | FPT_BL_Card[p_card]. |
| 7067 | discQ_Tbl[qtag], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7068 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7069 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 7070 | currTar_Info->TarTagQ_Cnt--; |
| 7071 | |
| 7072 | } |
| 7073 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7074 | } |
| 7075 | |
| 7076 | } |
| 7077 | |
| 7078 | /*--------------------------------------------------------------------- |
| 7079 | * |
| 7080 | * Function: Queue Flush Target SCCB |
| 7081 | * |
| 7082 | * Description: Flush all SCCB's back to the host driver for this target. |
| 7083 | * |
| 7084 | *---------------------------------------------------------------------*/ |
| 7085 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7086 | static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg, |
| 7087 | unsigned char error_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7088 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7089 | unsigned char qtag; |
| 7090 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7091 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7092 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7093 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7094 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7095 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7096 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] && |
| 7097 | (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == thisTarg)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7098 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7099 | FPT_BL_Card[p_card].discQ_Tbl[qtag]->HostStatus = |
| 7100 | (unsigned char)error_code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7101 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7102 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 7103 | FPT_BL_Card[p_card]. |
| 7104 | discQ_Tbl[qtag], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7105 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7106 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 7107 | currTar_Info->TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7108 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7109 | } |
| 7110 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7111 | |
| 7112 | } |
| 7113 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7114 | static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7115 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7116 | struct sccb_mgr_tar_info *currTar_Info; |
| 7117 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_SCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7118 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7119 | p_SCCB->Sccb_forwardlink = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7120 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7121 | p_SCCB->Sccb_backlink = currTar_Info->TarSelQ_Tail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7122 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7123 | if (currTar_Info->TarSelQ_Cnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7124 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7125 | currTar_Info->TarSelQ_Head = p_SCCB; |
| 7126 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7127 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7128 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7129 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7130 | currTar_Info->TarSelQ_Tail->Sccb_forwardlink = p_SCCB; |
| 7131 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7132 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7133 | currTar_Info->TarSelQ_Tail = p_SCCB; |
| 7134 | currTar_Info->TarSelQ_Cnt++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7135 | } |
| 7136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7137 | /*--------------------------------------------------------------------- |
| 7138 | * |
| 7139 | * Function: Queue Find SCCB |
| 7140 | * |
| 7141 | * Description: Search the target select Queue for this SCCB, and |
| 7142 | * remove it if found. |
| 7143 | * |
| 7144 | *---------------------------------------------------------------------*/ |
| 7145 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7146 | static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB, |
| 7147 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7148 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7149 | struct sccb *q_ptr; |
| 7150 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7151 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7152 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_SCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7153 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7154 | q_ptr = currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7155 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7156 | while (q_ptr != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7157 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7158 | if (q_ptr == p_SCCB) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7159 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7160 | if (currTar_Info->TarSelQ_Head == q_ptr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7161 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7162 | currTar_Info->TarSelQ_Head = |
| 7163 | q_ptr->Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7164 | } |
| 7165 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7166 | if (currTar_Info->TarSelQ_Tail == q_ptr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7167 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7168 | currTar_Info->TarSelQ_Tail = |
| 7169 | q_ptr->Sccb_backlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7170 | } |
| 7171 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7172 | if (q_ptr->Sccb_forwardlink != NULL) { |
| 7173 | q_ptr->Sccb_forwardlink->Sccb_backlink = |
| 7174 | q_ptr->Sccb_backlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7175 | } |
| 7176 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7177 | if (q_ptr->Sccb_backlink != NULL) { |
| 7178 | q_ptr->Sccb_backlink->Sccb_forwardlink = |
| 7179 | q_ptr->Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7180 | } |
| 7181 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7182 | currTar_Info->TarSelQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7183 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7184 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7185 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7186 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7187 | else { |
| 7188 | q_ptr = q_ptr->Sccb_forwardlink; |
| 7189 | } |
| 7190 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7191 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7192 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7193 | |
| 7194 | } |
| 7195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7196 | /*--------------------------------------------------------------------- |
| 7197 | * |
| 7198 | * Function: Utility Update Residual Count |
| 7199 | * |
| 7200 | * Description: Update the XferCnt to the remaining byte count. |
| 7201 | * If we transferred all the data then just write zero. |
| 7202 | * If Non-SG transfer then report Total Cnt - Actual Transfer |
| 7203 | * Cnt. For SG transfers add the count fields of all |
| 7204 | * remaining SG elements, as well as any partial remaining |
| 7205 | * element. |
| 7206 | * |
| 7207 | *---------------------------------------------------------------------*/ |
| 7208 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7209 | static void FPT_utilUpdateResidual(struct sccb *p_SCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7210 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7211 | unsigned long partial_cnt; |
| 7212 | unsigned int sg_index; |
| 7213 | unsigned long *sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7214 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7215 | if (p_SCCB->Sccb_XferState & F_ALL_XFERRED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7216 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7217 | p_SCCB->DataLength = 0x0000; |
| 7218 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7219 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7220 | else if (p_SCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7221 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7222 | partial_cnt = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7223 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7224 | sg_index = p_SCCB->Sccb_sgseg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7226 | sg_ptr = (unsigned long *)p_SCCB->DataPointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7227 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7228 | if (p_SCCB->Sccb_SGoffset) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7229 | |
| 7230 | partial_cnt = p_SCCB->Sccb_SGoffset; |
| 7231 | sg_index++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7232 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7233 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7234 | while (((unsigned long)sg_index * |
| 7235 | (unsigned long)SG_ELEMENT_SIZE) < p_SCCB->DataLength) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7236 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7237 | partial_cnt += *(sg_ptr + (sg_index * 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7238 | sg_index++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7239 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7240 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7241 | p_SCCB->DataLength = partial_cnt; |
| 7242 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7243 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7244 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7245 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7246 | p_SCCB->DataLength -= p_SCCB->Sccb_ATC; |
| 7247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7248 | } |
| 7249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7250 | /*--------------------------------------------------------------------- |
| 7251 | * |
| 7252 | * Function: Wait 1 Second |
| 7253 | * |
| 7254 | * Description: Wait for 1 second. |
| 7255 | * |
| 7256 | *---------------------------------------------------------------------*/ |
| 7257 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 7258 | static void FPT_Wait1Second(unsigned long p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7259 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7260 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7261 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7262 | for (i = 0; i < 4; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7263 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7264 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7266 | if ((RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST)) |
| 7267 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7268 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7269 | if ((RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) |
| 7270 | break; |
| 7271 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7272 | } |
| 7273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7274 | /*--------------------------------------------------------------------- |
| 7275 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7276 | * Function: FPT_Wait |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7277 | * |
| 7278 | * Description: Wait the desired delay. |
| 7279 | * |
| 7280 | *---------------------------------------------------------------------*/ |
| 7281 | |
Alexey Dobriyan | d63a4cc | 2006-03-08 00:14:26 -0800 | [diff] [blame] | 7282 | static void FPT_Wait(unsigned long p_port, unsigned char p_delay) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7283 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7284 | unsigned char old_timer; |
| 7285 | unsigned char green_flag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7286 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7287 | old_timer = RD_HARPOON(p_port + hp_seltimeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7288 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7289 | green_flag = RD_HARPOON(p_port + hp_clkctrl_0); |
| 7290 | WR_HARPOON(p_port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7292 | WR_HARPOON(p_port + hp_seltimeout, p_delay); |
| 7293 | WRW_HARPOON((p_port + hp_intstat), TIMEOUT); |
| 7294 | WRW_HARPOON((p_port + hp_intena), (FPT_default_intena & ~TIMEOUT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7295 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7296 | WR_HARPOON(p_port + hp_portctrl_0, |
| 7297 | (RD_HARPOON(p_port + hp_portctrl_0) | START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7298 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7299 | while (!(RDW_HARPOON((p_port + hp_intstat)) & TIMEOUT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7300 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7301 | if ((RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST)) |
| 7302 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7303 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7304 | if ((RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) |
| 7305 | break; |
| 7306 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7308 | WR_HARPOON(p_port + hp_portctrl_0, |
| 7309 | (RD_HARPOON(p_port + hp_portctrl_0) & ~START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7310 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7311 | WRW_HARPOON((p_port + hp_intstat), TIMEOUT); |
| 7312 | WRW_HARPOON((p_port + hp_intena), FPT_default_intena); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7313 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7314 | WR_HARPOON(p_port + hp_clkctrl_0, green_flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7315 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7316 | WR_HARPOON(p_port + hp_seltimeout, old_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7317 | } |
| 7318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7319 | /*--------------------------------------------------------------------- |
| 7320 | * |
| 7321 | * Function: Enable/Disable Write to EEPROM |
| 7322 | * |
| 7323 | * Description: The EEPROM must first be enabled for writes |
| 7324 | * A total of 9 clocks are needed. |
| 7325 | * |
| 7326 | *---------------------------------------------------------------------*/ |
| 7327 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7328 | static void FPT_utilEEWriteOnOff(unsigned long p_port, unsigned char p_mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7329 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7330 | unsigned char ee_value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7331 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7332 | ee_value = |
| 7333 | (unsigned char)(RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7334 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7336 | if (p_mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7337 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7338 | FPT_utilEESendCmdAddr(p_port, EWEN, EWEN_ADDR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7339 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7340 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7341 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7342 | FPT_utilEESendCmdAddr(p_port, EWDS, EWDS_ADDR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7343 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7344 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */ |
| 7345 | 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] | 7346 | } |
| 7347 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7348 | /*--------------------------------------------------------------------- |
| 7349 | * |
| 7350 | * Function: Write EEPROM |
| 7351 | * |
| 7352 | * Description: Write a word to the EEPROM at the specified |
| 7353 | * address. |
| 7354 | * |
| 7355 | *---------------------------------------------------------------------*/ |
| 7356 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7357 | static void FPT_utilEEWrite(unsigned long p_port, unsigned short ee_data, |
| 7358 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7359 | { |
| 7360 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7361 | unsigned char ee_value; |
| 7362 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7363 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7364 | ee_value = |
| 7365 | (unsigned |
| 7366 | char)((RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7367 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)) | (SEE_MS | SEE_CS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7368 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7369 | FPT_utilEESendCmdAddr(p_port, EE_WRITE, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7370 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7371 | ee_value |= (SEE_MS + SEE_CS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7372 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7373 | for (i = 0x8000; i != 0; i >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7375 | if (i & ee_data) |
| 7376 | ee_value |= SEE_DO; |
| 7377 | else |
| 7378 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7379 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7380 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7381 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7382 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7383 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7384 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7385 | ee_value &= ~SEE_CLK; |
| 7386 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7387 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7388 | } |
| 7389 | ee_value &= (EXT_ARB_ACK | SCSI_TERM_ENA_H); |
| 7390 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7391 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7392 | FPT_Wait(p_port, TO_10ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7393 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7394 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS | SEE_CS)); /* Set CS to EEPROM */ |
| 7395 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /* Turn off CS */ |
| 7396 | 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] | 7397 | } |
| 7398 | |
| 7399 | /*--------------------------------------------------------------------- |
| 7400 | * |
| 7401 | * Function: Read EEPROM |
| 7402 | * |
| 7403 | * Description: Read a word from the EEPROM at the desired |
| 7404 | * address. |
| 7405 | * |
| 7406 | *---------------------------------------------------------------------*/ |
| 7407 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7408 | static unsigned short FPT_utilEERead(unsigned long p_port, |
| 7409 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7410 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7411 | unsigned short i, ee_data1, ee_data2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7412 | |
| 7413 | i = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7414 | ee_data1 = FPT_utilEEReadOrg(p_port, ee_addr); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7415 | do { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7416 | ee_data2 = FPT_utilEEReadOrg(p_port, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7417 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7418 | if (ee_data1 == ee_data2) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7419 | return ee_data1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7420 | |
| 7421 | ee_data1 = ee_data2; |
| 7422 | i++; |
| 7423 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7424 | } while (i < 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7425 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7426 | return ee_data1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7427 | } |
| 7428 | |
| 7429 | /*--------------------------------------------------------------------- |
| 7430 | * |
| 7431 | * Function: Read EEPROM Original |
| 7432 | * |
| 7433 | * Description: Read a word from the EEPROM at the desired |
| 7434 | * address. |
| 7435 | * |
| 7436 | *---------------------------------------------------------------------*/ |
| 7437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7438 | static unsigned short FPT_utilEEReadOrg(unsigned long p_port, |
| 7439 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7440 | { |
| 7441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7442 | unsigned char ee_value; |
| 7443 | unsigned short i, ee_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7444 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7445 | ee_value = |
| 7446 | (unsigned |
| 7447 | char)((RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7448 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)) | (SEE_MS | SEE_CS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7450 | FPT_utilEESendCmdAddr(p_port, EE_READ, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7451 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7452 | ee_value |= (SEE_MS + SEE_CS); |
| 7453 | ee_data = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7454 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7455 | for (i = 1; i <= 16; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7456 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7457 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7458 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7459 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7460 | ee_value &= ~SEE_CLK; |
| 7461 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7462 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7464 | ee_data <<= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7466 | if (RD_HARPOON(p_port + hp_ee_ctrl) & SEE_DI) |
| 7467 | ee_data |= 1; |
| 7468 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7469 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7470 | ee_value &= ~(SEE_MS + SEE_CS); |
| 7471 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */ |
| 7472 | 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] | 7473 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7474 | return ee_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7475 | } |
| 7476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7477 | /*--------------------------------------------------------------------- |
| 7478 | * |
| 7479 | * Function: Send EE command and Address to the EEPROM |
| 7480 | * |
| 7481 | * Description: Transfers the correct command and sends the address |
| 7482 | * to the eeprom. |
| 7483 | * |
| 7484 | *---------------------------------------------------------------------*/ |
| 7485 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7486 | static void FPT_utilEESendCmdAddr(unsigned long p_port, unsigned char ee_cmd, |
| 7487 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7488 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7489 | unsigned char ee_value; |
| 7490 | unsigned char narrow_flg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7492 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7493 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7494 | narrow_flg = |
| 7495 | (unsigned char)(RD_HARPOON(p_port + hp_page_ctrl) & |
| 7496 | NARROW_SCSI_CARD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7497 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7498 | ee_value = SEE_MS; |
| 7499 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7500 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7501 | ee_value |= SEE_CS; /* Set CS to EEPROM */ |
| 7502 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7503 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7504 | for (i = 0x04; i != 0; i >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7506 | if (i & ee_cmd) |
| 7507 | ee_value |= SEE_DO; |
| 7508 | else |
| 7509 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7510 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7511 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7512 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7513 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7514 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7515 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7516 | ee_value &= ~SEE_CLK; |
| 7517 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7518 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7519 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7520 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7521 | if (narrow_flg) |
| 7522 | i = 0x0080; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7523 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7524 | else |
| 7525 | i = 0x0200; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7526 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7527 | while (i != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7528 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7529 | if (i & ee_addr) |
| 7530 | ee_value |= SEE_DO; |
| 7531 | else |
| 7532 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7533 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7534 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7535 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7536 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7537 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7538 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7539 | ee_value &= ~SEE_CLK; |
| 7540 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7541 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7542 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7543 | i >>= 1; |
| 7544 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7545 | } |
| 7546 | |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 7547 | static unsigned short FPT_CalcCrc16(unsigned char buffer[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7548 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7549 | unsigned short crc = 0; |
| 7550 | int i, j; |
| 7551 | unsigned short ch; |
| 7552 | for (i = 0; i < ID_STRING_LENGTH; i++) { |
| 7553 | ch = (unsigned short)buffer[i]; |
| 7554 | for (j = 0; j < 8; j++) { |
| 7555 | if ((crc ^ ch) & 1) |
| 7556 | crc = (crc >> 1) ^ CRCMASK; |
| 7557 | else |
| 7558 | crc >>= 1; |
| 7559 | ch >>= 1; |
| 7560 | } |
| 7561 | } |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7562 | return crc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7563 | } |
| 7564 | |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 7565 | static unsigned char FPT_CalcLrc(unsigned char buffer[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7566 | { |
| 7567 | int i; |
Alexey Dobriyan | db038cf | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 7568 | unsigned char lrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7569 | lrc = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7570 | for (i = 0; i < ID_STRING_LENGTH; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7571 | lrc ^= buffer[i]; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7572 | return lrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7573 | } |
| 7574 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7575 | /* |
| 7576 | The following inline definitions avoid type conflicts. |
| 7577 | */ |
| 7578 | |
| 7579 | static inline unsigned char |
| 7580 | FlashPoint__ProbeHostAdapter(struct FlashPoint_Info *FlashPointInfo) |
| 7581 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7582 | return FlashPoint_ProbeHostAdapter((struct sccb_mgr_info *) |
| 7583 | FlashPointInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7584 | } |
| 7585 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7586 | static inline FlashPoint_CardHandle_T |
| 7587 | FlashPoint__HardwareResetHostAdapter(struct FlashPoint_Info *FlashPointInfo) |
| 7588 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7589 | return FlashPoint_HardwareResetHostAdapter((struct sccb_mgr_info *) |
| 7590 | FlashPointInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7591 | } |
| 7592 | |
| 7593 | static inline void |
| 7594 | FlashPoint__ReleaseHostAdapter(FlashPoint_CardHandle_T CardHandle) |
| 7595 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7596 | FlashPoint_ReleaseHostAdapter(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7597 | } |
| 7598 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7599 | static inline void |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7600 | FlashPoint__StartCCB(FlashPoint_CardHandle_T CardHandle, |
| 7601 | struct BusLogic_CCB *CCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7602 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7603 | FlashPoint_StartCCB(CardHandle, (struct sccb *)CCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7604 | } |
| 7605 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7606 | static inline void |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7607 | FlashPoint__AbortCCB(FlashPoint_CardHandle_T CardHandle, |
| 7608 | struct BusLogic_CCB *CCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7609 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7610 | FlashPoint_AbortCCB(CardHandle, (struct sccb *)CCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7611 | } |
| 7612 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7613 | static inline boolean |
| 7614 | FlashPoint__InterruptPending(FlashPoint_CardHandle_T CardHandle) |
| 7615 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7616 | return FlashPoint_InterruptPending(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7617 | } |
| 7618 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7619 | static inline int |
| 7620 | FlashPoint__HandleInterrupt(FlashPoint_CardHandle_T CardHandle) |
| 7621 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7622 | return FlashPoint_HandleInterrupt(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7623 | } |
| 7624 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7625 | #define FlashPoint_ProbeHostAdapter FlashPoint__ProbeHostAdapter |
| 7626 | #define FlashPoint_HardwareResetHostAdapter FlashPoint__HardwareResetHostAdapter |
| 7627 | #define FlashPoint_ReleaseHostAdapter FlashPoint__ReleaseHostAdapter |
| 7628 | #define FlashPoint_StartCCB FlashPoint__StartCCB |
| 7629 | #define FlashPoint_AbortCCB FlashPoint__AbortCCB |
| 7630 | #define FlashPoint_InterruptPending FlashPoint__InterruptPending |
| 7631 | #define FlashPoint_HandleInterrupt FlashPoint__HandleInterrupt |
| 7632 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7633 | #else /* CONFIG_SCSI_OMIT_FLASHPOINT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7634 | |
| 7635 | /* |
| 7636 | Define prototypes for the FlashPoint SCCB Manager Functions. |
| 7637 | */ |
| 7638 | |
| 7639 | extern unsigned char FlashPoint_ProbeHostAdapter(struct FlashPoint_Info *); |
| 7640 | extern FlashPoint_CardHandle_T |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7641 | FlashPoint_HardwareResetHostAdapter(struct FlashPoint_Info *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7642 | extern void FlashPoint_StartCCB(FlashPoint_CardHandle_T, struct BusLogic_CCB *); |
| 7643 | extern int FlashPoint_AbortCCB(FlashPoint_CardHandle_T, struct BusLogic_CCB *); |
| 7644 | extern boolean FlashPoint_InterruptPending(FlashPoint_CardHandle_T); |
| 7645 | extern int FlashPoint_HandleInterrupt(FlashPoint_CardHandle_T); |
| 7646 | extern void FlashPoint_ReleaseHostAdapter(FlashPoint_CardHandle_T); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7647 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7648 | #endif /* CONFIG_SCSI_OMIT_FLASHPOINT */ |