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 | |
Matthew Wilcox | 78b4b05 | 2008-03-13 06:55:08 -0600 | [diff] [blame] | 19 | #ifdef CONFIG_SCSI_FLASHPOINT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #define MAX_CARDS 8 |
| 22 | #undef BUSTYPE_PCI |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #define CRCMASK 0xA001 |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #define FAILURE 0xFFFFFFFFL |
| 27 | |
Alexey Dobriyan | 69eb2ea | 2006-03-08 00:14:29 -0800 | [diff] [blame] | 28 | struct sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 29 | typedef void (*CALL_BK_FN) (struct sccb *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Alexey Dobriyan | 7f10166 | 2006-03-08 00:14:30 -0800 | [diff] [blame] | 31 | struct sccb_mgr_info { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 32 | u32 si_baseaddr; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 33 | unsigned char si_present; |
| 34 | unsigned char si_intvect; |
| 35 | unsigned char si_id; |
| 36 | unsigned char si_lun; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 37 | u16 si_fw_revision; |
| 38 | u16 si_per_targ_init_sync; |
| 39 | u16 si_per_targ_fast_nego; |
| 40 | u16 si_per_targ_ultra_nego; |
| 41 | u16 si_per_targ_no_disc; |
| 42 | u16 si_per_targ_wide_nego; |
| 43 | u16 si_flags; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 44 | unsigned char si_card_family; |
| 45 | unsigned char si_bustype; |
| 46 | unsigned char si_card_model[3]; |
| 47 | unsigned char si_relative_cardnum; |
| 48 | unsigned char si_reserved[4]; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 49 | u32 si_OS_reserved; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 50 | unsigned char si_XlatInfo[4]; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 51 | u32 si_reserved2[5]; |
| 52 | u32 si_secondary_range; |
Alexey Dobriyan | 7f10166 | 2006-03-08 00:14:30 -0800 | [diff] [blame] | 53 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 55 | #define SCSI_PARITY_ENA 0x0001 |
| 56 | #define LOW_BYTE_TERM 0x0010 |
| 57 | #define HIGH_BYTE_TERM 0x0020 |
| 58 | #define BUSTYPE_PCI 0x3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | #define SUPPORT_16TAR_32LUN 0x0002 |
| 61 | #define SOFT_RESET 0x0004 |
| 62 | #define EXTENDED_TRANSLATION 0x0008 |
| 63 | #define POST_ALL_UNDERRRUNS 0x0040 |
| 64 | #define FLAG_SCAM_ENABLED 0x0080 |
| 65 | #define FLAG_SCAM_LEVEL2 0x0100 |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #define HARPOON_FAMILY 0x02 |
| 68 | |
Alexey Dobriyan | 32357988 | 2006-01-15 02:12:54 +0100 | [diff] [blame] | 69 | /* SCCB struct used for both SCCB and UCB manager compiles! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | * The UCB Manager treats the SCCB as it's 'native hardware structure' |
| 71 | */ |
| 72 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 73 | /*#pragma pack(1)*/ |
Alexey Dobriyan | 69eb2ea | 2006-03-08 00:14:29 -0800 | [diff] [blame] | 74 | struct sccb { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 75 | unsigned char OperationCode; |
| 76 | unsigned char ControlByte; |
| 77 | unsigned char CdbLength; |
| 78 | unsigned char RequestSenseLength; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 79 | u32 DataLength; |
| 80 | void *DataPointer; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 81 | unsigned char CcbRes[2]; |
| 82 | unsigned char HostStatus; |
| 83 | unsigned char TargetStatus; |
| 84 | unsigned char TargID; |
| 85 | unsigned char Lun; |
| 86 | unsigned char Cdb[12]; |
| 87 | unsigned char CcbRes1; |
| 88 | unsigned char Reserved1; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 89 | u32 Reserved2; |
| 90 | u32 SensePointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 92 | CALL_BK_FN SccbCallback; /* VOID (*SccbCallback)(); */ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 93 | u32 SccbIOPort; /* Identifies board base port */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 94 | unsigned char SccbStatus; |
| 95 | unsigned char SCCBRes2; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 96 | u16 SccbOSFlags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 98 | u32 Sccb_XferCnt; /* actual transfer count */ |
| 99 | u32 Sccb_ATC; |
| 100 | u32 SccbVirtDataPtr; /* virtual addr for OS/2 */ |
| 101 | u32 Sccb_res1; |
| 102 | u16 Sccb_MGRFlags; |
| 103 | u16 Sccb_sgseg; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 104 | unsigned char Sccb_scsimsg; /* identify msg for selection */ |
| 105 | unsigned char Sccb_tag; |
| 106 | unsigned char Sccb_scsistat; |
| 107 | unsigned char Sccb_idmsg; /* image of last msg in */ |
| 108 | struct sccb *Sccb_forwardlink; |
| 109 | struct sccb *Sccb_backlink; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 110 | u32 Sccb_savedATC; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 111 | unsigned char Save_Cdb[6]; |
| 112 | unsigned char Save_CdbLen; |
| 113 | unsigned char Sccb_XferState; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 114 | u32 Sccb_SGoffset; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 115 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | #pragma pack() |
| 118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | #define SCATTER_GATHER_COMMAND 0x02 |
| 120 | #define RESIDUAL_COMMAND 0x03 |
| 121 | #define RESIDUAL_SG_COMMAND 0x04 |
| 122 | #define RESET_COMMAND 0x81 |
| 123 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 124 | #define F_USE_CMD_Q 0x20 /*Inidcates TAGGED command. */ |
| 125 | #define TAG_TYPE_MASK 0xC0 /*Type of tag msg to send. */ |
| 126 | #define SCCB_DATA_XFER_OUT 0x10 /* Write */ |
| 127 | #define SCCB_DATA_XFER_IN 0x08 /* Read */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 129 | #define NO_AUTO_REQUEST_SENSE 0x01 /* No Request Sense Buffer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 131 | #define BUS_FREE_ST 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | #define SELECT_ST 1 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 133 | #define SELECT_BDR_ST 2 /* Select w\ Bus Device Reset */ |
| 134 | #define SELECT_SN_ST 3 /* Select w\ Sync Nego */ |
| 135 | #define SELECT_WN_ST 4 /* Select w\ Wide Data Nego */ |
| 136 | #define SELECT_Q_ST 5 /* Select w\ Tagged Q'ing */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #define COMMAND_ST 6 |
| 138 | #define DATA_OUT_ST 7 |
| 139 | #define DATA_IN_ST 8 |
| 140 | #define DISCONNECT_ST 9 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | #define ABORT_ST 11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | #define F_HOST_XFER_DIR 0x01 |
| 144 | #define F_ALL_XFERRED 0x02 |
| 145 | #define F_SG_XFER 0x04 |
| 146 | #define F_AUTO_SENSE 0x08 |
| 147 | #define F_ODD_BALL_CNT 0x10 |
| 148 | #define F_NO_DATA_YET 0x80 |
| 149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | #define F_STATUSLOADED 0x01 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | #define F_DEV_SELECTED 0x04 |
| 152 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 153 | #define SCCB_COMPLETE 0x00 /* SCCB completed without error */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | #define SCCB_DATA_UNDER_RUN 0x0C |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 155 | #define SCCB_SELECTION_TIMEOUT 0x11 /* Set SCSI selection timed out */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | #define SCCB_DATA_OVER_RUN 0x12 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 157 | #define SCCB_PHASE_SEQUENCE_FAIL 0x14 /* Target bus phase sequence failure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 159 | #define SCCB_GROSS_FW_ERR 0x27 /* Major problem! */ |
| 160 | #define SCCB_BM_ERR 0x30 /* BusMaster error. */ |
| 161 | #define SCCB_PARITY_ERR 0x34 /* SCSI parity error */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
| 163 | #define SCCB_IN_PROCESS 0x00 |
| 164 | #define SCCB_SUCCESS 0x01 |
| 165 | #define SCCB_ABORT 0x02 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | #define SCCB_ERROR 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | #define ORION_FW_REV 3110 |
| 169 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 170 | #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] | 171 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 172 | #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] | 173 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 174 | #define MAX_SCSI_TAR 16 |
| 175 | #define MAX_LUN 32 |
| 176 | #define LUN_MASK 0x1f |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 178 | #define SG_BUF_CNT 16 /*Number of prefetched elements. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 180 | #define SG_ELEMENT_SIZE 8 /*Eight byte per element. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
Alexey Dobriyan | ad0e1d9 | 2006-03-08 00:14:28 -0800 | [diff] [blame] | 182 | #define RD_HARPOON(ioport) inb((u32)ioport) |
| 183 | #define RDW_HARPOON(ioport) inw((u32)ioport) |
| 184 | #define RD_HARP32(ioport,offset,data) (data = inl((u32)(ioport + offset))) |
| 185 | #define WR_HARPOON(ioport,val) outb((u8) val, (u32)ioport) |
| 186 | #define WRW_HARPOON(ioport,val) outw((u16)val, (u32)ioport) |
| 187 | #define WR_HARP32(ioport,offset,data) outl(data, (u32)(ioport + offset)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | #define TAR_SYNC_MASK (BIT(7)+BIT(6)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | #define SYNC_TRYING BIT(6) |
| 191 | #define SYNC_SUPPORTED (BIT(7)+BIT(6)) |
| 192 | |
| 193 | #define TAR_WIDE_MASK (BIT(5)+BIT(4)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | #define WIDE_ENABLED BIT(4) |
| 195 | #define WIDE_NEGOCIATED BIT(5) |
| 196 | |
| 197 | #define TAR_TAG_Q_MASK (BIT(3)+BIT(2)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | #define TAG_Q_TRYING BIT(2) |
| 199 | #define TAG_Q_REJECT BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
| 201 | #define TAR_ALLOW_DISC BIT(0) |
| 202 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | #define EE_SYNC_MASK (BIT(0)+BIT(1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | #define EE_SYNC_5MB BIT(0) |
| 205 | #define EE_SYNC_10MB BIT(1) |
| 206 | #define EE_SYNC_20MB (BIT(0)+BIT(1)) |
| 207 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | #define EE_WIDE_SCSI BIT(7) |
| 209 | |
Alexey Dobriyan | f31dc0cd | 2006-03-08 00:14:31 -0800 | [diff] [blame] | 210 | struct sccb_mgr_tar_info { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 212 | struct sccb *TarSelQ_Head; |
| 213 | struct sccb *TarSelQ_Tail; |
| 214 | unsigned char TarLUN_CA; /*Contingent Allgiance */ |
| 215 | unsigned char TarTagQ_Cnt; |
| 216 | unsigned char TarSelQ_Cnt; |
| 217 | unsigned char TarStatus; |
| 218 | unsigned char TarEEValue; |
| 219 | unsigned char TarSyncCtrl; |
| 220 | unsigned char TarReserved[2]; /* for alignment */ |
| 221 | unsigned char LunDiscQ_Idx[MAX_LUN]; |
| 222 | unsigned char TarLUNBusy[MAX_LUN]; |
Alexey Dobriyan | f31dc0cd | 2006-03-08 00:14:31 -0800 | [diff] [blame] | 223 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Alexey Dobriyan | 68d0c1a | 2006-03-08 00:14:33 -0800 | [diff] [blame] | 225 | struct nvram_info { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 226 | unsigned char niModel; /* Model No. of card */ |
| 227 | unsigned char niCardNo; /* Card no. */ |
| 228 | u32 niBaseAddr; /* Port Address of card */ |
| 229 | unsigned char niSysConf; /* Adapter Configuration byte - |
| 230 | Byte 16 of eeprom map */ |
| 231 | unsigned char niScsiConf; /* SCSI Configuration byte - |
| 232 | Byte 17 of eeprom map */ |
| 233 | unsigned char niScamConf; /* SCAM Configuration byte - |
| 234 | Byte 20 of eeprom map */ |
| 235 | unsigned char niAdapId; /* Host Adapter ID - |
| 236 | Byte 24 of eerpom map */ |
| 237 | unsigned char niSyncTbl[MAX_SCSI_TAR / 2]; /* Sync/Wide byte |
| 238 | of targets */ |
| 239 | unsigned char niScamTbl[MAX_SCSI_TAR][4]; /* Compressed Scam name |
| 240 | string of Targets */ |
Alexey Dobriyan | 68d0c1a | 2006-03-08 00:14:33 -0800 | [diff] [blame] | 241 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | #define MODEL_LT 1 |
| 244 | #define MODEL_DL 2 |
| 245 | #define MODEL_LW 3 |
| 246 | #define MODEL_DW 4 |
| 247 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 248 | struct sccb_card { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 249 | struct sccb *currentSCCB; |
| 250 | struct sccb_mgr_info *cardInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 252 | u32 ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 254 | unsigned short cmdCounter; |
| 255 | unsigned char discQCount; |
| 256 | unsigned char tagQ_Lst; |
| 257 | unsigned char cardIndex; |
| 258 | unsigned char scanIndex; |
| 259 | unsigned char globalFlags; |
| 260 | unsigned char ourId; |
| 261 | struct nvram_info *pNvRamInfo; |
| 262 | struct sccb *discQ_Tbl[QUEUE_DEPTH]; |
| 263 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 264 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | #define F_TAG_STARTED 0x01 |
| 267 | #define F_CONLUN_IO 0x02 |
| 268 | #define F_DO_RENEGO 0x04 |
| 269 | #define F_NO_FILTER 0x08 |
| 270 | #define F_GREEN_PC 0x10 |
| 271 | #define F_HOST_XFER_ACT 0x20 |
| 272 | #define F_NEW_SCCB_CMD 0x40 |
| 273 | #define F_UPDATE_EEPROM 0x80 |
| 274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | #define ID_STRING_LENGTH 32 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 276 | #define TYPE_CODE0 0x63 /*Level2 Mstr (bits 7-6), */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 278 | #define SLV_TYPE_CODE0 0xA3 /*Priority Bit set (bits 7-6), */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
| 280 | #define ASSIGN_ID 0x00 |
| 281 | #define SET_P_FLAG 0x01 |
| 282 | #define CFG_CMPLT 0x03 |
| 283 | #define DOM_MSTR 0x0F |
| 284 | #define SYNC_PTRN 0x1F |
| 285 | |
| 286 | #define ID_0_7 0x18 |
| 287 | #define ID_8_F 0x11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | #define MISC_CODE 0x14 |
| 289 | #define CLR_P_FLAG 0x18 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | #define INIT_SELTD 0x01 |
| 292 | #define LEVEL2_TAR 0x02 |
| 293 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 294 | enum scam_id_st { ID0, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, ID9, ID10, ID11, |
| 295 | ID12, |
| 296 | ID13, ID14, ID15, ID_UNUSED, ID_UNASSIGNED, ID_ASSIGNED, LEGACY, |
| 297 | CLR_PRIORITY, NO_ID_AVAIL |
| 298 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
| 300 | typedef struct SCCBscam_info { |
| 301 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 302 | unsigned char id_string[ID_STRING_LENGTH]; |
| 303 | enum scam_id_st state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 305 | } SCCBSCAM_INFO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | #define SCSI_REQUEST_SENSE 0x03 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | #define SCSI_READ 0x08 |
| 309 | #define SCSI_WRITE 0x0A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | #define SCSI_START_STOP_UNIT 0x1B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | #define SCSI_READ_EXTENDED 0x28 |
| 312 | #define SCSI_WRITE_EXTENDED 0x2A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | #define SCSI_WRITE_AND_VERIFY 0x2E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | #define SSGOOD 0x00 |
| 316 | #define SSCHECK 0x02 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | #define SSQ_FULL 0x28 |
| 318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | #define SMCMD_COMP 0x00 |
| 320 | #define SMEXT 0x01 |
| 321 | #define SMSAVE_DATA_PTR 0x02 |
| 322 | #define SMREST_DATA_PTR 0x03 |
| 323 | #define SMDISC 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | #define SMABORT 0x06 |
| 325 | #define SMREJECT 0x07 |
| 326 | #define SMNO_OP 0x08 |
| 327 | #define SMPARITY 0x09 |
| 328 | #define SMDEV_RESET 0x0C |
| 329 | #define SMABORT_TAG 0x0D |
| 330 | #define SMINIT_RECOVERY 0x0F |
| 331 | #define SMREL_RECOVERY 0x10 |
| 332 | |
| 333 | #define SMIDENT 0x80 |
| 334 | #define DISC_PRIV 0x40 |
| 335 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | #define SMSYNC 0x01 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | #define SMWDTR 0x03 |
| 338 | #define SM8BIT 0x00 |
| 339 | #define SM16BIT 0x01 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 340 | #define SMIGNORWR 0x23 /* Ignore Wide Residue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
| 342 | #define SIX_BYTE_CMD 0x06 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | #define TWELVE_BYTE_CMD 0x0C |
| 344 | |
| 345 | #define ASYNC 0x00 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 346 | #define MAX_OFFSET 0x0F /* Maxbyteoffset for Sync Xfers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | |
| 348 | #define EEPROM_WD_CNT 256 |
| 349 | |
| 350 | #define EEPROM_CHECK_SUM 0 |
| 351 | #define FW_SIGNATURE 2 |
| 352 | #define MODEL_NUMB_0 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | #define MODEL_NUMB_2 6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | #define MODEL_NUMB_4 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | #define SYSTEM_CONFIG 16 |
| 356 | #define SCSI_CONFIG 17 |
| 357 | #define BIOS_CONFIG 18 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | #define SCAM_CONFIG 20 |
| 359 | #define ADAPTER_SCSI_ID 24 |
| 360 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | #define IGNORE_B_SCAN 32 |
| 362 | #define SEND_START_ENA 34 |
| 363 | #define DEVICE_ENABLE 36 |
| 364 | |
| 365 | #define SYNC_RATE_TBL 38 |
| 366 | #define SYNC_RATE_TBL01 38 |
| 367 | #define SYNC_RATE_TBL23 40 |
| 368 | #define SYNC_RATE_TBL45 42 |
| 369 | #define SYNC_RATE_TBL67 44 |
| 370 | #define SYNC_RATE_TBL89 46 |
| 371 | #define SYNC_RATE_TBLab 48 |
| 372 | #define SYNC_RATE_TBLcd 50 |
| 373 | #define SYNC_RATE_TBLef 52 |
| 374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 375 | #define EE_SCAMBASE 256 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 377 | #define SCAM_ENABLED BIT(2) |
| 378 | #define SCAM_LEVEL2 BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 380 | #define RENEGO_ENA BIT(10) |
| 381 | #define CONNIO_ENA BIT(11) |
| 382 | #define GREEN_PC_ENA BIT(12) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 384 | #define AUTO_RATE_00 00 |
| 385 | #define AUTO_RATE_05 01 |
| 386 | #define AUTO_RATE_10 02 |
| 387 | #define AUTO_RATE_20 03 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 389 | #define WIDE_NEGO_BIT BIT(7) |
| 390 | #define DISC_ENABLE_BIT BIT(6) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 392 | #define hp_vendor_id_0 0x00 /* LSB */ |
| 393 | #define ORION_VEND_0 0x4B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 395 | #define hp_vendor_id_1 0x01 /* MSB */ |
| 396 | #define ORION_VEND_1 0x10 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 398 | #define hp_device_id_0 0x02 /* LSB */ |
| 399 | #define ORION_DEV_0 0x30 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 401 | #define hp_device_id_1 0x03 /* MSB */ |
| 402 | #define ORION_DEV_1 0x81 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | |
| 404 | /* Sub Vendor ID and Sub Device ID only available in |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 405 | Harpoon Version 2 and higher */ |
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_sub_device_id_0 0x06 /* LSB */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 409 | #define hp_semaphore 0x0C |
| 410 | #define SCCB_MGR_ACTIVE BIT(0) |
| 411 | #define TICKLE_ME BIT(1) |
| 412 | #define SCCB_MGR_PRESENT BIT(3) |
| 413 | #define BIOS_IN_USE BIT(4) |
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 hp_sys_ctrl 0x0F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 417 | #define STOP_CLK BIT(0) /*Turn off BusMaster Clock */ |
| 418 | #define DRVR_RST BIT(1) /*Firmware Reset to 80C15 chip */ |
| 419 | #define HALT_MACH BIT(3) /*Halt State Machine */ |
| 420 | #define HARD_ABORT BIT(4) /*Hard Abort */ |
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 hp_host_blk_cnt 0x13 |
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 XFER_BLK64 0x06 /* 1 1 0 64 byte per block */ |
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 BM_THRESHOLD 0x40 /* PCI mode can only xfer 16 bytes */ |
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 hp_int_mask 0x17 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 430 | #define INT_CMD_COMPL BIT(0) /* DMA command complete */ |
| 431 | #define INT_EXT_STATUS BIT(1) /* Extended Status Set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 433 | #define hp_xfer_cnt_lo 0x18 |
| 434 | #define hp_xfer_cnt_hi 0x1A |
| 435 | #define hp_xfer_cmd 0x1B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 437 | #define XFER_HOST_DMA 0x00 /* 0 0 0 Transfer Host -> DMA */ |
| 438 | #define XFER_DMA_HOST 0x01 /* 0 0 1 Transfer DMA -> Host */ |
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_HOST_AUTO 0x00 /* 0 0 Auto Transfer Size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 442 | #define XFER_DMA_8BIT 0x20 /* 0 1 8 BIT Transfer Size */ |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 443 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 444 | #define DISABLE_INT BIT(7) /*Do not interrupt at end of cmd. */ |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 445 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 446 | #define HOST_WRT_CMD ((DISABLE_INT + XFER_HOST_DMA + XFER_HOST_AUTO + XFER_DMA_8BIT)) |
| 447 | #define HOST_RD_CMD ((DISABLE_INT + XFER_DMA_HOST + XFER_HOST_AUTO + XFER_DMA_8BIT)) |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 448 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 449 | #define hp_host_addr_lo 0x1C |
| 450 | #define hp_host_addr_hmi 0x1E |
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 hp_ee_ctrl 0x22 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 454 | #define EXT_ARB_ACK BIT(7) |
| 455 | #define SCSI_TERM_ENA_H BIT(6) /* SCSI high byte terminator */ |
| 456 | #define SEE_MS BIT(5) |
| 457 | #define SEE_CS BIT(3) |
| 458 | #define SEE_CLK BIT(2) |
| 459 | #define SEE_DO BIT(1) |
| 460 | #define SEE_DI BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 462 | #define EE_READ 0x06 |
| 463 | #define EE_WRITE 0x05 |
| 464 | #define EWEN 0x04 |
| 465 | #define EWEN_ADDR 0x03C0 |
| 466 | #define EWDS 0x04 |
| 467 | #define EWDS_ADDR 0x0000 |
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 hp_bm_ctrl 0x26 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 471 | #define SCSI_TERM_ENA_L BIT(0) /*Enable/Disable external terminators */ |
| 472 | #define FLUSH_XFER_CNTR BIT(1) /*Flush transfer counter */ |
| 473 | #define FORCE1_XFER BIT(5) /*Always xfer one byte in byte mode */ |
| 474 | #define FAST_SINGLE BIT(6) /*?? */ |
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 BMCTRL_DEFAULT (FORCE1_XFER|FAST_SINGLE|SCSI_TERM_ENA_L) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 478 | #define hp_sg_addr 0x28 |
| 479 | #define hp_page_ctrl 0x29 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 481 | #define SCATTER_EN BIT(0) |
| 482 | #define SGRAM_ARAM BIT(1) |
| 483 | #define G_INT_DISABLE BIT(3) /* Enable/Disable all Interrupts */ |
| 484 | #define NARROW_SCSI_CARD BIT(4) /* NARROW/WIDE SCSI config pin */ |
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 hp_pci_stat_cfg 0x2D |
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 REC_MASTER_ABORT BIT(5) /*received Master abort */ |
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_rev_num 0x33 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 492 | #define hp_stack_data 0x34 |
| 493 | #define hp_stack_addr 0x35 |
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 hp_ext_status 0x36 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 497 | #define BM_FORCE_OFF BIT(0) /*Bus Master is forced to get off */ |
| 498 | #define PCI_TGT_ABORT BIT(0) /*PCI bus master transaction aborted */ |
| 499 | #define PCI_DEV_TMOUT BIT(1) /*PCI Device Time out */ |
| 500 | #define CMD_ABORTED BIT(4) /*Command aborted */ |
| 501 | #define BM_PARITY_ERR BIT(5) /*parity error on data received */ |
| 502 | #define PIO_OVERRUN BIT(6) /*Slave data overrun */ |
| 503 | #define BM_CMD_BUSY BIT(7) /*Bus master transfer command busy */ |
| 504 | #define BAD_EXT_STATUS (BM_FORCE_OFF | PCI_DEV_TMOUT | CMD_ABORTED | \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | BM_PARITY_ERR | PIO_OVERRUN) |
| 506 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 507 | #define hp_int_status 0x37 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 509 | #define EXT_STATUS_ON BIT(1) /*Extended status is valid */ |
| 510 | #define SCSI_INTERRUPT BIT(2) /*Global indication of a SCSI int. */ |
| 511 | #define INT_ASSERTED BIT(5) /* */ |
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_fifo_cnt 0x38 |
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 hp_intena 0x40 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 517 | #define RESET BIT(7) |
| 518 | #define PROG_HLT BIT(6) |
| 519 | #define PARITY BIT(5) |
| 520 | #define FIFO BIT(4) |
| 521 | #define SEL BIT(3) |
| 522 | #define SCAM_SEL BIT(2) |
| 523 | #define RSEL BIT(1) |
| 524 | #define TIMEOUT BIT(0) |
| 525 | #define BUS_FREE BIT(15) |
| 526 | #define XFER_CNT_0 BIT(14) |
| 527 | #define PHASE BIT(13) |
| 528 | #define IUNKWN BIT(12) |
| 529 | #define ICMD_COMP BIT(11) |
| 530 | #define ITICKLE BIT(10) |
| 531 | #define IDO_STRT BIT(9) |
| 532 | #define ITAR_DISC BIT(8) |
| 533 | #define AUTO_INT (BIT(12)+BIT(11)+BIT(10)+BIT(9)+BIT(8)) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 534 | #define CLR_ALL_INT 0xFFFF |
| 535 | #define CLR_ALL_INT_1 0xFF00 |
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_intstat 0x42 |
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 hp_scsisig 0x44 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 541 | #define SCSI_SEL BIT(7) |
| 542 | #define SCSI_BSY BIT(6) |
| 543 | #define SCSI_REQ BIT(5) |
| 544 | #define SCSI_ACK BIT(4) |
| 545 | #define SCSI_ATN BIT(3) |
| 546 | #define SCSI_CD BIT(2) |
| 547 | #define SCSI_MSG BIT(1) |
| 548 | #define SCSI_IOBIT BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 550 | #define S_SCSI_PHZ (BIT(2)+BIT(1)+BIT(0)) |
| 551 | #define S_MSGO_PH (BIT(2)+BIT(1) ) |
| 552 | #define S_MSGI_PH (BIT(2)+BIT(1)+BIT(0)) |
| 553 | #define S_DATAI_PH ( BIT(0)) |
| 554 | #define S_DATAO_PH 0x00 |
| 555 | #define S_ILL_PH ( BIT(1) ) |
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 hp_scsictrl_0 0x45 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 559 | #define SEL_TAR BIT(6) |
| 560 | #define ENA_ATN BIT(4) |
| 561 | #define ENA_RESEL BIT(2) |
| 562 | #define SCSI_RST BIT(1) |
| 563 | #define ENA_SCAM_SEL BIT(0) |
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 hp_portctrl_0 0x46 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 567 | #define SCSI_PORT BIT(7) |
| 568 | #define SCSI_INBIT BIT(6) |
| 569 | #define DMA_PORT BIT(5) |
| 570 | #define DMA_RD BIT(4) |
| 571 | #define HOST_PORT BIT(3) |
| 572 | #define HOST_WRT BIT(2) |
| 573 | #define SCSI_BUS_EN BIT(1) |
| 574 | #define START_TO BIT(0) |
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 hp_scsireset 0x47 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 578 | #define SCSI_INI BIT(6) |
| 579 | #define SCAM_EN BIT(5) |
| 580 | #define DMA_RESET BIT(3) |
| 581 | #define HPSCSI_RESET BIT(2) |
| 582 | #define PROG_RESET BIT(1) |
| 583 | #define FIFO_CLR BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 585 | #define hp_xfercnt_0 0x48 |
| 586 | #define hp_xfercnt_2 0x4A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 588 | #define hp_fifodata_0 0x4C |
| 589 | #define hp_addstat 0x4E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 591 | #define SCAM_TIMER BIT(7) |
| 592 | #define SCSI_MODE8 BIT(3) |
| 593 | #define SCSI_PAR_ERR BIT(0) |
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_prgmcnt_0 0x4F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 597 | #define hp_selfid_0 0x50 |
| 598 | #define hp_selfid_1 0x51 |
| 599 | #define hp_arb_id 0x52 |
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_select_id 0x53 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 603 | #define hp_synctarg_base 0x54 |
| 604 | #define hp_synctarg_12 0x54 |
| 605 | #define hp_synctarg_13 0x55 |
| 606 | #define hp_synctarg_14 0x56 |
| 607 | #define hp_synctarg_15 0x57 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 609 | #define hp_synctarg_8 0x58 |
| 610 | #define hp_synctarg_9 0x59 |
| 611 | #define hp_synctarg_10 0x5A |
| 612 | #define hp_synctarg_11 0x5B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 614 | #define hp_synctarg_4 0x5C |
| 615 | #define hp_synctarg_5 0x5D |
| 616 | #define hp_synctarg_6 0x5E |
| 617 | #define hp_synctarg_7 0x5F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 619 | #define hp_synctarg_0 0x60 |
| 620 | #define hp_synctarg_1 0x61 |
| 621 | #define hp_synctarg_2 0x62 |
| 622 | #define hp_synctarg_3 0x63 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 624 | #define NARROW_SCSI BIT(4) |
| 625 | #define DEFAULT_OFFSET 0x0F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 627 | #define hp_autostart_0 0x64 |
| 628 | #define hp_autostart_1 0x65 |
| 629 | #define hp_autostart_3 0x67 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 631 | #define AUTO_IMMED BIT(5) |
| 632 | #define SELECT BIT(6) |
| 633 | #define END_DATA (BIT(7)+BIT(6)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 635 | #define hp_gp_reg_0 0x68 |
| 636 | #define hp_gp_reg_1 0x69 |
| 637 | #define hp_gp_reg_3 0x6B |
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 hp_seltimeout 0x6C |
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_4ms 0x67 /* 3.9959ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 643 | #define TO_5ms 0x03 /* 4.9152ms */ |
| 644 | #define TO_10ms 0x07 /* 11.xxxms */ |
| 645 | #define TO_250ms 0x99 /* 250.68ms */ |
| 646 | #define TO_290ms 0xB1 /* 289.99ms */ |
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 hp_clkctrl_0 0x6D |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 650 | #define PWR_DWN BIT(6) |
| 651 | #define ACTdeassert BIT(4) |
| 652 | #define CLK_40MHZ (BIT(1) + BIT(0)) |
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 CLKCTRL_DEFAULT (ACTdeassert | CLK_40MHZ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 656 | #define hp_fiforead 0x6E |
| 657 | #define hp_fifowrite 0x6F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 659 | #define hp_offsetctr 0x70 |
| 660 | #define hp_xferstat 0x71 |
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 FIFO_EMPTY BIT(6) |
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 hp_portctrl_1 0x72 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 666 | #define CHK_SCSI_P BIT(3) |
| 667 | #define HOST_MODE8 BIT(0) |
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 hp_xfer_pad 0x73 |
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 ID_UNLOCK BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 673 | #define hp_scsidata_0 0x74 |
| 674 | #define hp_scsidata_1 0x75 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 676 | #define hp_aramBase 0x80 |
| 677 | #define BIOS_DATA_OFFSET 0x60 |
| 678 | #define BIOS_RELATIVE_CARD 0x64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 680 | #define AR3 (BIT(9) + BIT(8)) |
| 681 | #define SDATA BIT(10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 683 | #define CRD_OP BIT(11) /* Cmp Reg. w/ Data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 685 | #define CRR_OP BIT(12) /* Cmp Reg. w. Reg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 687 | #define CPE_OP (BIT(14)+BIT(11)) /* Cmp SCSI phs & Branch EQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 689 | #define CPN_OP (BIT(14)+BIT(12)) /* Cmp SCSI phs & Branch NOT EQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 691 | #define ADATA_OUT 0x00 |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 692 | #define ADATA_IN BIT(8) |
| 693 | #define ACOMMAND BIT(10) |
| 694 | #define ASTATUS (BIT(10)+BIT(8)) |
| 695 | #define AMSG_OUT (BIT(10)+BIT(9)) |
| 696 | #define AMSG_IN (BIT(10)+BIT(9)+BIT(8)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 698 | #define BRH_OP BIT(13) /* Branch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 700 | #define ALWAYS 0x00 |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 701 | #define EQUAL BIT(8) |
| 702 | #define NOT_EQ BIT(9) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 704 | #define TCB_OP (BIT(13)+BIT(11)) /* Test condition & branch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 706 | #define FIFO_0 BIT(10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 708 | #define MPM_OP BIT(15) /* Match phase and move data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 710 | #define MRR_OP BIT(14) /* Move DReg. to Reg. */ |
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 S_IDREG (BIT(2)+BIT(1)+BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 714 | #define D_AR0 0x00 |
| 715 | #define D_AR1 BIT(0) |
| 716 | #define D_BUCKET (BIT(2) + BIT(1) + BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 718 | #define RAT_OP (BIT(14)+BIT(13)+BIT(11)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 720 | #define SSI_OP (BIT(15)+BIT(11)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 722 | #define SSI_ITAR_DISC (ITAR_DISC >> 8) |
| 723 | #define SSI_IDO_STRT (IDO_STRT >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 725 | #define SSI_ICMD_COMP (ICMD_COMP >> 8) |
| 726 | #define SSI_ITICKLE (ITICKLE >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 728 | #define SSI_IUNKWN (IUNKWN >> 8) |
| 729 | #define SSI_INO_CC (IUNKWN >> 8) |
| 730 | #define SSI_IRFAIL (IUNKWN >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 732 | #define NP 0x10 /*Next Phase */ |
| 733 | #define NTCMD 0x02 /*Non- Tagged Command start */ |
| 734 | #define CMDPZ 0x04 /*Command phase */ |
| 735 | #define DINT 0x12 /*Data Out/In interrupt */ |
| 736 | #define DI 0x13 /*Data Out */ |
| 737 | #define DC 0x19 /*Disconnect Message */ |
| 738 | #define ST 0x1D /*Status Phase */ |
| 739 | #define UNKNWN 0x24 /*Unknown bus action */ |
| 740 | #define CC 0x25 /*Command Completion failure */ |
| 741 | #define TICK 0x26 /*New target reselected us. */ |
| 742 | #define SELCHK 0x28 /*Select & Check SCSI ID latch reg */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 744 | #define ID_MSG_STRT hp_aramBase + 0x00 |
| 745 | #define NON_TAG_ID_MSG hp_aramBase + 0x06 |
| 746 | #define CMD_STRT hp_aramBase + 0x08 |
| 747 | #define SYNC_MSGS hp_aramBase + 0x08 |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 748 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 749 | #define TAG_STRT 0x00 |
| 750 | #define DISCONNECT_START 0x10/2 |
| 751 | #define END_DATA_START 0x14/2 |
| 752 | #define CMD_ONLY_STRT CMDPZ/2 |
| 753 | #define SELCHK_STRT SELCHK/2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | |
| 755 | #define GET_XFER_CNT(port, xfercnt) {RD_HARP32(port,hp_xfercnt_0,xfercnt); xfercnt &= 0xFFFFFF;} |
| 756 | /* #define GET_XFER_CNT(port, xfercnt) (xfercnt = RD_HARPOON(port+hp_xfercnt_2), \ |
| 757 | xfercnt <<= 16,\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 758 | xfercnt |= RDW_HARPOON((unsigned short)(port+hp_xfercnt_0))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | */ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 760 | #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] | 761 | addr >>= 16,\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 762 | WRW_HARPOON((port+hp_host_addr_hmi), (unsigned short)(addr & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | WR_HARP32(port,hp_xfercnt_0,count),\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 764 | WRW_HARPOON((port+hp_xfer_cnt_lo), (unsigned short)(count & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | count >>= 16,\ |
| 766 | WR_HARPOON(port+hp_xfer_cnt_hi, (count & 0xFF))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | |
| 768 | #define ACCEPT_MSG(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\ |
| 769 | WR_HARPOON(port+hp_scsisig, S_ILL_PH);} |
| 770 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | #define ACCEPT_MSG_ATN(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\ |
| 772 | WR_HARPOON(port+hp_scsisig, (S_ILL_PH|SCSI_ATN));} |
| 773 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | #define DISABLE_AUTO(port) (WR_HARPOON(port+hp_scsireset, PROG_RESET),\ |
| 775 | WR_HARPOON(port+hp_scsireset, 0x00)) |
| 776 | |
| 777 | #define ARAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 778 | (RD_HARPOON(p_port+hp_page_ctrl) | SGRAM_ARAM))) |
| 779 | |
| 780 | #define SGRAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 781 | (RD_HARPOON(p_port+hp_page_ctrl) & ~SGRAM_ARAM))) |
| 782 | |
| 783 | #define MDISABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 784 | (RD_HARPOON(p_port+hp_page_ctrl) | G_INT_DISABLE))) |
| 785 | |
| 786 | #define MENABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 787 | (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE))) |
| 788 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 789 | static unsigned char FPT_sisyncn(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 790 | unsigned char syncFlag); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 791 | static void FPT_ssel(u32 port, unsigned char p_card); |
| 792 | static void FPT_sres(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 793 | struct sccb_card *pCurrCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 794 | static void FPT_shandem(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 795 | struct sccb *pCurrSCCB); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 796 | static void FPT_stsyncn(u32 port, unsigned char p_card); |
| 797 | static void FPT_sisyncr(u32 port, unsigned char sync_pulse, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 798 | unsigned char offset); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 799 | static void FPT_sssyncv(u32 p_port, unsigned char p_id, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 800 | unsigned char p_sync_value, |
| 801 | struct sccb_mgr_tar_info *currTar_Info); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 802 | static void FPT_sresb(u32 port, unsigned char p_card); |
| 803 | static void FPT_sxfrp(u32 p_port, unsigned char p_card); |
| 804 | static void FPT_schkdd(u32 port, unsigned char p_card); |
| 805 | static unsigned char FPT_RdStack(u32 port, unsigned char index); |
| 806 | static void FPT_WrStack(u32 portBase, unsigned char index, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 807 | unsigned char data); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 808 | static unsigned char FPT_ChkIfChipInitialized(u32 ioPort); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 810 | static void FPT_SendMsg(u32 port, unsigned char message); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 811 | static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg, |
| 812 | unsigned char error_code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 814 | static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card); |
| 815 | static void FPT_RNVRamData(struct nvram_info *pNvRamInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 817 | static unsigned char FPT_siwidn(u32 port, unsigned char p_card); |
| 818 | static void FPT_stwidn(u32 port, unsigned char p_card); |
| 819 | static void FPT_siwidr(u32 port, unsigned char width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 821 | static void FPT_queueSelectFail(struct sccb_card *pCurrCard, |
| 822 | unsigned char p_card); |
| 823 | static void FPT_queueDisconnect(struct sccb *p_SCCB, unsigned char p_card); |
| 824 | static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, |
| 825 | struct sccb *p_SCCB, unsigned char p_card); |
| 826 | static void FPT_queueSearchSelect(struct sccb_card *pCurrCard, |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 827 | unsigned char p_card); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 828 | static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code); |
| 829 | static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char card); |
| 830 | static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB, |
| 831 | unsigned char p_card); |
| 832 | static void FPT_utilUpdateResidual(struct sccb *p_SCCB); |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 833 | static unsigned short FPT_CalcCrc16(unsigned char buffer[]); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 834 | static unsigned char FPT_CalcLrc(unsigned char buffer[]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 836 | static void FPT_Wait1Second(u32 p_port); |
| 837 | static void FPT_Wait(u32 p_port, unsigned char p_delay); |
| 838 | static void FPT_utilEEWriteOnOff(u32 p_port, unsigned char p_mode); |
| 839 | static void FPT_utilEEWrite(u32 p_port, unsigned short ee_data, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 840 | unsigned short ee_addr); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 841 | static unsigned short FPT_utilEERead(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 842 | unsigned short ee_addr); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 843 | static unsigned short FPT_utilEEReadOrg(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 844 | unsigned short ee_addr); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 845 | static void FPT_utilEESendCmdAddr(u32 p_port, unsigned char ee_cmd, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 846 | unsigned short ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 848 | static void FPT_phaseDataOut(u32 port, unsigned char p_card); |
| 849 | static void FPT_phaseDataIn(u32 port, unsigned char p_card); |
| 850 | static void FPT_phaseCommand(u32 port, unsigned char p_card); |
| 851 | static void FPT_phaseStatus(u32 port, unsigned char p_card); |
| 852 | static void FPT_phaseMsgOut(u32 port, unsigned char p_card); |
| 853 | static void FPT_phaseMsgIn(u32 port, unsigned char p_card); |
| 854 | static void FPT_phaseIllegal(u32 port, unsigned char p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 856 | static void FPT_phaseDecode(u32 port, unsigned char p_card); |
| 857 | static void FPT_phaseChkFifo(u32 port, unsigned char p_card); |
| 858 | static void FPT_phaseBusFree(u32 p_port, unsigned char p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 860 | static void FPT_XbowInit(u32 port, unsigned char scamFlg); |
| 861 | static void FPT_BusMasterInit(u32 p_port); |
| 862 | static void FPT_DiagEEPROM(u32 p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 864 | static void FPT_dataXferProcessor(u32 port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 865 | struct sccb_card *pCurrCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 866 | static void FPT_busMstrSGDataXferStart(u32 port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 867 | struct sccb *pCurrSCCB); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 868 | static void FPT_busMstrDataXferStart(u32 port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 869 | struct sccb *pCurrSCCB); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 870 | static void FPT_hostDataXferAbort(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 871 | struct sccb *pCurrSCCB); |
| 872 | static void FPT_hostDataXferRestart(struct sccb *currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 874 | static unsigned char FPT_SccbMgr_bad_isr(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 875 | unsigned char p_card, |
| 876 | struct sccb_card *pCurrCard, |
| 877 | unsigned short p_int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 879 | static void FPT_SccbMgrTableInitAll(void); |
| 880 | static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard, |
| 881 | unsigned char p_card); |
| 882 | static void FPT_SccbMgrTableInitTarget(unsigned char p_card, |
| 883 | unsigned char target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 885 | static void FPT_scini(unsigned char p_card, unsigned char p_our_id, |
| 886 | unsigned char p_power_up); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 888 | static int FPT_scarb(u32 p_port, unsigned char p_sel_type); |
| 889 | static void FPT_scbusf(u32 p_port); |
| 890 | static void FPT_scsel(u32 p_port); |
| 891 | static void FPT_scasid(unsigned char p_card, u32 p_port); |
| 892 | static unsigned char FPT_scxferc(u32 p_port, unsigned char p_data); |
| 893 | static unsigned char FPT_scsendi(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 894 | unsigned char p_id_string[]); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 895 | static unsigned char FPT_sciso(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 896 | unsigned char p_id_string[]); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 897 | static void FPT_scwirod(u32 p_port, unsigned char p_data_bit); |
| 898 | static void FPT_scwiros(u32 p_port, unsigned char p_data_bit); |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 899 | static unsigned char FPT_scvalq(unsigned char p_quintet); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 900 | static unsigned char FPT_scsell(u32 p_port, unsigned char targ_id); |
| 901 | static void FPT_scwtsel(u32 p_port); |
| 902 | static void FPT_inisci(unsigned char p_card, u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 903 | unsigned char p_our_id); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 904 | static void FPT_scsavdi(unsigned char p_card, u32 p_port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 905 | static unsigned char FPT_scmachid(unsigned char p_card, |
| 906 | unsigned char p_id_string[]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 908 | static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card); |
| 909 | static void FPT_autoLoadDefaultMap(u32 p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 911 | static struct sccb_mgr_tar_info FPT_sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR] = |
| 912 | { {{0}} }; |
| 913 | static struct sccb_card FPT_BL_Card[MAX_CARDS] = { {0} }; |
| 914 | static SCCBSCAM_INFO FPT_scamInfo[MAX_SCSI_TAR] = { {{0}} }; |
| 915 | static struct nvram_info FPT_nvRamInfo[MAX_MB_CARDS] = { {0} }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 917 | static unsigned char FPT_mbCards = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 918 | static unsigned char FPT_scamHAString[] = |
| 919 | { 0x63, 0x07, 'B', 'U', 'S', 'L', 'O', 'G', 'I', 'C', |
| 920 | ' ', 'B', 'T', '-', '9', '3', '0', |
| 921 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 922 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 |
| 923 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 925 | static unsigned short FPT_default_intena = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 927 | static void (*FPT_s_PhaseTbl[8]) (u32, unsigned char) = { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 928 | 0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | |
| 930 | /*--------------------------------------------------------------------- |
| 931 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 932 | * Function: FlashPoint_ProbeHostAdapter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | * |
| 934 | * Description: Setup and/or Search for cards and return info to caller. |
| 935 | * |
| 936 | *---------------------------------------------------------------------*/ |
| 937 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 938 | static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo) |
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 | static unsigned char first_time = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 942 | unsigned char i, j, id, ScamFlg; |
| 943 | unsigned short temp, temp2, temp3, temp4, temp5, temp6; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 944 | u32 ioport; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 945 | struct nvram_info *pCurrNvRam; |
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 | ioport = pCardInfo->si_baseaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 949 | if (RD_HARPOON(ioport + hp_vendor_id_0) != ORION_VEND_0) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 950 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 952 | if ((RD_HARPOON(ioport + hp_vendor_id_1) != ORION_VEND_1)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 953 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 955 | if ((RD_HARPOON(ioport + hp_device_id_0) != ORION_DEV_0)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 956 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 958 | if ((RD_HARPOON(ioport + hp_device_id_1) != ORION_DEV_1)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 959 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 961 | if (RD_HARPOON(ioport + hp_rev_num) != 0x0f) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | |
| 963 | /* For new Harpoon then check for sub_device ID LSB |
| 964 | the bits(0-3) must be all ZERO for compatible with |
| 965 | current version of SCCBMgr, else skip this Harpoon |
| 966 | device. */ |
| 967 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 968 | if (RD_HARPOON(ioport + hp_sub_device_id_0) & 0x0f) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 969 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | } |
| 971 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 972 | if (first_time) { |
| 973 | FPT_SccbMgrTableInitAll(); |
| 974 | first_time = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 975 | FPT_mbCards = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 976 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 978 | if (FPT_RdStack(ioport, 0) != 0x00) { |
| 979 | if (FPT_ChkIfChipInitialized(ioport) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | pCurrNvRam = NULL; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 981 | WR_HARPOON(ioport + hp_semaphore, 0x00); |
| 982 | FPT_XbowInit(ioport, 0); /*Must Init the SCSI before attempting */ |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 983 | FPT_DiagEEPROM(ioport); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 984 | } else { |
| 985 | if (FPT_mbCards < MAX_MB_CARDS) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 986 | pCurrNvRam = &FPT_nvRamInfo[FPT_mbCards]; |
| 987 | FPT_mbCards++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | pCurrNvRam->niBaseAddr = ioport; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 989 | FPT_RNVRamData(pCurrNvRam); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 990 | } else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 991 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 993 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | pCurrNvRam = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 996 | WR_HARPOON(ioport + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 997 | WR_HARPOON(ioport + hp_sys_ctrl, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 999 | if (pCurrNvRam) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | pCardInfo->si_id = pCurrNvRam->niAdapId; |
| 1001 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1002 | pCardInfo->si_id = |
| 1003 | (unsigned |
| 1004 | char)(FPT_utilEERead(ioport, |
| 1005 | (ADAPTER_SCSI_ID / |
| 1006 | 2)) & (unsigned char)0x0FF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1008 | pCardInfo->si_lun = 0x00; |
| 1009 | pCardInfo->si_fw_revision = ORION_FW_REV; |
| 1010 | temp2 = 0x0000; |
| 1011 | temp3 = 0x0000; |
| 1012 | temp4 = 0x0000; |
| 1013 | temp5 = 0x0000; |
| 1014 | temp6 = 0x0000; |
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 | for (id = 0; id < (16 / 2); id++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1018 | if (pCurrNvRam) { |
| 1019 | temp = (unsigned short)pCurrNvRam->niSyncTbl[id]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) + |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1021 | (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000)); |
| 1022 | } else |
| 1023 | temp = |
| 1024 | FPT_utilEERead(ioport, |
| 1025 | (unsigned short)((SYNC_RATE_TBL / 2) |
| 1026 | + id)); |
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 | for (i = 0; i < 2; temp >>= 8, i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1030 | temp2 >>= 1; |
| 1031 | temp3 >>= 1; |
| 1032 | temp4 >>= 1; |
| 1033 | temp5 >>= 1; |
| 1034 | temp6 >>= 1; |
| 1035 | switch (temp & 0x3) { |
| 1036 | case AUTO_RATE_20: /* Synchronous, 20 mega-transfers/second */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1037 | temp6 |= 0x8000; |
| 1038 | fallthrough; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1039 | case AUTO_RATE_10: /* Synchronous, 10 mega-transfers/second */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1040 | temp5 |= 0x8000; |
| 1041 | fallthrough; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1042 | case AUTO_RATE_05: /* Synchronous, 5 mega-transfers/second */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1043 | temp2 |= 0x8000; |
| 1044 | fallthrough; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1045 | case AUTO_RATE_00: /* Asynchronous */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | break; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | if (temp & DISC_ENABLE_BIT) |
| 1050 | temp3 |= 0x8000; |
| 1051 | |
| 1052 | if (temp & WIDE_NEGO_BIT) |
| 1053 | temp4 |= 0x8000; |
| 1054 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1058 | pCardInfo->si_per_targ_init_sync = temp2; |
| 1059 | pCardInfo->si_per_targ_no_disc = temp3; |
| 1060 | pCardInfo->si_per_targ_wide_nego = temp4; |
| 1061 | pCardInfo->si_per_targ_fast_nego = temp5; |
| 1062 | pCardInfo->si_per_targ_ultra_nego = temp6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1064 | if (pCurrNvRam) |
| 1065 | i = pCurrNvRam->niSysConf; |
| 1066 | else |
| 1067 | i = (unsigned |
| 1068 | char)(FPT_utilEERead(ioport, (SYSTEM_CONFIG / 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1070 | if (pCurrNvRam) |
| 1071 | ScamFlg = pCurrNvRam->niScamConf; |
| 1072 | else |
| 1073 | ScamFlg = |
| 1074 | (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1075 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1076 | pCardInfo->si_flags = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1078 | if (i & 0x01) |
| 1079 | pCardInfo->si_flags |= SCSI_PARITY_ENA; |
| 1080 | |
| 1081 | if (!(i & 0x02)) |
| 1082 | pCardInfo->si_flags |= SOFT_RESET; |
| 1083 | |
| 1084 | if (i & 0x10) |
| 1085 | pCardInfo->si_flags |= EXTENDED_TRANSLATION; |
| 1086 | |
| 1087 | if (ScamFlg & SCAM_ENABLED) |
| 1088 | pCardInfo->si_flags |= FLAG_SCAM_ENABLED; |
| 1089 | |
| 1090 | if (ScamFlg & SCAM_LEVEL2) |
| 1091 | pCardInfo->si_flags |= FLAG_SCAM_LEVEL2; |
| 1092 | |
| 1093 | j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L); |
| 1094 | if (i & 0x04) { |
| 1095 | j |= SCSI_TERM_ENA_L; |
| 1096 | } |
| 1097 | WR_HARPOON(ioport + hp_bm_ctrl, j); |
| 1098 | |
| 1099 | j = (RD_HARPOON(ioport + hp_ee_ctrl) & ~SCSI_TERM_ENA_H); |
| 1100 | if (i & 0x08) { |
| 1101 | j |= SCSI_TERM_ENA_H; |
| 1102 | } |
| 1103 | WR_HARPOON(ioport + hp_ee_ctrl, j); |
| 1104 | |
| 1105 | if (!(RD_HARPOON(ioport + hp_page_ctrl) & NARROW_SCSI_CARD)) |
| 1106 | |
| 1107 | pCardInfo->si_flags |= SUPPORT_16TAR_32LUN; |
| 1108 | |
| 1109 | pCardInfo->si_card_family = HARPOON_FAMILY; |
| 1110 | pCardInfo->si_bustype = BUSTYPE_PCI; |
| 1111 | |
| 1112 | if (pCurrNvRam) { |
| 1113 | pCardInfo->si_card_model[0] = '9'; |
| 1114 | switch (pCurrNvRam->niModel & 0x0f) { |
| 1115 | case MODEL_LT: |
| 1116 | pCardInfo->si_card_model[1] = '3'; |
| 1117 | pCardInfo->si_card_model[2] = '0'; |
| 1118 | break; |
| 1119 | case MODEL_LW: |
| 1120 | pCardInfo->si_card_model[1] = '5'; |
| 1121 | pCardInfo->si_card_model[2] = '0'; |
| 1122 | break; |
| 1123 | case MODEL_DL: |
| 1124 | pCardInfo->si_card_model[1] = '3'; |
| 1125 | pCardInfo->si_card_model[2] = '2'; |
| 1126 | break; |
| 1127 | case MODEL_DW: |
| 1128 | pCardInfo->si_card_model[1] = '5'; |
| 1129 | pCardInfo->si_card_model[2] = '2'; |
| 1130 | break; |
| 1131 | } |
| 1132 | } else { |
| 1133 | temp = FPT_utilEERead(ioport, (MODEL_NUMB_0 / 2)); |
| 1134 | pCardInfo->si_card_model[0] = (unsigned char)(temp >> 8); |
| 1135 | temp = FPT_utilEERead(ioport, (MODEL_NUMB_2 / 2)); |
| 1136 | |
| 1137 | pCardInfo->si_card_model[1] = (unsigned char)(temp & 0x00FF); |
| 1138 | pCardInfo->si_card_model[2] = (unsigned char)(temp >> 8); |
| 1139 | } |
| 1140 | |
| 1141 | if (pCardInfo->si_card_model[1] == '3') { |
| 1142 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1143 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1144 | } else if (pCardInfo->si_card_model[2] == '0') { |
| 1145 | temp = RD_HARPOON(ioport + hp_xfer_pad); |
| 1146 | WR_HARPOON(ioport + hp_xfer_pad, (temp & ~BIT(4))); |
| 1147 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1148 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1149 | WR_HARPOON(ioport + hp_xfer_pad, (temp | BIT(4))); |
| 1150 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
| 1151 | pCardInfo->si_flags |= HIGH_BYTE_TERM; |
| 1152 | WR_HARPOON(ioport + hp_xfer_pad, temp); |
| 1153 | } else { |
| 1154 | temp = RD_HARPOON(ioport + hp_ee_ctrl); |
| 1155 | temp2 = RD_HARPOON(ioport + hp_xfer_pad); |
| 1156 | WR_HARPOON(ioport + hp_ee_ctrl, (temp | SEE_CS)); |
| 1157 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 | BIT(4))); |
| 1158 | temp3 = 0; |
| 1159 | for (i = 0; i < 8; i++) { |
| 1160 | temp3 <<= 1; |
| 1161 | if (!(RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))) |
| 1162 | temp3 |= 1; |
| 1163 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 & ~BIT(4))); |
| 1164 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 | BIT(4))); |
| 1165 | } |
| 1166 | WR_HARPOON(ioport + hp_ee_ctrl, temp); |
| 1167 | WR_HARPOON(ioport + hp_xfer_pad, temp2); |
| 1168 | if (!(temp3 & BIT(7))) |
| 1169 | pCardInfo->si_flags |= LOW_BYTE_TERM; |
| 1170 | if (!(temp3 & BIT(6))) |
| 1171 | pCardInfo->si_flags |= HIGH_BYTE_TERM; |
| 1172 | } |
| 1173 | |
| 1174 | ARAM_ACCESS(ioport); |
| 1175 | |
| 1176 | for (i = 0; i < 4; i++) { |
| 1177 | |
| 1178 | pCardInfo->si_XlatInfo[i] = |
| 1179 | RD_HARPOON(ioport + hp_aramBase + BIOS_DATA_OFFSET + i); |
| 1180 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | |
| 1182 | /* return with -1 if no sort, else return with |
| 1183 | logical card number sorted by BIOS (zero-based) */ |
| 1184 | |
| 1185 | pCardInfo->si_relative_cardnum = |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1186 | (unsigned |
| 1187 | char)(RD_HARPOON(ioport + hp_aramBase + BIOS_RELATIVE_CARD) - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1189 | SGRAM_ACCESS(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1191 | FPT_s_PhaseTbl[0] = FPT_phaseDataOut; |
| 1192 | FPT_s_PhaseTbl[1] = FPT_phaseDataIn; |
| 1193 | FPT_s_PhaseTbl[2] = FPT_phaseIllegal; |
| 1194 | FPT_s_PhaseTbl[3] = FPT_phaseIllegal; |
| 1195 | FPT_s_PhaseTbl[4] = FPT_phaseCommand; |
| 1196 | FPT_s_PhaseTbl[5] = FPT_phaseStatus; |
| 1197 | FPT_s_PhaseTbl[6] = FPT_phaseMsgOut; |
| 1198 | FPT_s_PhaseTbl[7] = FPT_phaseMsgIn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1200 | pCardInfo->si_present = 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1202 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | /*--------------------------------------------------------------------- |
| 1206 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1207 | * Function: FlashPoint_HardwareResetHostAdapter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | * |
| 1209 | * Description: Setup adapter for normal operation (hard reset). |
| 1210 | * |
| 1211 | *---------------------------------------------------------------------*/ |
| 1212 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1213 | static void *FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1214 | *pCardInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1216 | struct sccb_card *CurrCard = NULL; |
| 1217 | struct nvram_info *pCurrNvRam; |
| 1218 | unsigned char i, j, thisCard, ScamFlg; |
| 1219 | unsigned short temp, sync_bit_map, id; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1220 | u32 ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1222 | ioport = pCardInfo->si_baseaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1224 | for (thisCard = 0; thisCard <= MAX_CARDS; thisCard++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1225 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1226 | if (thisCard == MAX_CARDS) |
| 1227 | return (void *)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1228 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1229 | if (FPT_BL_Card[thisCard].ioPort == ioport) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1230 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1231 | CurrCard = &FPT_BL_Card[thisCard]; |
| 1232 | FPT_SccbMgrTableInitCard(CurrCard, thisCard); |
| 1233 | break; |
| 1234 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1236 | else if (FPT_BL_Card[thisCard].ioPort == 0x00) { |
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 | FPT_BL_Card[thisCard].ioPort = ioport; |
| 1239 | CurrCard = &FPT_BL_Card[thisCard]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1241 | if (FPT_mbCards) |
| 1242 | for (i = 0; i < FPT_mbCards; i++) { |
| 1243 | if (CurrCard->ioPort == |
| 1244 | FPT_nvRamInfo[i].niBaseAddr) |
| 1245 | CurrCard->pNvRamInfo = |
| 1246 | &FPT_nvRamInfo[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1248 | FPT_SccbMgrTableInitCard(CurrCard, thisCard); |
| 1249 | CurrCard->cardIndex = thisCard; |
| 1250 | CurrCard->cardInfo = pCardInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1252 | break; |
| 1253 | } |
| 1254 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | |
| 1256 | pCurrNvRam = CurrCard->pNvRamInfo; |
| 1257 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1258 | if (pCurrNvRam) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | ScamFlg = pCurrNvRam->niScamConf; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1260 | } else { |
| 1261 | ScamFlg = |
| 1262 | (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | } |
| 1264 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1265 | FPT_BusMasterInit(ioport); |
| 1266 | FPT_XbowInit(ioport, ScamFlg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1268 | FPT_autoLoadDefaultMap(ioport); |
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 | for (i = 0, id = 0x01; i != pCardInfo->si_id; i++, id <<= 1) { |
| 1271 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1273 | WR_HARPOON(ioport + hp_selfid_0, id); |
| 1274 | WR_HARPOON(ioport + hp_selfid_1, 0x00); |
| 1275 | WR_HARPOON(ioport + hp_arb_id, pCardInfo->si_id); |
| 1276 | CurrCard->ourId = pCardInfo->si_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1278 | i = (unsigned char)pCardInfo->si_flags; |
| 1279 | if (i & SCSI_PARITY_ENA) |
| 1280 | WR_HARPOON(ioport + hp_portctrl_1, (HOST_MODE8 | CHK_SCSI_P)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1281 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1282 | j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L); |
| 1283 | if (i & LOW_BYTE_TERM) |
| 1284 | j |= SCSI_TERM_ENA_L; |
| 1285 | WR_HARPOON(ioport + hp_bm_ctrl, j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1287 | j = (RD_HARPOON(ioport + hp_ee_ctrl) & ~SCSI_TERM_ENA_H); |
| 1288 | if (i & HIGH_BYTE_TERM) |
| 1289 | j |= SCSI_TERM_ENA_H; |
| 1290 | WR_HARPOON(ioport + hp_ee_ctrl, j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1292 | if (!(pCardInfo->si_flags & SOFT_RESET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1294 | FPT_sresb(ioport, thisCard); |
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 | FPT_scini(thisCard, pCardInfo->si_id, 0); |
| 1297 | } |
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 (pCardInfo->si_flags & POST_ALL_UNDERRRUNS) |
| 1300 | CurrCard->globalFlags |= F_NO_FILTER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1302 | if (pCurrNvRam) { |
| 1303 | if (pCurrNvRam->niSysConf & 0x10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1304 | CurrCard->globalFlags |= F_GREEN_PC; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1305 | } else { |
| 1306 | if (FPT_utilEERead(ioport, (SYSTEM_CONFIG / 2)) & GREEN_PC_ENA) |
| 1307 | CurrCard->globalFlags |= F_GREEN_PC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1308 | } |
| 1309 | |
| 1310 | /* Set global flag to indicate Re-Negotiation to be done on all |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1311 | ckeck condition */ |
| 1312 | if (pCurrNvRam) { |
| 1313 | if (pCurrNvRam->niScsiConf & 0x04) |
| 1314 | CurrCard->globalFlags |= F_DO_RENEGO; |
| 1315 | } else { |
| 1316 | if (FPT_utilEERead(ioport, (SCSI_CONFIG / 2)) & RENEGO_ENA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1317 | CurrCard->globalFlags |= F_DO_RENEGO; |
| 1318 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1319 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1320 | if (pCurrNvRam) { |
| 1321 | if (pCurrNvRam->niScsiConf & 0x08) |
| 1322 | CurrCard->globalFlags |= F_CONLUN_IO; |
| 1323 | } else { |
| 1324 | if (FPT_utilEERead(ioport, (SCSI_CONFIG / 2)) & CONNIO_ENA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | CurrCard->globalFlags |= F_CONLUN_IO; |
| 1326 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1327 | |
| 1328 | temp = pCardInfo->si_per_targ_no_disc; |
| 1329 | |
| 1330 | for (i = 0, id = 1; i < MAX_SCSI_TAR; i++, id <<= 1) { |
| 1331 | |
| 1332 | if (temp & id) |
| 1333 | FPT_sccbMgrTbl[thisCard][i].TarStatus |= TAR_ALLOW_DISC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | } |
| 1335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1336 | sync_bit_map = 0x0001; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1337 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1338 | for (id = 0; id < (MAX_SCSI_TAR / 2); id++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1340 | if (pCurrNvRam) { |
| 1341 | temp = (unsigned short)pCurrNvRam->niSyncTbl[id]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) + |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1343 | (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000)); |
| 1344 | } else |
| 1345 | temp = |
| 1346 | FPT_utilEERead(ioport, |
| 1347 | (unsigned short)((SYNC_RATE_TBL / 2) |
| 1348 | + id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1349 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1350 | for (i = 0; i < 2; temp >>= 8, i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1352 | if (pCardInfo->si_per_targ_init_sync & sync_bit_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1353 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1354 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1355 | i].TarEEValue = |
| 1356 | (unsigned char)temp; |
| 1357 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1358 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1359 | else { |
| 1360 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1361 | i].TarStatus |= |
| 1362 | SYNC_SUPPORTED; |
| 1363 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1364 | i].TarEEValue = |
| 1365 | (unsigned char)(temp & ~EE_SYNC_MASK); |
| 1366 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | /* if ((pCardInfo->si_per_targ_wide_nego & sync_bit_map) || |
| 1369 | (id*2+i >= 8)){ |
| 1370 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1371 | if (pCardInfo->si_per_targ_wide_nego & sync_bit_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1373 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1374 | i].TarEEValue |= |
| 1375 | EE_WIDE_SCSI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1376 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1377 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1379 | else { /* NARROW SCSI */ |
| 1380 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1381 | i].TarStatus |= |
| 1382 | WIDE_NEGOCIATED; |
| 1383 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1385 | sync_bit_map <<= 1; |
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 | } |
| 1388 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1390 | WR_HARPOON((ioport + hp_semaphore), |
| 1391 | (unsigned char)(RD_HARPOON((ioport + hp_semaphore)) | |
| 1392 | SCCB_MGR_PRESENT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1394 | return (void *)CurrCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | } |
| 1396 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1397 | static void FlashPoint_ReleaseHostAdapter(void *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1398 | { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1399 | unsigned char i; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1400 | u32 portBase; |
| 1401 | u32 regOffset; |
| 1402 | u32 scamData; |
| 1403 | u32 *pScamTbl; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1404 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1405 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1406 | pCurrNvRam = ((struct sccb_card *)pCurrCard)->pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1407 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1408 | if (pCurrNvRam) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 1409 | FPT_WrStack(pCurrNvRam->niBaseAddr, 0, pCurrNvRam->niModel); |
| 1410 | FPT_WrStack(pCurrNvRam->niBaseAddr, 1, pCurrNvRam->niSysConf); |
| 1411 | FPT_WrStack(pCurrNvRam->niBaseAddr, 2, pCurrNvRam->niScsiConf); |
| 1412 | FPT_WrStack(pCurrNvRam->niBaseAddr, 3, pCurrNvRam->niScamConf); |
| 1413 | FPT_WrStack(pCurrNvRam->niBaseAddr, 4, pCurrNvRam->niAdapId); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1414 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1415 | for (i = 0; i < MAX_SCSI_TAR / 2; i++) |
| 1416 | FPT_WrStack(pCurrNvRam->niBaseAddr, |
| 1417 | (unsigned char)(i + 5), |
| 1418 | pCurrNvRam->niSyncTbl[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | |
| 1420 | portBase = pCurrNvRam->niBaseAddr; |
| 1421 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1422 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 1423 | regOffset = hp_aramBase + 64 + i * 4; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1424 | pScamTbl = (u32 *)&pCurrNvRam->niScamTbl[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1425 | scamData = *pScamTbl; |
| 1426 | WR_HARP32(portBase, regOffset, scamData); |
| 1427 | } |
| 1428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1429 | } else { |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1430 | FPT_WrStack(((struct sccb_card *)pCurrCard)->ioPort, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | } |
| 1432 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1434 | static void FPT_RNVRamData(struct nvram_info *pNvRamInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1436 | unsigned char i; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1437 | u32 portBase; |
| 1438 | u32 regOffset; |
| 1439 | u32 scamData; |
| 1440 | u32 *pScamTbl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1442 | pNvRamInfo->niModel = FPT_RdStack(pNvRamInfo->niBaseAddr, 0); |
| 1443 | pNvRamInfo->niSysConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 1); |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 1444 | pNvRamInfo->niScsiConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 2); |
| 1445 | pNvRamInfo->niScamConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 3); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1446 | pNvRamInfo->niAdapId = FPT_RdStack(pNvRamInfo->niBaseAddr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1448 | for (i = 0; i < MAX_SCSI_TAR / 2; i++) |
| 1449 | pNvRamInfo->niSyncTbl[i] = |
| 1450 | FPT_RdStack(pNvRamInfo->niBaseAddr, (unsigned char)(i + 5)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1451 | |
| 1452 | portBase = pNvRamInfo->niBaseAddr; |
| 1453 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1454 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 1455 | regOffset = hp_aramBase + 64 + i * 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | RD_HARP32(portBase, regOffset, scamData); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1457 | pScamTbl = (u32 *)&pNvRamInfo->niScamTbl[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | *pScamTbl = scamData; |
| 1459 | } |
| 1460 | |
| 1461 | } |
| 1462 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1463 | static unsigned char FPT_RdStack(u32 portBase, unsigned char index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | { |
| 1465 | WR_HARPOON(portBase + hp_stack_addr, index); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1466 | return RD_HARPOON(portBase + hp_stack_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | } |
| 1468 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1469 | static void FPT_WrStack(u32 portBase, unsigned char index, unsigned char data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1470 | { |
| 1471 | WR_HARPOON(portBase + hp_stack_addr, index); |
| 1472 | WR_HARPOON(portBase + hp_stack_data, data); |
| 1473 | } |
| 1474 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1475 | static unsigned char FPT_ChkIfChipInitialized(u32 ioPort) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1477 | if ((RD_HARPOON(ioPort + hp_arb_id) & 0x0f) != FPT_RdStack(ioPort, 4)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1478 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1479 | if ((RD_HARPOON(ioPort + hp_clkctrl_0) & CLKCTRL_DEFAULT) |
| 1480 | != CLKCTRL_DEFAULT) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1481 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1482 | if ((RD_HARPOON(ioPort + hp_seltimeout) == TO_250ms) || |
| 1483 | (RD_HARPOON(ioPort + hp_seltimeout) == TO_290ms)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1484 | return 1; |
| 1485 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | |
| 1487 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | /*--------------------------------------------------------------------- |
| 1490 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1491 | * Function: FlashPoint_StartCCB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | * |
| 1493 | * Description: Start a command pointed to by p_Sccb. When the |
| 1494 | * command is completed it will be returned via the |
| 1495 | * callback function. |
| 1496 | * |
| 1497 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1498 | static void FlashPoint_StartCCB(void *curr_card, struct sccb *p_Sccb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1500 | u32 ioport; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1501 | unsigned char thisCard, lun; |
| 1502 | struct sccb *pSaveSccb; |
| 1503 | CALL_BK_FN callback; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1504 | struct sccb_card *pCurrCard = curr_card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1506 | thisCard = pCurrCard->cardIndex; |
| 1507 | ioport = pCurrCard->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1508 | |
Adrian Bunk | 1377d8d | 2008-04-23 12:51:10 +0300 | [diff] [blame] | 1509 | if ((p_Sccb->TargID >= MAX_SCSI_TAR) || (p_Sccb->Lun >= MAX_LUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | p_Sccb->HostStatus = SCCB_COMPLETE; |
| 1512 | p_Sccb->SccbStatus = SCCB_ERROR; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1513 | callback = (CALL_BK_FN) p_Sccb->SccbCallback; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | if (callback) |
| 1515 | callback(p_Sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | return; |
| 1518 | } |
| 1519 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1520 | FPT_sinits(p_Sccb, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1521 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1522 | if (!pCurrCard->cmdCounter) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1523 | WR_HARPOON(ioport + hp_semaphore, |
| 1524 | (RD_HARPOON(ioport + hp_semaphore) |
| 1525 | | SCCB_MGR_ACTIVE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1527 | if (pCurrCard->globalFlags & F_GREEN_PC) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1528 | WR_HARPOON(ioport + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 1529 | WR_HARPOON(ioport + hp_sys_ctrl, 0x00); |
| 1530 | } |
| 1531 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1533 | pCurrCard->cmdCounter++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1535 | if (RD_HARPOON(ioport + hp_semaphore) & BIOS_IN_USE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1537 | WR_HARPOON(ioport + hp_semaphore, |
| 1538 | (RD_HARPOON(ioport + hp_semaphore) |
| 1539 | | TICKLE_ME)); |
| 1540 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1541 | pSaveSccb = |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1542 | pCurrCard->currentSCCB; |
| 1543 | pCurrCard->currentSCCB = p_Sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1544 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], thisCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1545 | pCurrCard->currentSCCB = |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1546 | pSaveSccb; |
| 1547 | } else { |
| 1548 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1549 | } |
| 1550 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1551 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1552 | else if ((RD_HARPOON(ioport + hp_page_ctrl) & G_INT_DISABLE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1553 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1554 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1555 | pSaveSccb = |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1556 | pCurrCard->currentSCCB; |
| 1557 | pCurrCard->currentSCCB = p_Sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1558 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], thisCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1559 | pCurrCard->currentSCCB = |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1560 | pSaveSccb; |
| 1561 | } else { |
| 1562 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1563 | } |
| 1564 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1566 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1567 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1568 | MDISABLE_INT(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1570 | if ((pCurrCard->globalFlags & F_CONLUN_IO) && |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1571 | ((FPT_sccbMgrTbl[thisCard][p_Sccb->TargID]. |
| 1572 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1573 | lun = p_Sccb->Lun; |
| 1574 | else |
| 1575 | lun = 0; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1576 | if ((pCurrCard->currentSCCB == NULL) && |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1577 | (FPT_sccbMgrTbl[thisCard][p_Sccb->TargID].TarSelQ_Cnt == 0) |
| 1578 | && (FPT_sccbMgrTbl[thisCard][p_Sccb->TargID].TarLUNBusy[lun] |
| 1579 | == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1580 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1581 | pCurrCard->currentSCCB = p_Sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1582 | FPT_ssel(p_Sccb->SccbIOPort, thisCard); |
| 1583 | } |
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 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1586 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1587 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1588 | pSaveSccb = pCurrCard->currentSCCB; |
| 1589 | pCurrCard->currentSCCB = p_Sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1590 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], |
| 1591 | thisCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1592 | pCurrCard->currentSCCB = pSaveSccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1593 | } else { |
| 1594 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1595 | } |
| 1596 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1597 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1598 | MENABLE_INT(ioport); |
| 1599 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1600 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | } |
| 1602 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | /*--------------------------------------------------------------------- |
| 1604 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1605 | * Function: FlashPoint_AbortCCB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1606 | * |
| 1607 | * Description: Abort the command pointed to by p_Sccb. When the |
| 1608 | * command is completed it will be returned via the |
| 1609 | * callback function. |
| 1610 | * |
| 1611 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1612 | static int FlashPoint_AbortCCB(void *pCurrCard, struct sccb *p_Sccb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1614 | u32 ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1615 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1616 | unsigned char thisCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | CALL_BK_FN callback; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1618 | unsigned char TID; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1619 | struct sccb *pSaveSCCB; |
| 1620 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1622 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1623 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1624 | thisCard = ((struct sccb_card *)pCurrCard)->cardIndex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1626 | if (!(RD_HARPOON(ioport + hp_page_ctrl) & G_INT_DISABLE)) { |
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 (FPT_queueFindSccb(p_Sccb, thisCard)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1630 | ((struct sccb_card *)pCurrCard)->cmdCounter--; |
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 | if (!((struct sccb_card *)pCurrCard)->cmdCounter) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1633 | WR_HARPOON(ioport + hp_semaphore, |
| 1634 | (RD_HARPOON(ioport + hp_semaphore) |
| 1635 | & (unsigned |
| 1636 | char)(~(SCCB_MGR_ACTIVE | |
| 1637 | TICKLE_ME)))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | p_Sccb->SccbStatus = SCCB_ABORT; |
| 1640 | callback = p_Sccb->SccbCallback; |
| 1641 | callback(p_Sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1643 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | } |
| 1645 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1646 | else { |
| 1647 | if (((struct sccb_card *)pCurrCard)->currentSCCB == |
| 1648 | p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1649 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1650 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | |
| 1652 | } |
| 1653 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1654 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1655 | |
| 1656 | TID = p_Sccb->TargID; |
| 1657 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1658 | if (p_Sccb->Sccb_tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1659 | MDISABLE_INT(ioport); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1660 | if (((struct sccb_card *)pCurrCard)-> |
| 1661 | discQ_Tbl[p_Sccb->Sccb_tag] == |
| 1662 | p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1663 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1664 | p_Sccb->Sccb_scsistat = |
| 1665 | ABORT_ST; |
| 1666 | p_Sccb->Sccb_scsimsg = |
| 1667 | SMABORT_TAG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1669 | if (((struct sccb_card *) |
| 1670 | pCurrCard)->currentSCCB == |
| 1671 | NULL) { |
| 1672 | ((struct sccb_card *) |
| 1673 | pCurrCard)-> |
| 1674 | currentSCCB = p_Sccb; |
| 1675 | FPT_ssel(ioport, |
| 1676 | thisCard); |
| 1677 | } else { |
| 1678 | pSaveSCCB = |
| 1679 | ((struct sccb_card |
| 1680 | *)pCurrCard)-> |
| 1681 | currentSCCB; |
| 1682 | ((struct sccb_card *) |
| 1683 | pCurrCard)-> |
| 1684 | currentSCCB = p_Sccb; |
| 1685 | FPT_queueSelectFail((struct sccb_card *)pCurrCard, thisCard); |
| 1686 | ((struct sccb_card *) |
| 1687 | pCurrCard)-> |
| 1688 | currentSCCB = pSaveSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1689 | } |
| 1690 | } |
| 1691 | MENABLE_INT(ioport); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1692 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1693 | } else { |
| 1694 | currTar_Info = |
| 1695 | &FPT_sccbMgrTbl[thisCard][p_Sccb-> |
| 1696 | TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1697 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1698 | if (FPT_BL_Card[thisCard]. |
| 1699 | discQ_Tbl[currTar_Info-> |
| 1700 | LunDiscQ_Idx[p_Sccb->Lun]] |
| 1701 | == p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1702 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1703 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | } |
| 1705 | } |
| 1706 | } |
| 1707 | } |
| 1708 | } |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1709 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1710 | } |
| 1711 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | /*--------------------------------------------------------------------- |
| 1713 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1714 | * Function: FlashPoint_InterruptPending |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1715 | * |
| 1716 | * Description: Do a quick check to determine if there is a pending |
| 1717 | * interrupt for this card and disable the IRQ Pin if so. |
| 1718 | * |
| 1719 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1720 | static unsigned char FlashPoint_InterruptPending(void *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1722 | u32 ioport; |
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 | ioport = ((struct sccb_card *)pCurrCard)->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 | if (RD_HARPOON(ioport + hp_int_status) & INT_ASSERTED) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1727 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1728 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1729 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1730 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1732 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | } |
| 1734 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1735 | /*--------------------------------------------------------------------- |
| 1736 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1737 | * Function: FlashPoint_HandleInterrupt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1738 | * |
| 1739 | * Description: This is our entry point when an interrupt is generated |
| 1740 | * by the card and the upper level driver passes it on to |
| 1741 | * us. |
| 1742 | * |
| 1743 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1744 | static int FlashPoint_HandleInterrupt(void *pcard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1746 | struct sccb *currSCCB; |
| 1747 | unsigned char thisCard, result, bm_status, bm_int_st; |
| 1748 | unsigned short hp_int; |
| 1749 | unsigned char i, target; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1750 | struct sccb_card *pCurrCard = pcard; |
| 1751 | u32 ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1752 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1753 | thisCard = pCurrCard->cardIndex; |
| 1754 | ioport = pCurrCard->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1755 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1756 | MDISABLE_INT(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1757 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1758 | if ((bm_int_st = RD_HARPOON(ioport + hp_int_status)) & EXT_STATUS_ON) |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1759 | bm_status = RD_HARPOON(ioport + hp_ext_status) & |
| 1760 | (unsigned char)BAD_EXT_STATUS; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1761 | else |
| 1762 | bm_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1763 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1764 | WR_HARPOON(ioport + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1765 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1766 | while ((hp_int = RDW_HARPOON((ioport + hp_intstat)) & |
| 1767 | FPT_default_intena) | bm_status) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1769 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1770 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1771 | if (hp_int & (FIFO | TIMEOUT | RESET | SCAM_SEL) || bm_status) { |
| 1772 | result = |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1773 | FPT_SccbMgr_bad_isr(ioport, thisCard, pCurrCard, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1774 | hp_int); |
| 1775 | WRW_HARPOON((ioport + hp_intstat), |
| 1776 | (FIFO | TIMEOUT | RESET | SCAM_SEL)); |
| 1777 | bm_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1778 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1779 | if (result) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1780 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1781 | MENABLE_INT(ioport); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1782 | return result; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1783 | } |
| 1784 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1785 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1786 | else if (hp_int & ICMD_COMP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1788 | if (!(hp_int & BUS_FREE)) { |
| 1789 | /* Wait for the BusFree before starting a new command. We |
| 1790 | must also check for being reselected since the BusFree |
| 1791 | may not show up if another device reselects us in 1.5us or |
| 1792 | less. SRR Wednesday, 3/8/1995. |
| 1793 | */ |
| 1794 | while (! |
| 1795 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1796 | (BUS_FREE | RSEL))) ; |
| 1797 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1798 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1799 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1800 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1801 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1802 | |
| 1803 | /* WRW_HARPOON((ioport+hp_intstat), |
| 1804 | (BUS_FREE | ICMD_COMP | ITAR_DISC | XFER_CNT_0)); |
| 1805 | */ |
| 1806 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1807 | WRW_HARPOON((ioport + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1808 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1809 | FPT_autoCmdCmplt(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1810 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1811 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1812 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1813 | else if (hp_int & ITAR_DISC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1814 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1815 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1816 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1817 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1818 | if (RD_HARPOON(ioport + hp_gp_reg_1) == |
| 1819 | SMSAVE_DATA_PTR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1820 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1821 | WR_HARPOON(ioport + hp_gp_reg_1, 0x00); |
| 1822 | currSCCB->Sccb_XferState |= F_NO_DATA_YET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1823 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1824 | currSCCB->Sccb_savedATC = currSCCB->Sccb_ATC; |
| 1825 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1826 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1827 | currSCCB->Sccb_scsistat = DISCONNECT_ST; |
| 1828 | FPT_queueDisconnect(currSCCB, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1830 | /* Wait for the BusFree before starting a new command. We |
| 1831 | must also check for being reselected since the BusFree |
| 1832 | may not show up if another device reselects us in 1.5us or |
| 1833 | less. SRR Wednesday, 3/8/1995. |
| 1834 | */ |
| 1835 | while (! |
| 1836 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1837 | (BUS_FREE | RSEL)) |
| 1838 | && !((RDW_HARPOON((ioport + hp_intstat)) & PHASE) |
| 1839 | && RD_HARPOON((ioport + hp_scsisig)) == |
| 1840 | (SCSI_BSY | SCSI_REQ | SCSI_CD | SCSI_MSG | |
| 1841 | SCSI_IOBIT))) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1842 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1843 | /* |
| 1844 | The additional loop exit condition above detects a timing problem |
| 1845 | with the revision D/E harpoon chips. The caller should reset the |
| 1846 | host adapter to recover when 0xFE is returned. |
| 1847 | */ |
| 1848 | if (! |
| 1849 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1850 | (BUS_FREE | RSEL))) { |
| 1851 | MENABLE_INT(ioport); |
| 1852 | return 0xFE; |
| 1853 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1854 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1855 | WRW_HARPOON((ioport + hp_intstat), |
| 1856 | (BUS_FREE | ITAR_DISC)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1857 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1858 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1859 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1860 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1861 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1862 | else if (hp_int & RSEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1863 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1864 | WRW_HARPOON((ioport + hp_intstat), |
| 1865 | (PROG_HLT | RSEL | PHASE | BUS_FREE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1867 | if (RDW_HARPOON((ioport + hp_intstat)) & ITAR_DISC) { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1868 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1869 | FPT_phaseChkFifo(ioport, thisCard); |
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 | if (RD_HARPOON(ioport + hp_gp_reg_1) == |
| 1872 | SMSAVE_DATA_PTR) { |
| 1873 | WR_HARPOON(ioport + hp_gp_reg_1, 0x00); |
| 1874 | currSCCB->Sccb_XferState |= |
| 1875 | F_NO_DATA_YET; |
| 1876 | currSCCB->Sccb_savedATC = |
| 1877 | currSCCB->Sccb_ATC; |
| 1878 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1879 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1880 | WRW_HARPOON((ioport + hp_intstat), |
| 1881 | (BUS_FREE | ITAR_DISC)); |
| 1882 | currSCCB->Sccb_scsistat = DISCONNECT_ST; |
| 1883 | FPT_queueDisconnect(currSCCB, thisCard); |
| 1884 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1885 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1886 | FPT_sres(ioport, thisCard, pCurrCard); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1887 | FPT_phaseDecode(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1888 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 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 | else if ((hp_int & IDO_STRT) && (!(hp_int & BUS_FREE))) { |
| 1892 | |
| 1893 | WRW_HARPOON((ioport + hp_intstat), |
| 1894 | (IDO_STRT | XFER_CNT_0)); |
| 1895 | FPT_phaseDecode(ioport, thisCard); |
| 1896 | |
| 1897 | } |
| 1898 | |
| 1899 | else if ((hp_int & IUNKWN) || (hp_int & PROG_HLT)) { |
| 1900 | WRW_HARPOON((ioport + hp_intstat), |
| 1901 | (PHASE | IUNKWN | PROG_HLT)); |
| 1902 | if ((RD_HARPOON(ioport + hp_prgmcnt_0) & (unsigned char) |
| 1903 | 0x3f) < (unsigned char)SELCHK) { |
| 1904 | FPT_phaseDecode(ioport, thisCard); |
| 1905 | } else { |
| 1906 | /* Harpoon problem some SCSI target device respond to selection |
| 1907 | with short BUSY pulse (<400ns) this will make the Harpoon is not able |
| 1908 | to latch the correct Target ID into reg. x53. |
| 1909 | The work around require to correct this reg. But when write to this |
| 1910 | reg. (0x53) also increment the FIFO write addr reg (0x6f), thus we |
| 1911 | need to read this reg first then restore it later. After update to 0x53 */ |
| 1912 | |
| 1913 | i = (unsigned |
| 1914 | char)(RD_HARPOON(ioport + hp_fifowrite)); |
| 1915 | target = |
| 1916 | (unsigned |
| 1917 | char)(RD_HARPOON(ioport + hp_gp_reg_3)); |
| 1918 | WR_HARPOON(ioport + hp_xfer_pad, |
| 1919 | (unsigned char)ID_UNLOCK); |
| 1920 | WR_HARPOON(ioport + hp_select_id, |
| 1921 | (unsigned char)(target | target << |
| 1922 | 4)); |
| 1923 | WR_HARPOON(ioport + hp_xfer_pad, |
| 1924 | (unsigned char)0x00); |
| 1925 | WR_HARPOON(ioport + hp_fifowrite, i); |
| 1926 | WR_HARPOON(ioport + hp_autostart_3, |
| 1927 | (AUTO_IMMED + TAG_STRT)); |
| 1928 | } |
| 1929 | } |
| 1930 | |
| 1931 | else if (hp_int & XFER_CNT_0) { |
| 1932 | |
| 1933 | WRW_HARPOON((ioport + hp_intstat), XFER_CNT_0); |
| 1934 | |
| 1935 | FPT_schkdd(ioport, thisCard); |
| 1936 | |
| 1937 | } |
| 1938 | |
| 1939 | else if (hp_int & BUS_FREE) { |
| 1940 | |
| 1941 | WRW_HARPOON((ioport + hp_intstat), BUS_FREE); |
| 1942 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1943 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1944 | |
| 1945 | FPT_hostDataXferAbort(ioport, thisCard, |
| 1946 | currSCCB); |
| 1947 | } |
| 1948 | |
| 1949 | FPT_phaseBusFree(ioport, thisCard); |
| 1950 | } |
| 1951 | |
| 1952 | else if (hp_int & ITICKLE) { |
| 1953 | |
| 1954 | WRW_HARPOON((ioport + hp_intstat), ITICKLE); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1955 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1956 | } |
| 1957 | |
| 1958 | if (((struct sccb_card *)pCurrCard)-> |
| 1959 | globalFlags & F_NEW_SCCB_CMD) { |
| 1960 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1961 | pCurrCard->globalFlags &= ~F_NEW_SCCB_CMD; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1962 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1963 | if (pCurrCard->currentSCCB == NULL) |
| 1964 | FPT_queueSearchSelect(pCurrCard, thisCard); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1965 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1966 | if (pCurrCard->currentSCCB != NULL) { |
| 1967 | pCurrCard->globalFlags &= ~F_NEW_SCCB_CMD; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1968 | FPT_ssel(ioport, thisCard); |
| 1969 | } |
| 1970 | |
| 1971 | break; |
| 1972 | |
| 1973 | } |
| 1974 | |
| 1975 | } /*end while */ |
| 1976 | |
| 1977 | MENABLE_INT(ioport); |
| 1978 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1979 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1980 | } |
| 1981 | |
| 1982 | /*--------------------------------------------------------------------- |
| 1983 | * |
| 1984 | * Function: Sccb_bad_isr |
| 1985 | * |
| 1986 | * Description: Some type of interrupt has occurred which is slightly |
| 1987 | * out of the ordinary. We will now decode it fully, in |
| 1988 | * this routine. This is broken up in an attempt to save |
| 1989 | * processing time. |
| 1990 | * |
| 1991 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1992 | static unsigned char FPT_SccbMgr_bad_isr(u32 p_port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1993 | struct sccb_card *pCurrCard, |
| 1994 | unsigned short p_int) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1996 | unsigned char temp, ScamFlg; |
| 1997 | struct sccb_mgr_tar_info *currTar_Info; |
| 1998 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1999 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2000 | if (RD_HARPOON(p_port + hp_ext_status) & |
| 2001 | (BM_FORCE_OFF | PCI_DEV_TMOUT | BM_PARITY_ERR | PIO_OVERRUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2002 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2003 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2004 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2005 | FPT_hostDataXferAbort(p_port, p_card, |
| 2006 | pCurrCard->currentSCCB); |
| 2007 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2009 | if (RD_HARPOON(p_port + hp_pci_stat_cfg) & REC_MASTER_ABORT) |
| 2010 | { |
| 2011 | WR_HARPOON(p_port + hp_pci_stat_cfg, |
| 2012 | (RD_HARPOON(p_port + hp_pci_stat_cfg) & |
| 2013 | ~REC_MASTER_ABORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2014 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2015 | WR_HARPOON(p_port + hp_host_blk_cnt, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2016 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2017 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2018 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2019 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2020 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2021 | if (!pCurrCard->currentSCCB->HostStatus) |
| 2022 | pCurrCard->currentSCCB->HostStatus = |
| 2023 | SCCB_BM_ERR; |
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 | FPT_sxfrp(p_port, p_card); |
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 | temp = (unsigned char)(RD_HARPOON(p_port + hp_ee_ctrl) & |
| 2028 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)); |
| 2029 | WR_HARPOON(p_port + hp_ee_ctrl, |
| 2030 | ((unsigned char)temp | SEE_MS | SEE_CS)); |
| 2031 | WR_HARPOON(p_port + hp_ee_ctrl, temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2033 | if (! |
| 2034 | (RDW_HARPOON((p_port + hp_intstat)) & |
| 2035 | (BUS_FREE | RESET))) { |
| 2036 | FPT_phaseDecode(p_port, p_card); |
| 2037 | } |
| 2038 | } |
| 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 | else if (p_int & RESET) { |
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 | WR_HARPOON(p_port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 2044 | WR_HARPOON(p_port + hp_sys_ctrl, 0x00); |
| 2045 | if (pCurrCard->currentSCCB != NULL) { |
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 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
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 | FPT_hostDataXferAbort(p_port, p_card, |
| 2050 | pCurrCard->currentSCCB); |
| 2051 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2052 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2053 | DISABLE_AUTO(p_port); |
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 | FPT_sresb(p_port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2056 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2057 | while (RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST) { |
| 2058 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2059 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2060 | pCurrNvRam = pCurrCard->pNvRamInfo; |
| 2061 | if (pCurrNvRam) { |
| 2062 | ScamFlg = pCurrNvRam->niScamConf; |
| 2063 | } else { |
| 2064 | ScamFlg = |
| 2065 | (unsigned char)FPT_utilEERead(p_port, |
| 2066 | SCAM_CONFIG / 2); |
| 2067 | } |
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 | FPT_XbowInit(p_port, ScamFlg); |
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_scini(p_card, pCurrCard->ourId, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2072 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2073 | return 0xFF; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2074 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2076 | else if (p_int & FIFO) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2078 | WRW_HARPOON((p_port + hp_intstat), FIFO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2079 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2080 | if (pCurrCard->currentSCCB != NULL) |
| 2081 | FPT_sxfrp(p_port, p_card); |
| 2082 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2084 | else if (p_int & TIMEOUT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2086 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2087 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2088 | WRW_HARPOON((p_port + hp_intstat), |
| 2089 | (PROG_HLT | TIMEOUT | SEL | BUS_FREE | PHASE | |
| 2090 | IUNKWN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2092 | pCurrCard->currentSCCB->HostStatus = SCCB_SELECTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2093 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2094 | currTar_Info = |
| 2095 | &FPT_sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID]; |
| 2096 | if ((pCurrCard->globalFlags & F_CONLUN_IO) |
| 2097 | && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 2098 | TAG_Q_TRYING)) |
| 2099 | currTar_Info->TarLUNBusy[pCurrCard->currentSCCB->Lun] = |
| 2100 | 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2101 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2102 | currTar_Info->TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2104 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 2105 | currTar_Info->TarSyncCtrl = 0; |
| 2106 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 2107 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2109 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 2110 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2111 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2112 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2113 | FPT_sssyncv(p_port, pCurrCard->currentSCCB->TargID, NARROW_SCSI, |
| 2114 | currTar_Info); |
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 | FPT_queueCmdComplete(pCurrCard, pCurrCard->currentSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2117 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2118 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2119 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2120 | else if (p_int & SCAM_SEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2121 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2122 | FPT_scarb(p_port, LEVEL2_TAR); |
| 2123 | FPT_scsel(p_port); |
| 2124 | FPT_scasid(p_card, p_port); |
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 | FPT_scbusf(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2128 | WRW_HARPOON((p_port + hp_intstat), SCAM_SEL); |
| 2129 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2131 | return 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | } |
| 2133 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | /*--------------------------------------------------------------------- |
| 2135 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2136 | * Function: SccbMgrTableInit |
| 2137 | * |
| 2138 | * Description: Initialize all Sccb manager data structures. |
| 2139 | * |
| 2140 | *---------------------------------------------------------------------*/ |
| 2141 | |
Sudip Mukherjee | cd9d715 | 2015-09-16 19:36:20 +0530 | [diff] [blame] | 2142 | static void FPT_SccbMgrTableInitAll(void) |
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 | unsigned char thisCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2145 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2146 | for (thisCard = 0; thisCard < MAX_CARDS; thisCard++) { |
| 2147 | FPT_SccbMgrTableInitCard(&FPT_BL_Card[thisCard], thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2148 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2149 | FPT_BL_Card[thisCard].ioPort = 0x00; |
| 2150 | FPT_BL_Card[thisCard].cardInfo = NULL; |
| 2151 | FPT_BL_Card[thisCard].cardIndex = 0xFF; |
| 2152 | FPT_BL_Card[thisCard].ourId = 0x00; |
| 2153 | FPT_BL_Card[thisCard].pNvRamInfo = NULL; |
| 2154 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2155 | } |
| 2156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | /*--------------------------------------------------------------------- |
| 2158 | * |
| 2159 | * Function: SccbMgrTableInit |
| 2160 | * |
| 2161 | * Description: Initialize all Sccb manager data structures. |
| 2162 | * |
| 2163 | *---------------------------------------------------------------------*/ |
| 2164 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2165 | static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard, |
| 2166 | unsigned char p_card) |
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 | unsigned char scsiID, qtag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2169 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2170 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2171 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | } |
| 2173 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2174 | for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++) { |
| 2175 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus = 0; |
| 2176 | FPT_sccbMgrTbl[p_card][scsiID].TarEEValue = 0; |
| 2177 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 2178 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2180 | pCurrCard->scanIndex = 0x00; |
| 2181 | pCurrCard->currentSCCB = NULL; |
| 2182 | pCurrCard->globalFlags = 0x00; |
| 2183 | pCurrCard->cmdCounter = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | pCurrCard->tagQ_Lst = 0x01; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2185 | pCurrCard->discQCount = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2186 | |
| 2187 | } |
| 2188 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | /*--------------------------------------------------------------------- |
| 2190 | * |
| 2191 | * Function: SccbMgrTableInit |
| 2192 | * |
| 2193 | * Description: Initialize all Sccb manager data structures. |
| 2194 | * |
| 2195 | *---------------------------------------------------------------------*/ |
| 2196 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2197 | static void FPT_SccbMgrTableInitTarget(unsigned char p_card, |
| 2198 | unsigned char target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2199 | { |
| 2200 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2201 | unsigned char lun, qtag; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2202 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2203 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2204 | currTar_Info = &FPT_sccbMgrTbl[p_card][target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2205 | |
| 2206 | currTar_Info->TarSelQ_Cnt = 0; |
| 2207 | currTar_Info->TarSyncCtrl = 0; |
| 2208 | |
| 2209 | currTar_Info->TarSelQ_Head = NULL; |
| 2210 | currTar_Info->TarSelQ_Tail = NULL; |
| 2211 | currTar_Info->TarTagQ_Cnt = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2212 | currTar_Info->TarLUN_CA = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2214 | for (lun = 0; lun < MAX_LUN; lun++) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2215 | currTar_Info->TarLUNBusy[lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | currTar_Info->LunDiscQ_Idx[lun] = 0; |
| 2217 | } |
| 2218 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2219 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
| 2220 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] != NULL) { |
| 2221 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == |
| 2222 | target) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2223 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 2224 | FPT_BL_Card[p_card].discQCount--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | } |
| 2226 | } |
| 2227 | } |
| 2228 | } |
| 2229 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2230 | /*--------------------------------------------------------------------- |
| 2231 | * |
| 2232 | * Function: sfetm |
| 2233 | * |
| 2234 | * Description: Read in a message byte from the SCSI bus, and check |
| 2235 | * for a parity error. |
| 2236 | * |
| 2237 | *---------------------------------------------------------------------*/ |
| 2238 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2239 | static unsigned char FPT_sfm(u32 port, struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2241 | unsigned char message; |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 2242 | unsigned short TimeOutLoop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2243 | |
| 2244 | TimeOutLoop = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2245 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2246 | (TimeOutLoop++ < 20000)) { |
| 2247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2249 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2250 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2251 | message = RD_HARPOON(port + hp_scsidata_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2252 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2253 | WR_HARPOON(port + hp_scsisig, SCSI_ACK + S_MSGI_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | |
| 2255 | if (TimeOutLoop > 20000) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2256 | message = 0x00; /* force message byte = 0 if Time Out on Req */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2257 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2258 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 2259 | (RD_HARPOON(port + hp_addstat) & SCSI_PAR_ERR)) { |
| 2260 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
| 2261 | WR_HARPOON(port + hp_xferstat, 0); |
| 2262 | WR_HARPOON(port + hp_fiforead, 0); |
| 2263 | WR_HARPOON(port + hp_fifowrite, 0); |
| 2264 | if (pCurrSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | pCurrSCCB->Sccb_scsimsg = SMPARITY; |
| 2266 | } |
| 2267 | message = 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2268 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2269 | ACCEPT_MSG_ATN(port); |
| 2270 | TimeOutLoop = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2271 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2272 | (TimeOutLoop++ < 20000)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2274 | if (TimeOutLoop > 20000) { |
| 2275 | WRW_HARPOON((port + hp_intstat), PARITY); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2276 | return message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2277 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2278 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) != |
| 2279 | S_MSGI_PH) { |
| 2280 | WRW_HARPOON((port + hp_intstat), PARITY); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2281 | return message; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2282 | } |
| 2283 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2284 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2285 | RD_HARPOON(port + hp_scsidata_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2286 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2287 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2289 | } while (1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | |
| 2291 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2292 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
| 2293 | WR_HARPOON(port + hp_xferstat, 0); |
| 2294 | WR_HARPOON(port + hp_fiforead, 0); |
| 2295 | WR_HARPOON(port + hp_fifowrite, 0); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2296 | return message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2297 | } |
| 2298 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2299 | /*--------------------------------------------------------------------- |
| 2300 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2301 | * Function: FPT_ssel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2302 | * |
| 2303 | * Description: Load up automation and select target device. |
| 2304 | * |
| 2305 | *---------------------------------------------------------------------*/ |
| 2306 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2307 | static void FPT_ssel(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2308 | { |
| 2309 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2310 | unsigned char auto_loaded, i, target, *theCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2312 | u32 cdb_reg; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2313 | struct sccb_card *CurrCard; |
| 2314 | struct sccb *currSCCB; |
| 2315 | struct sccb_mgr_tar_info *currTar_Info; |
| 2316 | unsigned char lastTag, lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2317 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2318 | CurrCard = &FPT_BL_Card[p_card]; |
| 2319 | currSCCB = CurrCard->currentSCCB; |
| 2320 | target = currSCCB->TargID; |
| 2321 | currTar_Info = &FPT_sccbMgrTbl[p_card][target]; |
| 2322 | lastTag = CurrCard->tagQ_Lst; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2324 | ARAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2325 | |
| 2326 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT) |
| 2327 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
| 2328 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2329 | if (((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2330 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2332 | lun = currSCCB->Lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2333 | else |
| 2334 | lun = 0; |
| 2335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2336 | if (CurrCard->globalFlags & F_TAG_STARTED) { |
| 2337 | if (!(currSCCB->ControlByte & F_USE_CMD_Q)) { |
| 2338 | if ((currTar_Info->TarLUN_CA == 0) |
| 2339 | && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) |
| 2340 | == TAG_Q_TRYING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2342 | if (currTar_Info->TarTagQ_Cnt != 0) { |
| 2343 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2344 | FPT_queueSelectFail(CurrCard, p_card); |
| 2345 | SGRAM_ACCESS(port); |
| 2346 | return; |
| 2347 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2348 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2349 | else { |
| 2350 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2351 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2353 | } |
| 2354 | /*End non-tagged */ |
| 2355 | else { |
| 2356 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2357 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2358 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2359 | } |
| 2360 | /*!Use cmd Q Tagged */ |
| 2361 | else { |
| 2362 | if (currTar_Info->TarLUN_CA == 1) { |
| 2363 | FPT_queueSelectFail(CurrCard, p_card); |
| 2364 | SGRAM_ACCESS(port); |
| 2365 | return; |
| 2366 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2367 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2368 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2369 | |
| 2370 | } /*else use cmd Q tagged */ |
| 2371 | |
| 2372 | } |
| 2373 | /*if glob tagged started */ |
| 2374 | else { |
| 2375 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2376 | } |
| 2377 | |
| 2378 | if ((((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2379 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 2380 | || (!(currSCCB->ControlByte & F_USE_CMD_Q)))) { |
| 2381 | if (CurrCard->discQCount >= QUEUE_DEPTH) { |
| 2382 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2383 | FPT_queueSelectFail(CurrCard, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2384 | SGRAM_ACCESS(port); |
| 2385 | return; |
| 2386 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2387 | for (i = 1; i < QUEUE_DEPTH; i++) { |
| 2388 | if (++lastTag >= QUEUE_DEPTH) |
| 2389 | lastTag = 1; |
| 2390 | if (CurrCard->discQ_Tbl[lastTag] == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2391 | CurrCard->tagQ_Lst = lastTag; |
| 2392 | currTar_Info->LunDiscQ_Idx[lun] = lastTag; |
| 2393 | CurrCard->discQ_Tbl[lastTag] = currSCCB; |
| 2394 | CurrCard->discQCount++; |
| 2395 | break; |
| 2396 | } |
| 2397 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2398 | if (i == QUEUE_DEPTH) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2399 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2400 | FPT_queueSelectFail(CurrCard, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | SGRAM_ACCESS(port); |
| 2402 | return; |
| 2403 | } |
| 2404 | } |
| 2405 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2406 | auto_loaded = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2407 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2408 | WR_HARPOON(port + hp_select_id, target); |
| 2409 | 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] | 2410 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2411 | if (currSCCB->OperationCode == RESET_COMMAND) { |
| 2412 | WRW_HARPOON((port + ID_MSG_STRT), (MPM_OP + AMSG_OUT + |
| 2413 | (currSCCB-> |
| 2414 | Sccb_idmsg & ~DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2415 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2416 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + NP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2417 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2418 | currSCCB->Sccb_scsimsg = SMDEV_RESET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2420 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
| 2421 | auto_loaded = 1; |
| 2422 | currSCCB->Sccb_scsistat = SELECT_BDR_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2423 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2424 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 2425 | currTar_Info->TarSyncCtrl = 0; |
| 2426 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2427 | } |
| 2428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2429 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 2430 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2431 | } |
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 | FPT_sssyncv(port, target, NARROW_SCSI, currTar_Info); |
| 2434 | FPT_SccbMgrTableInitTarget(p_card, target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2435 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2436 | } |
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 | else if (currSCCB->Sccb_scsistat == ABORT_ST) { |
| 2439 | WRW_HARPOON((port + ID_MSG_STRT), (MPM_OP + AMSG_OUT + |
| 2440 | (currSCCB-> |
| 2441 | Sccb_idmsg & ~DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2442 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2443 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2444 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2445 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + |
| 2446 | (((unsigned |
| 2447 | char)(currSCCB-> |
| 2448 | ControlByte & |
| 2449 | TAG_TYPE_MASK) |
| 2450 | >> 6) | (unsigned char) |
| 2451 | 0x20))); |
| 2452 | WRW_HARPOON((port + SYNC_MSGS + 2), |
| 2453 | (MPM_OP + AMSG_OUT + currSCCB->Sccb_tag)); |
| 2454 | WRW_HARPOON((port + SYNC_MSGS + 4), (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2455 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2456 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
| 2457 | auto_loaded = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2458 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2459 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2460 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2461 | else if (!(currTar_Info->TarStatus & WIDE_NEGOCIATED)) { |
| 2462 | auto_loaded = FPT_siwidn(port, p_card); |
| 2463 | currSCCB->Sccb_scsistat = SELECT_WN_ST; |
| 2464 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2466 | else if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) |
| 2467 | == SYNC_SUPPORTED)) { |
| 2468 | auto_loaded = FPT_sisyncn(port, p_card, 0); |
| 2469 | currSCCB->Sccb_scsistat = SELECT_SN_ST; |
| 2470 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2471 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2472 | if (!auto_loaded) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2474 | if (currSCCB->ControlByte & F_USE_CMD_Q) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2475 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2476 | CurrCard->globalFlags |= F_TAG_STARTED; |
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 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) |
| 2479 | == TAG_Q_REJECT) { |
| 2480 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2481 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2482 | /* Fix up the start instruction with a jump to |
| 2483 | Non-Tag-CMD handling */ |
| 2484 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2485 | BRH_OP + ALWAYS + NTCMD); |
| 2486 | |
| 2487 | WRW_HARPOON((port + NON_TAG_ID_MSG), |
| 2488 | (MPM_OP + AMSG_OUT + |
| 2489 | currSCCB->Sccb_idmsg)); |
| 2490 | |
| 2491 | WR_HARPOON(port + hp_autostart_3, |
| 2492 | (SELECT + SELCHK_STRT)); |
| 2493 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2494 | /* Setup our STATE so we know what happened when |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2495 | the wheels fall off. */ |
| 2496 | currSCCB->Sccb_scsistat = SELECT_ST; |
| 2497 | |
| 2498 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2499 | } |
| 2500 | |
| 2501 | else { |
| 2502 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2503 | (MPM_OP + AMSG_OUT + |
| 2504 | currSCCB->Sccb_idmsg)); |
| 2505 | |
| 2506 | WRW_HARPOON((port + ID_MSG_STRT + 2), |
| 2507 | (MPM_OP + AMSG_OUT + |
| 2508 | (((unsigned char)(currSCCB-> |
| 2509 | ControlByte & |
| 2510 | TAG_TYPE_MASK) |
| 2511 | >> 6) | (unsigned char)0x20))); |
| 2512 | |
| 2513 | for (i = 1; i < QUEUE_DEPTH; i++) { |
| 2514 | if (++lastTag >= QUEUE_DEPTH) |
| 2515 | lastTag = 1; |
| 2516 | if (CurrCard->discQ_Tbl[lastTag] == |
| 2517 | NULL) { |
| 2518 | WRW_HARPOON((port + |
| 2519 | ID_MSG_STRT + 6), |
| 2520 | (MPM_OP + AMSG_OUT + |
| 2521 | lastTag)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2522 | CurrCard->tagQ_Lst = lastTag; |
| 2523 | currSCCB->Sccb_tag = lastTag; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2524 | CurrCard->discQ_Tbl[lastTag] = |
| 2525 | currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2526 | CurrCard->discQCount++; |
| 2527 | break; |
| 2528 | } |
| 2529 | } |
| 2530 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2531 | if (i == QUEUE_DEPTH) { |
| 2532 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2533 | FPT_queueSelectFail(CurrCard, p_card); |
| 2534 | SGRAM_ACCESS(port); |
| 2535 | return; |
| 2536 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2537 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2538 | currSCCB->Sccb_scsistat = SELECT_Q_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2539 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2540 | WR_HARPOON(port + hp_autostart_3, |
| 2541 | (SELECT + SELCHK_STRT)); |
| 2542 | } |
| 2543 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2545 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2546 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2547 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2548 | BRH_OP + ALWAYS + NTCMD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2549 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2550 | WRW_HARPOON((port + NON_TAG_ID_MSG), |
| 2551 | (MPM_OP + AMSG_OUT + currSCCB->Sccb_idmsg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2552 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2553 | currSCCB->Sccb_scsistat = SELECT_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2554 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2555 | WR_HARPOON(port + hp_autostart_3, |
| 2556 | (SELECT + SELCHK_STRT)); |
| 2557 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2558 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2559 | theCCB = (unsigned char *)&currSCCB->Cdb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2560 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2561 | cdb_reg = port + CMD_STRT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2562 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2563 | for (i = 0; i < currSCCB->CdbLength; i++) { |
| 2564 | WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + *theCCB)); |
| 2565 | cdb_reg += 2; |
| 2566 | theCCB++; |
| 2567 | } |
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 | if (currSCCB->CdbLength != TWELVE_BYTE_CMD) |
| 2570 | WRW_HARPOON(cdb_reg, (BRH_OP + ALWAYS + NP)); |
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 | } |
| 2573 | /* auto_loaded */ |
| 2574 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
| 2575 | WR_HARPOON(port + hp_xferstat, 0x00); |
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 | WRW_HARPOON((port + hp_intstat), (PROG_HLT | TIMEOUT | SEL | BUS_FREE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2578 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2579 | WR_HARPOON(port + hp_portctrl_0, (SCSI_PORT)); |
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 | if (!(currSCCB->Sccb_MGRFlags & F_DEV_SELECTED)) { |
| 2582 | WR_HARPOON(port + hp_scsictrl_0, |
| 2583 | (SEL_TAR | ENA_ATN | ENA_RESEL | ENA_SCAM_SEL)); |
| 2584 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2585 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2586 | /* auto_loaded = (RD_HARPOON(port+hp_autostart_3) & (unsigned char)0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2587 | auto_loaded |= AUTO_IMMED; */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2588 | auto_loaded = AUTO_IMMED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2589 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2590 | DISABLE_AUTO(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2591 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2592 | WR_HARPOON(port + hp_autostart_3, auto_loaded); |
| 2593 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2594 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2595 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2596 | } |
| 2597 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2598 | /*--------------------------------------------------------------------- |
| 2599 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2600 | * Function: FPT_sres |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2601 | * |
| 2602 | * Description: Hookup the correct CCB and handle the incoming messages. |
| 2603 | * |
| 2604 | *---------------------------------------------------------------------*/ |
| 2605 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2606 | static void FPT_sres(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2607 | struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2608 | { |
| 2609 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2610 | unsigned char our_target, message, lun = 0, tag, msgRetryCount; |
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 | struct sccb_mgr_tar_info *currTar_Info; |
| 2613 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2614 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2615 | if (pCurrCard->currentSCCB != NULL) { |
| 2616 | currTar_Info = |
| 2617 | &FPT_sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2618 | DISABLE_AUTO(port); |
| 2619 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2620 | WR_HARPOON((port + hp_scsictrl_0), (ENA_RESEL | ENA_SCAM_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2621 | |
| 2622 | currSCCB = pCurrCard->currentSCCB; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2623 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2624 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2625 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
| 2626 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2627 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2628 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 2629 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
| 2630 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2631 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 2632 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 2633 | TAG_Q_TRYING))) { |
| 2634 | currTar_Info->TarLUNBusy[currSCCB->Lun] = 0; |
| 2635 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2636 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2637 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 2638 | LunDiscQ_Idx[currSCCB-> |
| 2639 | Lun]] |
| 2640 | = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2641 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2642 | } else { |
| 2643 | currTar_Info->TarLUNBusy[0] = 0; |
| 2644 | if (currSCCB->Sccb_tag) { |
| 2645 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2646 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2647 | pCurrCard->discQ_Tbl[currSCCB-> |
| 2648 | Sccb_tag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2649 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2650 | } else { |
| 2651 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2652 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2653 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 2654 | LunDiscQ_Idx[0]] = |
| 2655 | NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2656 | } |
| 2657 | } |
| 2658 | } |
| 2659 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2660 | FPT_queueSelectFail(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2661 | } |
| 2662 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2663 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2664 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2665 | our_target = (unsigned char)(RD_HARPOON(port + hp_select_id) >> 4); |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2666 | currTar_Info = &FPT_sccbMgrTbl[p_card][our_target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2667 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2668 | msgRetryCount = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2669 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2671 | currTar_Info = &FPT_sccbMgrTbl[p_card][our_target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2672 | tag = 0; |
| 2673 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2674 | while (!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) { |
| 2675 | if (!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2676 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2677 | WRW_HARPOON((port + hp_intstat), PHASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2678 | return; |
| 2679 | } |
| 2680 | } |
| 2681 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2682 | WRW_HARPOON((port + hp_intstat), PHASE); |
| 2683 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) == S_MSGI_PH) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2684 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2685 | message = FPT_sfm(port, pCurrCard->currentSCCB); |
| 2686 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2687 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2688 | if (message <= (0x80 | LUN_MASK)) { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2689 | lun = message & (unsigned char)LUN_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2690 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2691 | if ((currTar_Info-> |
| 2692 | TarStatus & TAR_TAG_Q_MASK) == |
| 2693 | TAG_Q_TRYING) { |
| 2694 | if (currTar_Info->TarTagQ_Cnt != |
| 2695 | 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2696 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2697 | if (! |
| 2698 | (currTar_Info-> |
| 2699 | TarLUN_CA)) { |
| 2700 | ACCEPT_MSG(port); /*Release the ACK for ID msg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2701 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2702 | message = |
| 2703 | FPT_sfm |
| 2704 | (port, |
| 2705 | pCurrCard-> |
| 2706 | currentSCCB); |
| 2707 | if (message) { |
| 2708 | ACCEPT_MSG |
| 2709 | (port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2710 | } |
| 2711 | |
| 2712 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2713 | message |
| 2714 | = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2715 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2716 | if (message != |
| 2717 | 0) { |
| 2718 | tag = |
| 2719 | FPT_sfm |
| 2720 | (port, |
| 2721 | pCurrCard-> |
| 2722 | currentSCCB); |
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 | if (! |
| 2725 | (tag)) |
| 2726 | message |
| 2727 | = |
| 2728 | 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2729 | } |
| 2730 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2731 | } |
| 2732 | /*C.A. exists! */ |
| 2733 | } |
| 2734 | /*End Q cnt != 0 */ |
| 2735 | } |
| 2736 | /*End Tag cmds supported! */ |
| 2737 | } |
| 2738 | /*End valid ID message. */ |
| 2739 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2740 | |
| 2741 | ACCEPT_MSG_ATN(port); |
| 2742 | } |
| 2743 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2744 | } |
| 2745 | /* End good id message. */ |
| 2746 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2747 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2748 | message = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2749 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2750 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2751 | ACCEPT_MSG_ATN(port); |
| 2752 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2753 | while (! |
| 2754 | (RDW_HARPOON((port + hp_intstat)) & |
| 2755 | (PHASE | RESET)) |
| 2756 | && !(RD_HARPOON(port + hp_scsisig) & SCSI_REQ) |
| 2757 | && (RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2758 | |
| 2759 | return; |
| 2760 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2761 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2762 | if (message == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2763 | msgRetryCount++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2764 | if (msgRetryCount == 1) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2765 | FPT_SendMsg(port, SMPARITY); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2766 | } else { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2767 | FPT_SendMsg(port, SMDEV_RESET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2768 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2769 | FPT_sssyncv(port, our_target, NARROW_SCSI, |
| 2770 | currTar_Info); |
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 | if (FPT_sccbMgrTbl[p_card][our_target]. |
| 2773 | TarEEValue & EE_SYNC_MASK) { |
| 2774 | |
| 2775 | FPT_sccbMgrTbl[p_card][our_target]. |
| 2776 | TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2777 | |
| 2778 | } |
| 2779 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2780 | if (FPT_sccbMgrTbl[p_card][our_target]. |
| 2781 | TarEEValue & EE_WIDE_SCSI) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2782 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2783 | FPT_sccbMgrTbl[p_card][our_target]. |
| 2784 | TarStatus &= ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2785 | } |
| 2786 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2787 | FPT_queueFlushTargSccb(p_card, our_target, |
| 2788 | SCCB_COMPLETE); |
| 2789 | FPT_SccbMgrTableInitTarget(p_card, our_target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2790 | return; |
| 2791 | } |
| 2792 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2793 | } while (message == 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2794 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2795 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 2796 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2797 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2798 | pCurrCard->currentSCCB = |
| 2799 | pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[lun]]; |
| 2800 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2801 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2802 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2803 | ACCEPT_MSG_ATN(port); |
| 2804 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2805 | } else { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2806 | currTar_Info->TarLUNBusy[0] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2807 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2808 | if (tag) { |
| 2809 | if (pCurrCard->discQ_Tbl[tag] != NULL) { |
| 2810 | pCurrCard->currentSCCB = |
| 2811 | pCurrCard->discQ_Tbl[tag]; |
| 2812 | currTar_Info->TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2813 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2814 | } else { |
| 2815 | ACCEPT_MSG_ATN(port); |
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 | } else { |
| 2818 | pCurrCard->currentSCCB = |
| 2819 | pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]]; |
| 2820 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2821 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2822 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2823 | ACCEPT_MSG_ATN(port); |
| 2824 | } |
| 2825 | } |
| 2826 | } |
| 2827 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2828 | if (pCurrCard->currentSCCB != NULL) { |
| 2829 | if (pCurrCard->currentSCCB->Sccb_scsistat == ABORT_ST) { |
| 2830 | /* During Abort Tag command, the target could have got re-selected |
| 2831 | and completed the command. Check the select Q and remove the CCB |
| 2832 | if it is in the Select Q */ |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2833 | FPT_queueFindSccb(pCurrCard->currentSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2834 | } |
| 2835 | } |
| 2836 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2837 | while (!(RDW_HARPOON((port + hp_intstat)) & (PHASE | RESET)) && |
| 2838 | !(RD_HARPOON(port + hp_scsisig) & SCSI_REQ) && |
| 2839 | (RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2840 | } |
| 2841 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2842 | static void FPT_SendMsg(u32 port, unsigned char message) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2843 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2844 | while (!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) { |
| 2845 | if (!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2846 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2847 | WRW_HARPOON((port + hp_intstat), PHASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2848 | return; |
| 2849 | } |
| 2850 | } |
| 2851 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2852 | WRW_HARPOON((port + hp_intstat), PHASE); |
| 2853 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) == S_MSGO_PH) { |
| 2854 | WRW_HARPOON((port + hp_intstat), |
| 2855 | (BUS_FREE | PHASE | XFER_CNT_0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2856 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2857 | WR_HARPOON(port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2858 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2859 | WR_HARPOON(port + hp_scsidata_0, message); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2860 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2861 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2862 | |
| 2863 | ACCEPT_MSG(port); |
| 2864 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2865 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2866 | |
| 2867 | if ((message == SMABORT) || (message == SMDEV_RESET) || |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2868 | (message == SMABORT_TAG)) { |
| 2869 | while (! |
| 2870 | (RDW_HARPOON((port + hp_intstat)) & |
| 2871 | (BUS_FREE | PHASE))) { |
| 2872 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2873 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2874 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 2875 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2876 | } |
| 2877 | } |
| 2878 | } |
| 2879 | } |
| 2880 | |
| 2881 | /*--------------------------------------------------------------------- |
| 2882 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2883 | * Function: FPT_sdecm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2884 | * |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2885 | * Description: Determine the proper response to the message from the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2886 | * target device. |
| 2887 | * |
| 2888 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2889 | static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2890 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2891 | struct sccb *currSCCB; |
| 2892 | struct sccb_card *CurrCard; |
| 2893 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2894 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2895 | CurrCard = &FPT_BL_Card[p_card]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2896 | currSCCB = CurrCard->currentSCCB; |
| 2897 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2898 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2899 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2900 | if (message == SMREST_DATA_PTR) { |
| 2901 | if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2902 | currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC; |
| 2903 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2904 | FPT_hostDataXferRestart(currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2905 | } |
| 2906 | |
| 2907 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2908 | WR_HARPOON(port + hp_autostart_1, |
| 2909 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2910 | } |
| 2911 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2912 | else if (message == SMCMD_COMP) { |
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 | if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { |
| 2915 | currTar_Info->TarStatus &= |
| 2916 | ~(unsigned char)TAR_TAG_Q_MASK; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2917 | currTar_Info->TarStatus |= (unsigned char)TAG_Q_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2918 | } |
| 2919 | |
| 2920 | ACCEPT_MSG(port); |
| 2921 | |
| 2922 | } |
| 2923 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2924 | else if ((message == SMNO_OP) || (message >= SMIDENT) |
| 2925 | || (message == SMINIT_RECOVERY) || (message == SMREL_RECOVERY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2926 | |
| 2927 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2928 | WR_HARPOON(port + hp_autostart_1, |
| 2929 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2930 | } |
| 2931 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2932 | else if (message == SMREJECT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2933 | |
| 2934 | if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) || |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2935 | (currSCCB->Sccb_scsistat == SELECT_WN_ST) || |
| 2936 | ((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING) |
| 2937 | || ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == |
| 2938 | TAG_Q_TRYING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2939 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2940 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2941 | |
| 2942 | ACCEPT_MSG(port); |
| 2943 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2944 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2945 | (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2946 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2947 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2948 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2949 | if (currSCCB->Lun == 0x00) { |
Nathan Chancellor | adb1102 | 2018-09-20 14:10:32 -0700 | [diff] [blame] | 2950 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2951 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2952 | currTar_Info->TarStatus |= |
| 2953 | (unsigned char)SYNC_SUPPORTED; |
| 2954 | |
| 2955 | currTar_Info->TarEEValue &= |
| 2956 | ~EE_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2957 | } |
| 2958 | |
Nathan Chancellor | adb1102 | 2018-09-20 14:10:32 -0700 | [diff] [blame] | 2959 | else if (currSCCB->Sccb_scsistat == |
| 2960 | SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2961 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2962 | currTar_Info->TarStatus = |
| 2963 | (currTar_Info-> |
| 2964 | TarStatus & ~WIDE_ENABLED) | |
| 2965 | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2966 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2967 | currTar_Info->TarEEValue &= |
| 2968 | ~EE_WIDE_SCSI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2969 | |
| 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 | else if ((currTar_Info-> |
| 2973 | TarStatus & TAR_TAG_Q_MASK) == |
| 2974 | TAG_Q_TRYING) { |
| 2975 | currTar_Info->TarStatus = |
| 2976 | (currTar_Info-> |
| 2977 | TarStatus & ~(unsigned char) |
| 2978 | TAR_TAG_Q_MASK) | TAG_Q_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2979 | |
| 2980 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
| 2981 | CurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2982 | CurrCard->discQ_Tbl[currSCCB-> |
| 2983 | Sccb_tag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2984 | currSCCB->Sccb_tag = 0x00; |
| 2985 | |
| 2986 | } |
| 2987 | } |
| 2988 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2989 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2990 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2991 | if (currSCCB->Lun == 0x00) { |
| 2992 | WRW_HARPOON((port + hp_intstat), |
| 2993 | BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2994 | CurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 2995 | } |
| 2996 | } |
| 2997 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2998 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2999 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3000 | if ((CurrCard->globalFlags & F_CONLUN_IO) && |
| 3001 | ((currTar_Info-> |
| 3002 | TarStatus & TAR_TAG_Q_MASK) != |
| 3003 | TAG_Q_TRYING)) |
| 3004 | currTar_Info->TarLUNBusy[currSCCB-> |
| 3005 | Lun] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3006 | else |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3007 | currTar_Info->TarLUNBusy[0] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3008 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3009 | currSCCB->ControlByte &= |
| 3010 | ~(unsigned char)F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3011 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3012 | WR_HARPOON(port + hp_autostart_1, |
| 3013 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3014 | |
| 3015 | } |
| 3016 | } |
| 3017 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3018 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3019 | ACCEPT_MSG(port); |
| 3020 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3021 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 3022 | (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3023 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3024 | } |
| 3025 | |
| 3026 | if (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE)) { |
| 3027 | WR_HARPOON(port + hp_autostart_1, |
| 3028 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3029 | } |
| 3030 | } |
| 3031 | } |
| 3032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3033 | else if (message == SMEXT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3034 | |
| 3035 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3036 | FPT_shandem(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3037 | } |
| 3038 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3039 | else if (message == SMIGNORWR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3040 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3041 | ACCEPT_MSG(port); /* ACK the RESIDUE MSG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3043 | message = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3044 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3045 | if (currSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3046 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3047 | WR_HARPOON(port + hp_autostart_1, |
| 3048 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3049 | } |
| 3050 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3051 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3052 | |
| 3053 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 3054 | currSCCB->Sccb_scsimsg = SMREJECT; |
| 3055 | |
| 3056 | ACCEPT_MSG_ATN(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3057 | WR_HARPOON(port + hp_autostart_1, |
| 3058 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3059 | } |
| 3060 | } |
| 3061 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3062 | /*--------------------------------------------------------------------- |
| 3063 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3064 | * Function: FPT_shandem |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3065 | * |
| 3066 | * Description: Decide what to do with the extended message. |
| 3067 | * |
| 3068 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3069 | static void FPT_shandem(u32 port, unsigned char p_card, struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3070 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3071 | unsigned char length, message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3072 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3073 | length = FPT_sfm(port, pCurrSCCB); |
| 3074 | if (length) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3075 | |
| 3076 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3077 | message = FPT_sfm(port, pCurrSCCB); |
| 3078 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3079 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3080 | if (message == SMSYNC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3081 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3082 | if (length == 0x03) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3083 | |
| 3084 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3085 | FPT_stsyncn(port, p_card); |
| 3086 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3087 | |
| 3088 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3089 | ACCEPT_MSG_ATN(port); |
| 3090 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3091 | } else if (message == SMWDTR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3092 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3093 | if (length == 0x02) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3094 | |
| 3095 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3096 | FPT_stwidn(port, p_card); |
| 3097 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3098 | |
| 3099 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3100 | ACCEPT_MSG_ATN(port); |
| 3101 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3102 | WR_HARPOON(port + hp_autostart_1, |
| 3103 | (AUTO_IMMED + |
| 3104 | DISCONNECT_START)); |
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 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3107 | |
| 3108 | pCurrSCCB->Sccb_scsimsg = SMREJECT; |
| 3109 | ACCEPT_MSG_ATN(port); |
| 3110 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3111 | WR_HARPOON(port + hp_autostart_1, |
| 3112 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3113 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3114 | } else { |
| 3115 | if (pCurrSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3116 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3117 | WR_HARPOON(port + hp_autostart_1, |
| 3118 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3119 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3120 | } else { |
| 3121 | if (pCurrSCCB->Sccb_scsimsg == SMPARITY) |
| 3122 | WR_HARPOON(port + hp_autostart_1, |
| 3123 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3124 | } |
| 3125 | } |
| 3126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3127 | /*--------------------------------------------------------------------- |
| 3128 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3129 | * Function: FPT_sisyncn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3130 | * |
| 3131 | * Description: Read in a message byte from the SCSI bus, and check |
| 3132 | * for a parity error. |
| 3133 | * |
| 3134 | *---------------------------------------------------------------------*/ |
| 3135 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3136 | static unsigned char FPT_sisyncn(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3137 | unsigned char syncFlag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3138 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3139 | struct sccb *currSCCB; |
| 3140 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3141 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3142 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3143 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3144 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3145 | if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3146 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3147 | WRW_HARPOON((port + ID_MSG_STRT), |
| 3148 | (MPM_OP + AMSG_OUT + |
| 3149 | (currSCCB-> |
| 3150 | Sccb_idmsg & ~(unsigned char)DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3151 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3152 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3153 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3154 | WRW_HARPOON((port + SYNC_MSGS + 0), |
| 3155 | (MPM_OP + AMSG_OUT + SMEXT)); |
| 3156 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); |
| 3157 | WRW_HARPOON((port + SYNC_MSGS + 4), |
| 3158 | (MPM_OP + AMSG_OUT + SMSYNC)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3159 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3160 | if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3161 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3162 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3163 | (MPM_OP + AMSG_OUT + 12)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3164 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3165 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == |
| 3166 | EE_SYNC_10MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3167 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3168 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3169 | (MPM_OP + AMSG_OUT + 25)); |
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 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == |
| 3172 | EE_SYNC_5MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3173 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3174 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3175 | (MPM_OP + AMSG_OUT + 50)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3177 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3178 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3179 | (MPM_OP + AMSG_OUT + 00)); |
| 3180 | |
| 3181 | WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); |
| 3182 | WRW_HARPOON((port + SYNC_MSGS + 10), |
| 3183 | (MPM_OP + AMSG_OUT + DEFAULT_OFFSET)); |
| 3184 | WRW_HARPOON((port + SYNC_MSGS + 12), (BRH_OP + ALWAYS + NP)); |
| 3185 | |
| 3186 | if (syncFlag == 0) { |
| 3187 | WR_HARPOON(port + hp_autostart_3, |
| 3188 | (SELECT + SELCHK_STRT)); |
| 3189 | currTar_Info->TarStatus = |
| 3190 | ((currTar_Info-> |
| 3191 | TarStatus & ~(unsigned char)TAR_SYNC_MASK) | |
| 3192 | (unsigned char)SYNC_TRYING); |
| 3193 | } else { |
| 3194 | WR_HARPOON(port + hp_autostart_3, |
| 3195 | (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3196 | } |
| 3197 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3198 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3199 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3200 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3201 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3202 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3203 | currTar_Info->TarStatus |= (unsigned char)SYNC_SUPPORTED; |
| 3204 | currTar_Info->TarEEValue &= ~EE_SYNC_MASK; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3205 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3206 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3207 | } |
| 3208 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3209 | /*--------------------------------------------------------------------- |
| 3210 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3211 | * Function: FPT_stsyncn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3212 | * |
| 3213 | * Description: The has sent us a Sync Nego message so handle it as |
| 3214 | * necessary. |
| 3215 | * |
| 3216 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3217 | static void FPT_stsyncn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3218 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3219 | unsigned char sync_msg, offset, sync_reg, our_sync_msg; |
| 3220 | struct sccb *currSCCB; |
| 3221 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3222 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3223 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3224 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3226 | sync_msg = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3227 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3228 | if ((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3229 | WR_HARPOON(port + hp_autostart_1, |
| 3230 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3231 | return; |
| 3232 | } |
| 3233 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3234 | ACCEPT_MSG(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3235 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3236 | offset = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3237 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3238 | if ((offset == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3239 | WR_HARPOON(port + hp_autostart_1, |
| 3240 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3241 | return; |
| 3242 | } |
| 3243 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3244 | if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3245 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3246 | our_sync_msg = 12; /* Setup our Message to 20mb/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3247 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3248 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_10MB) |
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 | our_sync_msg = 25; /* Setup our Message to 10mb/s */ |
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 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_5MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3253 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3254 | our_sync_msg = 50; /* Setup our Message to 5mb/s */ |
| 3255 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3256 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3257 | our_sync_msg = 0; /* Message = Async */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3258 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3259 | if (sync_msg < our_sync_msg) { |
| 3260 | sync_msg = our_sync_msg; /*if faster, then set to max. */ |
| 3261 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3262 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3263 | if (offset == ASYNC) |
| 3264 | sync_msg = ASYNC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3266 | if (offset > MAX_OFFSET) |
| 3267 | offset = MAX_OFFSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3268 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3269 | sync_reg = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3270 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3271 | if (sync_msg > 12) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3272 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3273 | sync_reg = 0x20; /* Use 10MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3274 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3275 | if (sync_msg > 25) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3276 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3277 | sync_reg = 0x40; /* Use 6.6MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3278 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3279 | if (sync_msg > 38) |
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 | sync_reg = 0x60; /* Use 5MB/s */ |
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 > 50) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3284 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3285 | sync_reg = 0x80; /* Use 4MB/s */ |
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 (sync_msg > 62) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3288 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3289 | sync_reg = 0xA0; /* Use 3.33MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3290 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3291 | if (sync_msg > 75) |
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 = 0xC0; /* Use 2.85MB/s */ |
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 > 87) |
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 = 0xE0; /* Use 2.5MB/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 > 100) { |
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 = 0x00; /* Use ASYNC */ |
| 3302 | offset = 0x00; |
| 3303 | } |
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 | if (currTar_Info->TarStatus & WIDE_ENABLED) |
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 | sync_reg |= offset; |
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 | else |
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 | sync_reg |= (offset | NARROW_SCSI); |
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 | FPT_sssyncv(port, currSCCB->TargID, sync_reg, currTar_Info); |
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 (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
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 | ACCEPT_MSG(port); |
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 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3320 | ~(unsigned char)TAR_SYNC_MASK) | |
| 3321 | (unsigned char)SYNC_SUPPORTED); |
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 | WR_HARPOON(port + hp_autostart_1, |
| 3324 | (AUTO_IMMED + DISCONNECT_START)); |
| 3325 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3326 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3327 | else { |
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 | ACCEPT_MSG_ATN(port); |
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 | FPT_sisyncr(port, sync_msg, 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 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3334 | ~(unsigned char)TAR_SYNC_MASK) | |
| 3335 | (unsigned char)SYNC_SUPPORTED); |
| 3336 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3337 | } |
| 3338 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3339 | /*--------------------------------------------------------------------- |
| 3340 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3341 | * Function: FPT_sisyncr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3342 | * |
| 3343 | * Description: Answer the targets sync message. |
| 3344 | * |
| 3345 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3346 | static void FPT_sisyncr(u32 port, unsigned char sync_pulse, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3347 | unsigned char offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3348 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3349 | ARAM_ACCESS(port); |
| 3350 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); |
| 3351 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); |
| 3352 | WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMSYNC)); |
| 3353 | WRW_HARPOON((port + SYNC_MSGS + 6), (MPM_OP + AMSG_OUT + sync_pulse)); |
| 3354 | WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); |
| 3355 | WRW_HARPOON((port + SYNC_MSGS + 10), (MPM_OP + AMSG_OUT + offset)); |
| 3356 | WRW_HARPOON((port + SYNC_MSGS + 12), (BRH_OP + ALWAYS + NP)); |
| 3357 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3358 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3359 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
| 3360 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3361 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3362 | WR_HARPOON(port + hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3363 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3364 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | AUTO_INT))) { |
| 3365 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3366 | } |
| 3367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3368 | /*--------------------------------------------------------------------- |
| 3369 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3370 | * Function: FPT_siwidn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3371 | * |
| 3372 | * Description: Read in a message byte from the SCSI bus, and check |
| 3373 | * for a parity error. |
| 3374 | * |
| 3375 | *---------------------------------------------------------------------*/ |
| 3376 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3377 | static unsigned char FPT_siwidn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3378 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3379 | struct sccb *currSCCB; |
| 3380 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3381 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3382 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3383 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3384 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3385 | if (!((currTar_Info->TarStatus & TAR_WIDE_MASK) == WIDE_NEGOCIATED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3386 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3387 | WRW_HARPOON((port + ID_MSG_STRT), |
| 3388 | (MPM_OP + AMSG_OUT + |
| 3389 | (currSCCB-> |
| 3390 | Sccb_idmsg & ~(unsigned char)DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3391 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3392 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3393 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3394 | WRW_HARPOON((port + SYNC_MSGS + 0), |
| 3395 | (MPM_OP + AMSG_OUT + SMEXT)); |
| 3396 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); |
| 3397 | WRW_HARPOON((port + SYNC_MSGS + 4), |
| 3398 | (MPM_OP + AMSG_OUT + SMWDTR)); |
| 3399 | WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); |
| 3400 | WRW_HARPOON((port + SYNC_MSGS + 8), |
| 3401 | (MPM_OP + AMSG_OUT + SM16BIT)); |
| 3402 | WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3403 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3404 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
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 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3407 | ~(unsigned char)TAR_WIDE_MASK) | |
| 3408 | (unsigned char)WIDE_ENABLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3409 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3410 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3411 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3412 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3413 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3414 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3415 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3416 | ~(unsigned char)TAR_WIDE_MASK) | |
| 3417 | WIDE_NEGOCIATED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3418 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3419 | currTar_Info->TarEEValue &= ~EE_WIDE_SCSI; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3420 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3421 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3422 | } |
| 3423 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3424 | /*--------------------------------------------------------------------- |
| 3425 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3426 | * Function: FPT_stwidn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3427 | * |
| 3428 | * Description: The has sent us a Wide Nego message so handle it as |
| 3429 | * necessary. |
| 3430 | * |
| 3431 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3432 | static void FPT_stwidn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3433 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3434 | unsigned char width; |
| 3435 | struct sccb *currSCCB; |
| 3436 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3438 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3439 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3440 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3441 | width = FPT_sfm(port, currSCCB); |
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 | if ((width == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { |
| 3444 | WR_HARPOON(port + hp_autostart_1, |
| 3445 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3446 | return; |
| 3447 | } |
| 3448 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3449 | if (!(currTar_Info->TarEEValue & EE_WIDE_SCSI)) |
| 3450 | width = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3451 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3452 | if (width) { |
| 3453 | currTar_Info->TarStatus |= WIDE_ENABLED; |
| 3454 | width = 0; |
| 3455 | } else { |
| 3456 | width = NARROW_SCSI; |
| 3457 | currTar_Info->TarStatus &= ~WIDE_ENABLED; |
| 3458 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3459 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3460 | FPT_sssyncv(port, currSCCB->TargID, width, 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 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3464 | currTar_Info->TarStatus |= WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3466 | if (! |
| 3467 | ((currTar_Info->TarStatus & TAR_SYNC_MASK) == |
| 3468 | SYNC_SUPPORTED)) { |
| 3469 | ACCEPT_MSG_ATN(port); |
| 3470 | ARAM_ACCESS(port); |
| 3471 | FPT_sisyncn(port, p_card, 1); |
| 3472 | currSCCB->Sccb_scsistat = SELECT_SN_ST; |
| 3473 | SGRAM_ACCESS(port); |
| 3474 | } else { |
| 3475 | ACCEPT_MSG(port); |
| 3476 | WR_HARPOON(port + hp_autostart_1, |
| 3477 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3478 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3479 | } |
| 3480 | |
| 3481 | else { |
| 3482 | |
| 3483 | ACCEPT_MSG_ATN(port); |
| 3484 | |
| 3485 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) |
| 3486 | width = SM16BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3487 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3488 | width = SM8BIT; |
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 | FPT_siwidr(port, width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3492 | currTar_Info->TarStatus |= (WIDE_NEGOCIATED | WIDE_ENABLED); |
| 3493 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3494 | } |
| 3495 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3496 | /*--------------------------------------------------------------------- |
| 3497 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3498 | * Function: FPT_siwidr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3499 | * |
| 3500 | * Description: Answer the targets Wide nego message. |
| 3501 | * |
| 3502 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3503 | static void FPT_siwidr(u32 port, unsigned char width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3504 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3505 | ARAM_ACCESS(port); |
| 3506 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); |
| 3507 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); |
| 3508 | WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMWDTR)); |
| 3509 | WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); |
| 3510 | WRW_HARPOON((port + SYNC_MSGS + 8), (MPM_OP + AMSG_OUT + width)); |
| 3511 | WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); |
| 3512 | SGRAM_ACCESS(port); |
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 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
| 3515 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3516 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3517 | WR_HARPOON(port + hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3518 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3519 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | AUTO_INT))) { |
| 3520 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3521 | } |
| 3522 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3523 | /*--------------------------------------------------------------------- |
| 3524 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3525 | * Function: FPT_sssyncv |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3526 | * |
| 3527 | * Description: Write the desired value to the Sync Register for the |
| 3528 | * ID specified. |
| 3529 | * |
| 3530 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3531 | static void FPT_sssyncv(u32 p_port, unsigned char p_id, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3532 | unsigned char p_sync_value, |
| 3533 | struct sccb_mgr_tar_info *currTar_Info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3534 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3535 | unsigned char index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3537 | index = p_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3538 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3539 | switch (index) { |
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 | case 0: |
| 3542 | index = 12; /* hp_synctarg_0 */ |
| 3543 | break; |
| 3544 | case 1: |
| 3545 | index = 13; /* hp_synctarg_1 */ |
| 3546 | break; |
| 3547 | case 2: |
| 3548 | index = 14; /* hp_synctarg_2 */ |
| 3549 | break; |
| 3550 | case 3: |
| 3551 | index = 15; /* hp_synctarg_3 */ |
| 3552 | break; |
| 3553 | case 4: |
| 3554 | index = 8; /* hp_synctarg_4 */ |
| 3555 | break; |
| 3556 | case 5: |
| 3557 | index = 9; /* hp_synctarg_5 */ |
| 3558 | break; |
| 3559 | case 6: |
| 3560 | index = 10; /* hp_synctarg_6 */ |
| 3561 | break; |
| 3562 | case 7: |
| 3563 | index = 11; /* hp_synctarg_7 */ |
| 3564 | break; |
| 3565 | case 8: |
| 3566 | index = 4; /* hp_synctarg_8 */ |
| 3567 | break; |
| 3568 | case 9: |
| 3569 | index = 5; /* hp_synctarg_9 */ |
| 3570 | break; |
| 3571 | case 10: |
| 3572 | index = 6; /* hp_synctarg_10 */ |
| 3573 | break; |
| 3574 | case 11: |
| 3575 | index = 7; /* hp_synctarg_11 */ |
| 3576 | break; |
| 3577 | case 12: |
| 3578 | index = 0; /* hp_synctarg_12 */ |
| 3579 | break; |
| 3580 | case 13: |
| 3581 | index = 1; /* hp_synctarg_13 */ |
| 3582 | break; |
| 3583 | case 14: |
| 3584 | index = 2; /* hp_synctarg_14 */ |
| 3585 | break; |
| 3586 | case 15: |
| 3587 | index = 3; /* hp_synctarg_15 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3588 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3589 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3590 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3591 | WR_HARPOON(p_port + hp_synctarg_base + index, p_sync_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3592 | |
| 3593 | currTar_Info->TarSyncCtrl = p_sync_value; |
| 3594 | } |
| 3595 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3596 | /*--------------------------------------------------------------------- |
| 3597 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3598 | * Function: FPT_sresb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3599 | * |
| 3600 | * Description: Reset the desired card's SCSI bus. |
| 3601 | * |
| 3602 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3603 | static void FPT_sresb(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3604 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3605 | unsigned char scsiID, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3606 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3607 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3608 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3609 | WR_HARPOON(port + hp_page_ctrl, |
| 3610 | (RD_HARPOON(port + hp_page_ctrl) | G_INT_DISABLE)); |
| 3611 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
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 | WR_HARPOON(port + hp_scsictrl_0, SCSI_RST); |
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 | scsiID = RD_HARPOON(port + hp_seltimeout); |
| 3616 | WR_HARPOON(port + hp_seltimeout, TO_5ms); |
| 3617 | WRW_HARPOON((port + hp_intstat), TIMEOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3618 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3619 | WR_HARPOON(port + hp_portctrl_0, (SCSI_PORT | START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3620 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3621 | while (!(RDW_HARPOON((port + hp_intstat)) & TIMEOUT)) { |
| 3622 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3623 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3624 | WR_HARPOON(port + hp_seltimeout, scsiID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3625 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3626 | WR_HARPOON(port + hp_scsictrl_0, ENA_SCAM_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3627 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3628 | FPT_Wait(port, TO_5ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3629 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3630 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3631 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3632 | WR_HARPOON(port + hp_int_mask, (RD_HARPOON(port + hp_int_mask) | 0x00)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3633 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3634 | for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++) { |
| 3635 | currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; |
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 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 3638 | currTar_Info->TarSyncCtrl = 0; |
| 3639 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 3640 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3641 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3642 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 3643 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 3644 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3645 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3646 | FPT_sssyncv(port, scsiID, NARROW_SCSI, currTar_Info); |
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 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 3649 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3650 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3651 | FPT_BL_Card[p_card].scanIndex = 0x00; |
| 3652 | FPT_BL_Card[p_card].currentSCCB = NULL; |
| 3653 | FPT_BL_Card[p_card].globalFlags &= ~(F_TAG_STARTED | F_HOST_XFER_ACT |
| 3654 | | F_NEW_SCCB_CMD); |
| 3655 | FPT_BL_Card[p_card].cmdCounter = 0x00; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3656 | FPT_BL_Card[p_card].discQCount = 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3657 | FPT_BL_Card[p_card].tagQ_Lst = 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3658 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3659 | for (i = 0; i < QUEUE_DEPTH; i++) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3660 | FPT_BL_Card[p_card].discQ_Tbl[i] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3661 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3662 | WR_HARPOON(port + hp_page_ctrl, |
| 3663 | (RD_HARPOON(port + hp_page_ctrl) & ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3664 | |
| 3665 | } |
| 3666 | |
| 3667 | /*--------------------------------------------------------------------- |
| 3668 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3669 | * Function: FPT_ssenss |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3670 | * |
| 3671 | * Description: Setup for the Auto Sense command. |
| 3672 | * |
| 3673 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3674 | static void FPT_ssenss(struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3675 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3676 | unsigned char i; |
| 3677 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3678 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3679 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3680 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3681 | currSCCB->Save_CdbLen = currSCCB->CdbLength; |
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 < 6; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3684 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3685 | currSCCB->Save_Cdb[i] = currSCCB->Cdb[i]; |
| 3686 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3687 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3688 | currSCCB->CdbLength = SIX_BYTE_CMD; |
| 3689 | currSCCB->Cdb[0] = SCSI_REQUEST_SENSE; |
| 3690 | currSCCB->Cdb[1] = currSCCB->Cdb[1] & (unsigned char)0xE0; /*Keep LUN. */ |
| 3691 | currSCCB->Cdb[2] = 0x00; |
| 3692 | currSCCB->Cdb[3] = 0x00; |
| 3693 | currSCCB->Cdb[4] = currSCCB->RequestSenseLength; |
| 3694 | currSCCB->Cdb[5] = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3695 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3696 | currSCCB->Sccb_XferCnt = (u32)currSCCB->RequestSenseLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3697 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3698 | currSCCB->Sccb_ATC = 0x00; |
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 | currSCCB->Sccb_XferState |= F_AUTO_SENSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3701 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3702 | currSCCB->Sccb_XferState &= ~F_SG_XFER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3703 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3704 | currSCCB->Sccb_idmsg = currSCCB->Sccb_idmsg & ~(unsigned char)DISC_PRIV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3705 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3706 | currSCCB->ControlByte = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3707 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3708 | currSCCB->Sccb_MGRFlags &= F_STATUSLOADED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3709 | } |
| 3710 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3711 | /*--------------------------------------------------------------------- |
| 3712 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3713 | * Function: FPT_sxfrp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3714 | * |
| 3715 | * Description: Transfer data into the bit bucket until the device |
| 3716 | * decides to switch phase. |
| 3717 | * |
| 3718 | *---------------------------------------------------------------------*/ |
| 3719 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3720 | static void FPT_sxfrp(u32 p_port, unsigned char p_card) |
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 | unsigned char curr_phz; |
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 | DISABLE_AUTO(p_port); |
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 | if (FPT_BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) { |
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 | FPT_hostDataXferAbort(p_port, p_card, |
| 3729 | FPT_BL_Card[p_card].currentSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3730 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3731 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3732 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3733 | /* If the Automation handled the end of the transfer then do not |
| 3734 | 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] | 3735 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3736 | if (RDW_HARPOON((p_port + hp_intstat)) & |
| 3737 | (BUS_FREE | XFER_CNT_0 | AUTO_INT)) |
| 3738 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3739 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3740 | WR_HARPOON(p_port + hp_xfercnt_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3741 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3742 | 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] | 3743 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3744 | WRW_HARPOON((p_port + hp_intstat), XFER_CNT_0); |
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 | WR_HARPOON(p_port + hp_scsisig, 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 | while (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET)) && |
| 3749 | (curr_phz == |
| 3750 | (RD_HARPOON(p_port + hp_scsisig) & (unsigned char)S_SCSI_PHZ))) |
| 3751 | { |
| 3752 | if (curr_phz & (unsigned char)SCSI_IOBIT) { |
| 3753 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3754 | (SCSI_PORT | HOST_PORT | SCSI_INBIT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3755 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3756 | if (!(RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY)) { |
| 3757 | RD_HARPOON(p_port + hp_fifodata_0); |
| 3758 | } |
| 3759 | } else { |
| 3760 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3761 | (SCSI_PORT | HOST_PORT | HOST_WRT)); |
| 3762 | if (RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY) { |
| 3763 | WR_HARPOON(p_port + hp_fifodata_0, 0xFA); |
| 3764 | } |
| 3765 | } |
| 3766 | } /* End of While loop for padding data I/O phase */ |
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 | while (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET))) { |
| 3769 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_REQ) |
| 3770 | break; |
| 3771 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3772 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3773 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3774 | (SCSI_PORT | HOST_PORT | SCSI_INBIT)); |
| 3775 | while (!(RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY)) { |
| 3776 | RD_HARPOON(p_port + hp_fifodata_0); |
| 3777 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3778 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3779 | if (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET))) { |
| 3780 | WR_HARPOON(p_port + hp_autostart_0, |
| 3781 | (AUTO_IMMED + DISCONNECT_START)); |
| 3782 | while (!(RDW_HARPOON((p_port + hp_intstat)) & AUTO_INT)) { |
| 3783 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3784 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3785 | if (RDW_HARPOON((p_port + hp_intstat)) & |
| 3786 | (ICMD_COMP | ITAR_DISC)) |
| 3787 | while (! |
| 3788 | (RDW_HARPOON((p_port + hp_intstat)) & |
| 3789 | (BUS_FREE | RSEL))) ; |
| 3790 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3791 | } |
| 3792 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3793 | /*--------------------------------------------------------------------- |
| 3794 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3795 | * Function: FPT_schkdd |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3796 | * |
| 3797 | * Description: Make sure data has been flushed from both FIFOs and abort |
| 3798 | * the operations if necessary. |
| 3799 | * |
| 3800 | *---------------------------------------------------------------------*/ |
| 3801 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3802 | static void FPT_schkdd(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3804 | unsigned short TimeOutLoop; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 3805 | unsigned char sPhase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3806 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3807 | struct sccb *currSCCB; |
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 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3810 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3811 | if ((currSCCB->Sccb_scsistat != DATA_OUT_ST) && |
| 3812 | (currSCCB->Sccb_scsistat != DATA_IN_ST)) { |
| 3813 | return; |
| 3814 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3815 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3816 | if (currSCCB->Sccb_XferState & F_ODD_BALL_CNT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3817 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3818 | currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3819 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3820 | currSCCB->Sccb_XferCnt = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3821 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3822 | currSCCB->Sccb_XferState &= ~F_ODD_BALL_CNT; |
| 3823 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
| 3824 | WR_HARPOON(port + hp_xferstat, 0x00); |
| 3825 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3826 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3827 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3828 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3829 | currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt; |
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 | currSCCB->Sccb_XferCnt = 0; |
| 3832 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3833 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3834 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 3835 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3836 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3837 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 3838 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 3839 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3840 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3841 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3843 | while (RD_HARPOON(port + hp_scsisig) & SCSI_ACK) { |
| 3844 | } |
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 | TimeOutLoop = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3847 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3848 | while (RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY) { |
| 3849 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 3850 | return; |
| 3851 | } |
| 3852 | if (RD_HARPOON(port + hp_offsetctr) & (unsigned char)0x1F) { |
| 3853 | break; |
| 3854 | } |
| 3855 | if (RDW_HARPOON((port + hp_intstat)) & RESET) { |
| 3856 | return; |
| 3857 | } |
| 3858 | if ((RD_HARPOON(port + hp_scsisig) & SCSI_REQ) |
| 3859 | || (TimeOutLoop++ > 0x3000)) |
| 3860 | break; |
| 3861 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3862 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3863 | sPhase = RD_HARPOON(port + hp_scsisig) & (SCSI_BSY | S_SCSI_PHZ); |
| 3864 | if ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) || |
| 3865 | (RD_HARPOON(port + hp_offsetctr) & (unsigned char)0x1F) || |
| 3866 | (sPhase == (SCSI_BSY | S_DATAO_PH)) || |
| 3867 | (sPhase == (SCSI_BSY | S_DATAI_PH))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3868 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3869 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3870 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3871 | if (!(currSCCB->Sccb_XferState & F_ALL_XFERRED)) { |
| 3872 | if (currSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
| 3873 | FPT_phaseDataIn(port, p_card); |
| 3874 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3875 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3876 | else { |
| 3877 | FPT_phaseDataOut(port, p_card); |
| 3878 | } |
| 3879 | } else { |
| 3880 | FPT_sxfrp(port, p_card); |
| 3881 | if (!(RDW_HARPOON((port + hp_intstat)) & |
| 3882 | (BUS_FREE | ICMD_COMP | ITAR_DISC | RESET))) { |
| 3883 | WRW_HARPOON((port + hp_intstat), AUTO_INT); |
| 3884 | FPT_phaseDecode(port, p_card); |
| 3885 | } |
| 3886 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3887 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3888 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3889 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3890 | else { |
| 3891 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
| 3892 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3893 | } |
| 3894 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3895 | /*--------------------------------------------------------------------- |
| 3896 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3897 | * Function: FPT_sinits |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3898 | * |
| 3899 | * Description: Setup SCCB manager fields in this SCCB. |
| 3900 | * |
| 3901 | *---------------------------------------------------------------------*/ |
| 3902 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3903 | static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3904 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3905 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3906 | |
Dan Carpenter | 5d7ebb9 | 2009-12-28 20:08:39 +0200 | [diff] [blame] | 3907 | if ((p_sccb->TargID >= MAX_SCSI_TAR) || (p_sccb->Lun >= MAX_LUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3908 | return; |
| 3909 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3910 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
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 | p_sccb->Sccb_XferState = 0x00; |
| 3913 | p_sccb->Sccb_XferCnt = p_sccb->DataLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3914 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3915 | if ((p_sccb->OperationCode == SCATTER_GATHER_COMMAND) || |
| 3916 | (p_sccb->OperationCode == RESIDUAL_SG_COMMAND)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3917 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3918 | p_sccb->Sccb_SGoffset = 0; |
| 3919 | p_sccb->Sccb_XferState = F_SG_XFER; |
| 3920 | p_sccb->Sccb_XferCnt = 0x00; |
| 3921 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3922 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3923 | if (p_sccb->DataLength == 0x00) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3924 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3925 | p_sccb->Sccb_XferState |= F_ALL_XFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3926 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3927 | if (p_sccb->ControlByte & F_USE_CMD_Q) { |
| 3928 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT) |
| 3929 | p_sccb->ControlByte &= ~F_USE_CMD_Q; |
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 | else |
| 3932 | currTar_Info->TarStatus |= TAG_Q_TRYING; |
| 3933 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3934 | |
| 3935 | /* For !single SCSI device in system & device allow Disconnect |
| 3936 | or command is tag_q type then send Cmd with Disconnect Enable |
| 3937 | else send Cmd with Disconnect Disable */ |
| 3938 | |
| 3939 | /* |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3940 | if (((!(FPT_BL_Card[p_card].globalFlags & F_SINGLE_DEVICE)) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3941 | (currTar_Info->TarStatus & TAR_ALLOW_DISC)) || |
| 3942 | (currTar_Info->TarStatus & TAG_Q_TRYING)) { |
| 3943 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3944 | if ((currTar_Info->TarStatus & TAR_ALLOW_DISC) || |
| 3945 | (currTar_Info->TarStatus & TAG_Q_TRYING)) { |
| 3946 | p_sccb->Sccb_idmsg = |
| 3947 | (unsigned char)(SMIDENT | DISC_PRIV) | p_sccb->Lun; |
| 3948 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3949 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3950 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3951 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3952 | p_sccb->Sccb_idmsg = (unsigned char)SMIDENT | p_sccb->Lun; |
| 3953 | } |
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 | p_sccb->HostStatus = 0x00; |
| 3956 | p_sccb->TargetStatus = 0x00; |
| 3957 | p_sccb->Sccb_tag = 0x00; |
| 3958 | p_sccb->Sccb_MGRFlags = 0x00; |
| 3959 | p_sccb->Sccb_sgseg = 0x00; |
| 3960 | p_sccb->Sccb_ATC = 0x00; |
| 3961 | p_sccb->Sccb_savedATC = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3962 | /* |
| 3963 | p_sccb->SccbVirtDataPtr = 0x00; |
| 3964 | p_sccb->Sccb_forwardlink = NULL; |
| 3965 | p_sccb->Sccb_backlink = NULL; |
| 3966 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3967 | p_sccb->Sccb_scsistat = BUS_FREE_ST; |
| 3968 | p_sccb->SccbStatus = SCCB_IN_PROCESS; |
| 3969 | p_sccb->Sccb_scsimsg = SMNO_OP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3970 | |
| 3971 | } |
| 3972 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3973 | /*--------------------------------------------------------------------- |
| 3974 | * |
| 3975 | * Function: Phase Decode |
| 3976 | * |
| 3977 | * Description: Determine the phase and call the appropriate function. |
| 3978 | * |
| 3979 | *---------------------------------------------------------------------*/ |
| 3980 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3981 | static void FPT_phaseDecode(u32 p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3982 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3983 | unsigned char phase_ref; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3984 | void (*phase) (u32, unsigned char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3985 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3986 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3987 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3988 | phase_ref = |
| 3989 | (unsigned char)(RD_HARPOON(p_port + hp_scsisig) & S_SCSI_PHZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3990 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3991 | phase = FPT_s_PhaseTbl[phase_ref]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3992 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3993 | (*phase) (p_port, p_card); /* Call the correct phase func */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3994 | } |
| 3995 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3996 | /*--------------------------------------------------------------------- |
| 3997 | * |
| 3998 | * Function: Data Out Phase |
| 3999 | * |
| 4000 | * Description: Start up both the BusMaster and Xbow. |
| 4001 | * |
| 4002 | *---------------------------------------------------------------------*/ |
| 4003 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4004 | static void FPT_phaseDataOut(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4005 | { |
| 4006 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4007 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4008 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4009 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 4010 | if (currSCCB == NULL) { |
| 4011 | return; /* Exit if No SCCB record */ |
| 4012 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4013 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4014 | currSCCB->Sccb_scsistat = DATA_OUT_ST; |
| 4015 | currSCCB->Sccb_XferState &= ~(F_HOST_XFER_DIR | F_NO_DATA_YET); |
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 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4018 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4019 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4020 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4021 | WR_HARPOON(port + hp_autostart_0, (END_DATA + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4022 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4023 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4024 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4025 | if (currSCCB->Sccb_XferCnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4026 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4027 | if ((currSCCB->ControlByte & SCCB_DATA_XFER_OUT) && |
| 4028 | (currSCCB->HostStatus == SCCB_COMPLETE)) |
| 4029 | currSCCB->HostStatus = SCCB_DATA_OVER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4030 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4031 | FPT_sxfrp(port, p_card); |
| 4032 | if (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | RESET))) |
| 4033 | FPT_phaseDecode(port, p_card); |
| 4034 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4035 | } |
| 4036 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4037 | /*--------------------------------------------------------------------- |
| 4038 | * |
| 4039 | * Function: Data In Phase |
| 4040 | * |
| 4041 | * Description: Startup the BusMaster and the XBOW. |
| 4042 | * |
| 4043 | *---------------------------------------------------------------------*/ |
| 4044 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4045 | static void FPT_phaseDataIn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4046 | { |
| 4047 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4048 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4049 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4050 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4051 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4052 | if (currSCCB == NULL) { |
| 4053 | return; /* Exit if No SCCB record */ |
| 4054 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4055 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4056 | currSCCB->Sccb_scsistat = DATA_IN_ST; |
| 4057 | currSCCB->Sccb_XferState |= F_HOST_XFER_DIR; |
| 4058 | currSCCB->Sccb_XferState &= ~F_NO_DATA_YET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4059 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4060 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4062 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4063 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4064 | WR_HARPOON(port + hp_autostart_0, (END_DATA + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4065 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4066 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4067 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4068 | if (currSCCB->Sccb_XferCnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4069 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4070 | if ((currSCCB->ControlByte & SCCB_DATA_XFER_IN) && |
| 4071 | (currSCCB->HostStatus == SCCB_COMPLETE)) |
| 4072 | currSCCB->HostStatus = SCCB_DATA_OVER_RUN; |
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 | FPT_sxfrp(port, p_card); |
| 4075 | if (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | RESET))) |
| 4076 | FPT_phaseDecode(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4077 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4078 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4079 | } |
| 4080 | |
| 4081 | /*--------------------------------------------------------------------- |
| 4082 | * |
| 4083 | * Function: Command Phase |
| 4084 | * |
| 4085 | * Description: Load the CDB into the automation and start it up. |
| 4086 | * |
| 4087 | *---------------------------------------------------------------------*/ |
| 4088 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4089 | static void FPT_phaseCommand(u32 p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4090 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4091 | struct sccb *currSCCB; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4092 | u32 cdb_reg; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4093 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4094 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4095 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4096 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4097 | if (currSCCB->OperationCode == RESET_COMMAND) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4098 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4099 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4100 | currSCCB->CdbLength = SIX_BYTE_CMD; |
| 4101 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4102 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4103 | WR_HARPOON(p_port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4104 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4105 | ARAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4106 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4107 | cdb_reg = p_port + CMD_STRT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4108 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4109 | for (i = 0; i < currSCCB->CdbLength; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4110 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4111 | if (currSCCB->OperationCode == RESET_COMMAND) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4112 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4113 | WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + 0x00)); |
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 | else |
| 4116 | WRW_HARPOON(cdb_reg, |
| 4117 | (MPM_OP + ACOMMAND + currSCCB->Cdb[i])); |
| 4118 | cdb_reg += 2; |
| 4119 | } |
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->CdbLength != TWELVE_BYTE_CMD) |
| 4122 | WRW_HARPOON(cdb_reg, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4123 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4124 | WR_HARPOON(p_port + hp_portctrl_0, (SCSI_PORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4125 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4126 | currSCCB->Sccb_scsistat = COMMAND_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4127 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4128 | WR_HARPOON(p_port + hp_autostart_3, (AUTO_IMMED | CMD_ONLY_STRT)); |
| 4129 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4130 | } |
| 4131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4132 | /*--------------------------------------------------------------------- |
| 4133 | * |
| 4134 | * Function: Status phase |
| 4135 | * |
| 4136 | * Description: Bring in the status and command complete message bytes |
| 4137 | * |
| 4138 | *---------------------------------------------------------------------*/ |
| 4139 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4140 | static void FPT_phaseStatus(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4141 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4142 | /* Start-up the automation to finish off this command and let the |
| 4143 | isr handle the interrupt for command complete when it comes in. |
| 4144 | We could wait here for the interrupt to be generated? |
| 4145 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4146 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4147 | WR_HARPOON(port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4148 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4149 | WR_HARPOON(port + hp_autostart_0, (AUTO_IMMED + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4150 | } |
| 4151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4152 | /*--------------------------------------------------------------------- |
| 4153 | * |
| 4154 | * Function: Phase Message Out |
| 4155 | * |
| 4156 | * Description: Send out our message (if we have one) and handle whatever |
| 4157 | * else is involed. |
| 4158 | * |
| 4159 | *---------------------------------------------------------------------*/ |
| 4160 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4161 | static void FPT_phaseMsgOut(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4162 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4163 | unsigned char message, scsiID; |
| 4164 | struct sccb *currSCCB; |
| 4165 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4166 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4167 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4168 | |
| 4169 | if (currSCCB != NULL) { |
| 4170 | |
| 4171 | message = currSCCB->Sccb_scsimsg; |
| 4172 | scsiID = currSCCB->TargID; |
| 4173 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4174 | if (message == SMDEV_RESET) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4175 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4176 | currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4177 | currTar_Info->TarSyncCtrl = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4178 | FPT_sssyncv(port, scsiID, NARROW_SCSI, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4179 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4180 | if (FPT_sccbMgrTbl[p_card][scsiID]. |
| 4181 | TarEEValue & EE_SYNC_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4182 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4183 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus &= |
| 4184 | ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4185 | |
| 4186 | } |
| 4187 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4188 | if (FPT_sccbMgrTbl[p_card][scsiID]. |
| 4189 | TarEEValue & EE_WIDE_SCSI) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4190 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4191 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus &= |
| 4192 | ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4193 | } |
| 4194 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4195 | FPT_queueFlushSccb(p_card, SCCB_COMPLETE); |
| 4196 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 4197 | } else if (currSCCB->Sccb_scsistat == ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4198 | currSCCB->HostStatus = SCCB_COMPLETE; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4199 | if (FPT_BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] != |
| 4200 | NULL) { |
| 4201 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4202 | Sccb_tag] = NULL; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4203 | FPT_sccbMgrTbl[p_card][scsiID].TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4204 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4206 | } |
| 4207 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4208 | else if (currSCCB->Sccb_scsistat < COMMAND_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4209 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4210 | if (message == SMNO_OP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4211 | currSCCB->Sccb_MGRFlags |= F_DEV_SELECTED; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4212 | |
| 4213 | FPT_ssel(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4214 | return; |
| 4215 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4216 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4217 | |
| 4218 | if (message == SMABORT) |
| 4219 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4220 | FPT_queueFlushSccb(p_card, SCCB_COMPLETE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4221 | } |
| 4222 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4223 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4224 | message = SMABORT; |
| 4225 | } |
| 4226 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4227 | WRW_HARPOON((port + hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0)); |
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 | WR_HARPOON(port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4230 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4231 | WR_HARPOON(port + hp_scsidata_0, message); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4232 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4233 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4234 | |
| 4235 | ACCEPT_MSG(port); |
| 4236 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4237 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4238 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4239 | if ((message == SMABORT) || (message == SMDEV_RESET) || |
| 4240 | (message == SMABORT_TAG)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4241 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4242 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | PHASE))) { |
| 4243 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4244 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4245 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 4246 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4247 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4248 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4249 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4250 | if ((FPT_BL_Card[p_card]. |
| 4251 | globalFlags & F_CONLUN_IO) |
| 4252 | && |
| 4253 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4254 | TarStatus & TAR_TAG_Q_MASK) != |
| 4255 | TAG_Q_TRYING)) |
| 4256 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4257 | TargID]. |
| 4258 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4259 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4260 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4261 | TargID]. |
| 4262 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4263 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4264 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 4265 | currSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4266 | } |
| 4267 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4268 | else { |
| 4269 | FPT_BL_Card[p_card].globalFlags |= |
| 4270 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4271 | } |
| 4272 | } |
| 4273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4274 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4275 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4276 | FPT_sxfrp(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4277 | } |
| 4278 | } |
| 4279 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4280 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4281 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4282 | if (message == SMPARITY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4283 | currSCCB->Sccb_scsimsg = SMNO_OP; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4284 | WR_HARPOON(port + hp_autostart_1, |
| 4285 | (AUTO_IMMED + DISCONNECT_START)); |
| 4286 | } else { |
| 4287 | FPT_sxfrp(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4288 | } |
| 4289 | } |
| 4290 | } |
| 4291 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4292 | /*--------------------------------------------------------------------- |
| 4293 | * |
| 4294 | * Function: Message In phase |
| 4295 | * |
| 4296 | * Description: Bring in the message and determine what to do with it. |
| 4297 | * |
| 4298 | *---------------------------------------------------------------------*/ |
| 4299 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4300 | static void FPT_phaseMsgIn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4301 | { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 4302 | unsigned char message; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4303 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4304 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4305 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4306 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4307 | if (FPT_BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4308 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4309 | FPT_phaseChkFifo(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4310 | } |
| 4311 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4312 | message = RD_HARPOON(port + hp_scsidata_0); |
| 4313 | if ((message == SMDISC) || (message == SMSAVE_DATA_PTR)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4314 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4315 | WR_HARPOON(port + hp_autostart_1, |
| 4316 | (AUTO_IMMED + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4317 | |
| 4318 | } |
| 4319 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4320 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4321 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4322 | message = FPT_sfm(port, currSCCB); |
| 4323 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4324 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4325 | FPT_sdecm(message, port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4326 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4327 | } else { |
| 4328 | if (currSCCB->Sccb_scsimsg != SMPARITY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4329 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4330 | WR_HARPOON(port + hp_autostart_1, |
| 4331 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4332 | } |
| 4333 | } |
| 4334 | |
| 4335 | } |
| 4336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4337 | /*--------------------------------------------------------------------- |
| 4338 | * |
| 4339 | * Function: Illegal phase |
| 4340 | * |
| 4341 | * Description: Target switched to some illegal phase, so all we can do |
| 4342 | * is report an error back to the host (if that is possible) |
| 4343 | * and send an ABORT message to the misbehaving target. |
| 4344 | * |
| 4345 | *---------------------------------------------------------------------*/ |
| 4346 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4347 | static void FPT_phaseIllegal(u32 port, unsigned char p_card) |
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 | struct sccb *currSCCB; |
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 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4352 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4353 | WR_HARPOON(port + hp_scsisig, RD_HARPOON(port + hp_scsisig)); |
| 4354 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4355 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4356 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4357 | currSCCB->Sccb_scsistat = ABORT_ST; |
| 4358 | currSCCB->Sccb_scsimsg = SMABORT; |
| 4359 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4360 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4361 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4362 | } |
| 4363 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4364 | /*--------------------------------------------------------------------- |
| 4365 | * |
| 4366 | * Function: Phase Check FIFO |
| 4367 | * |
| 4368 | * Description: Make sure data has been flushed from both FIFOs and abort |
| 4369 | * the operations if necessary. |
| 4370 | * |
| 4371 | *---------------------------------------------------------------------*/ |
| 4372 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4373 | static void FPT_phaseChkFifo(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4374 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4375 | u32 xfercnt; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4376 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4377 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4378 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
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 | if (currSCCB->Sccb_scsistat == DATA_IN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4381 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4382 | while ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) && |
| 4383 | (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY)) { |
| 4384 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4385 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4386 | if (!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) { |
| 4387 | currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4388 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4389 | currSCCB->Sccb_XferCnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4390 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4391 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 4392 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
| 4393 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 4394 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 4395 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4396 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4397 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
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 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4400 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4401 | while ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) |
| 4402 | && (RD_HARPOON(port + hp_ext_status) & |
| 4403 | BM_CMD_BUSY)) { |
| 4404 | } |
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 | } |
| 4407 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4408 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4409 | /*End Data In specific code. */ |
| 4410 | GET_XFER_CNT(port, xfercnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4412 | WR_HARPOON(port + hp_xfercnt_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4413 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4414 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4415 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4416 | currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - xfercnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4417 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4418 | currSCCB->Sccb_XferCnt = xfercnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4420 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 4421 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
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 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 4424 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 4425 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4426 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4427 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4429 | WR_HARPOON(port + hp_fifowrite, 0x00); |
| 4430 | WR_HARPOON(port + hp_fiforead, 0x00); |
| 4431 | WR_HARPOON(port + hp_xferstat, 0x00); |
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 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4434 | } |
| 4435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4436 | /*--------------------------------------------------------------------- |
| 4437 | * |
| 4438 | * Function: Phase Bus Free |
| 4439 | * |
| 4440 | * Description: We just went bus free so figure out if it was |
| 4441 | * because of command complete or from a disconnect. |
| 4442 | * |
| 4443 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4444 | static void FPT_phaseBusFree(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4445 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4446 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4447 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4448 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4450 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4451 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4452 | DISABLE_AUTO(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4453 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4454 | if (currSCCB->OperationCode == RESET_COMMAND) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4455 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4456 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4457 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4458 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4459 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4460 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4461 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4462 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4463 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4464 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4465 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, |
| 4466 | p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4467 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4468 | FPT_queueSearchSelect(&FPT_BL_Card[p_card], 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 | } |
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 | else if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
| 4473 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= |
| 4474 | (unsigned char)SYNC_SUPPORTED; |
| 4475 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4476 | ~EE_SYNC_MASK; |
| 4477 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4478 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4479 | else if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
| 4480 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus = |
| 4481 | (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4482 | TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4483 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4484 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4485 | ~EE_WIDE_SCSI; |
| 4486 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4487 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4488 | else if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { |
| 4489 | /* Make sure this is not a phony BUS_FREE. If we were |
| 4490 | reselected or if BUSY is NOT on then this is a |
| 4491 | valid BUS FREE. SRR Wednesday, 5/10/1995. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4492 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4493 | if ((!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) || |
| 4494 | (RDW_HARPOON((port + hp_intstat)) & RSEL)) { |
| 4495 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4496 | TarStatus &= ~TAR_TAG_Q_MASK; |
| 4497 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4498 | TarStatus |= TAG_Q_REJECT; |
| 4499 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4500 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4501 | else { |
| 4502 | return; |
| 4503 | } |
| 4504 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4506 | else { |
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 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4509 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4510 | if (!currSCCB->HostStatus) { |
| 4511 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4512 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4513 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4514 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4515 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4516 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4517 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4518 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4519 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4520 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4521 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4522 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4523 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, |
| 4524 | p_card); |
| 4525 | return; |
| 4526 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4527 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4528 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
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 | } /*end if !=null */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4531 | } |
| 4532 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4533 | /*--------------------------------------------------------------------- |
| 4534 | * |
| 4535 | * Function: Auto Load Default Map |
| 4536 | * |
| 4537 | * Description: Load the Automation RAM with the defualt map values. |
| 4538 | * |
| 4539 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4540 | static void FPT_autoLoadDefaultMap(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4541 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4542 | u32 map_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4543 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4544 | ARAM_ACCESS(p_port); |
| 4545 | map_addr = p_port + hp_aramBase; |
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 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0xC0)); /*ID MESSAGE */ |
| 4548 | map_addr += 2; |
| 4549 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0x20)); /*SIMPLE TAG QUEUEING MSG */ |
| 4550 | map_addr += 2; |
| 4551 | WRW_HARPOON(map_addr, RAT_OP); /*RESET ATTENTION */ |
| 4552 | map_addr += 2; |
| 4553 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0x00)); /*TAG ID MSG */ |
| 4554 | map_addr += 2; |
| 4555 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 0 */ |
| 4556 | map_addr += 2; |
| 4557 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 1 */ |
| 4558 | map_addr += 2; |
| 4559 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 2 */ |
| 4560 | map_addr += 2; |
| 4561 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 3 */ |
| 4562 | map_addr += 2; |
| 4563 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 4 */ |
| 4564 | map_addr += 2; |
| 4565 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 5 */ |
| 4566 | map_addr += 2; |
| 4567 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 6 */ |
| 4568 | map_addr += 2; |
| 4569 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 7 */ |
| 4570 | map_addr += 2; |
| 4571 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 8 */ |
| 4572 | map_addr += 2; |
| 4573 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 9 */ |
| 4574 | map_addr += 2; |
| 4575 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 10 */ |
| 4576 | map_addr += 2; |
| 4577 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 11 */ |
| 4578 | map_addr += 2; |
| 4579 | WRW_HARPOON(map_addr, (CPE_OP + ADATA_OUT + DINT)); /*JUMP IF DATA OUT */ |
| 4580 | map_addr += 2; |
| 4581 | WRW_HARPOON(map_addr, (TCB_OP + FIFO_0 + DI)); /*JUMP IF NO DATA IN FIFO */ |
| 4582 | map_addr += 2; /*This means AYNC DATA IN */ |
| 4583 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IDO_STRT)); /*STOP AND INTERRUPT */ |
| 4584 | map_addr += 2; |
| 4585 | WRW_HARPOON(map_addr, (CPE_OP + ADATA_IN + DINT)); /*JUMP IF NOT DATA IN PHZ */ |
| 4586 | map_addr += 2; |
| 4587 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + ST)); /*IF NOT MSG IN CHECK 4 DATA IN */ |
| 4588 | map_addr += 2; |
| 4589 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x02)); /*SAVE DATA PTR MSG? */ |
| 4590 | map_addr += 2; |
| 4591 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + DC)); /*GO CHECK FOR DISCONNECT MSG */ |
| 4592 | map_addr += 2; |
| 4593 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_AR1)); /*SAVE DATA PTRS MSG */ |
| 4594 | map_addr += 2; |
| 4595 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + ST)); /*IF NOT MSG IN CHECK DATA IN */ |
| 4596 | map_addr += 2; |
| 4597 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x04)); /*DISCONNECT MSG? */ |
| 4598 | map_addr += 2; |
| 4599 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + UNKNWN)); /*UKNKNOWN MSG */ |
| 4600 | map_addr += 2; |
| 4601 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_BUCKET)); /*XFER DISCONNECT MSG */ |
| 4602 | map_addr += 2; |
| 4603 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ITAR_DISC)); /*STOP AND INTERRUPT */ |
| 4604 | map_addr += 2; |
| 4605 | WRW_HARPOON(map_addr, (CPN_OP + ASTATUS + UNKNWN)); /*JUMP IF NOT STATUS PHZ. */ |
| 4606 | map_addr += 2; |
| 4607 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_AR0)); /*GET STATUS BYTE */ |
| 4608 | map_addr += 2; |
| 4609 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + CC)); /*ERROR IF NOT MSG IN PHZ */ |
| 4610 | map_addr += 2; |
| 4611 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x00)); /*CHECK FOR CMD COMPLETE MSG. */ |
| 4612 | map_addr += 2; |
| 4613 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + CC)); /*ERROR IF NOT CMD COMPLETE MSG. */ |
| 4614 | map_addr += 2; |
| 4615 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_BUCKET)); /*GET CMD COMPLETE MSG */ |
| 4616 | map_addr += 2; |
| 4617 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ICMD_COMP)); /*END OF COMMAND */ |
| 4618 | map_addr += 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4619 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4620 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IUNKWN)); /*RECEIVED UNKNOWN MSG BYTE */ |
| 4621 | map_addr += 2; |
| 4622 | WRW_HARPOON(map_addr, (SSI_OP + SSI_INO_CC)); /*NO COMMAND COMPLETE AFTER STATUS */ |
| 4623 | map_addr += 2; |
| 4624 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ITICKLE)); /*BIOS Tickled the Mgr */ |
| 4625 | map_addr += 2; |
| 4626 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IRFAIL)); /*EXPECTED ID/TAG MESSAGES AND */ |
| 4627 | map_addr += 2; /* DIDN'T GET ONE */ |
| 4628 | WRW_HARPOON(map_addr, (CRR_OP + AR3 + S_IDREG)); /* comp SCSI SEL ID & AR3 */ |
| 4629 | map_addr += 2; |
| 4630 | WRW_HARPOON(map_addr, (BRH_OP + EQUAL + 0x00)); /*SEL ID OK then Conti. */ |
| 4631 | map_addr += 2; |
| 4632 | 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] | 4633 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4634 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4635 | } |
| 4636 | |
| 4637 | /*--------------------------------------------------------------------- |
| 4638 | * |
| 4639 | * Function: Auto Command Complete |
| 4640 | * |
| 4641 | * Description: Post command back to host and find another command |
| 4642 | * to execute. |
| 4643 | * |
| 4644 | *---------------------------------------------------------------------*/ |
| 4645 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4646 | static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4647 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4648 | struct sccb *currSCCB; |
| 4649 | unsigned char status_byte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4650 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4651 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4652 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4653 | status_byte = RD_HARPOON(p_port + hp_gp_reg_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4654 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4655 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUN_CA = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4656 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4657 | if (status_byte != SSGOOD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4658 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4659 | if (status_byte == SSQ_FULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4660 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4661 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4662 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4663 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4664 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4665 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4666 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4667 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4668 | FPT_BL_Card[p_card]. |
| 4669 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4670 | [currSCCB->TargID]. |
| 4671 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4672 | NULL; |
| 4673 | } else { |
| 4674 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4675 | TarLUNBusy[0] = 1; |
| 4676 | if (currSCCB->Sccb_tag) { |
| 4677 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4678 | FPT_BL_Card[p_card]. |
| 4679 | discQCount--; |
| 4680 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4681 | Sccb_tag] |
| 4682 | = NULL; |
| 4683 | } else { |
| 4684 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4685 | FPT_BL_Card[p_card]. |
| 4686 | discQCount--; |
| 4687 | FPT_BL_Card[p_card]. |
| 4688 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4689 | [currSCCB->TargID]. |
| 4690 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4691 | } |
| 4692 | } |
| 4693 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4694 | currSCCB->Sccb_MGRFlags |= F_STATUSLOADED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4695 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4696 | FPT_queueSelectFail(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4697 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4698 | return; |
| 4699 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4700 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4701 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
| 4702 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= |
| 4703 | (unsigned char)SYNC_SUPPORTED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4704 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4705 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4706 | ~EE_SYNC_MASK; |
| 4707 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4708 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4709 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4710 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4711 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4712 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4713 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4714 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4715 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4716 | FPT_BL_Card[p_card]. |
| 4717 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4718 | [currSCCB->TargID]. |
| 4719 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4720 | NULL; |
| 4721 | } else { |
| 4722 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4723 | TarLUNBusy[0] = 1; |
| 4724 | if (currSCCB->Sccb_tag) { |
| 4725 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4726 | FPT_BL_Card[p_card]. |
| 4727 | discQCount--; |
| 4728 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4729 | Sccb_tag] |
| 4730 | = NULL; |
| 4731 | } else { |
| 4732 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4733 | FPT_BL_Card[p_card]. |
| 4734 | discQCount--; |
| 4735 | FPT_BL_Card[p_card]. |
| 4736 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4737 | [currSCCB->TargID]. |
| 4738 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4739 | } |
| 4740 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4741 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4742 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4743 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4744 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4745 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4746 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4747 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus = |
| 4748 | (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4749 | TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4750 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4751 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4752 | ~EE_WIDE_SCSI; |
| 4753 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4754 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4755 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4756 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4757 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4758 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4759 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4760 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4761 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4762 | FPT_BL_Card[p_card]. |
| 4763 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4764 | [currSCCB->TargID]. |
| 4765 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4766 | NULL; |
| 4767 | } else { |
| 4768 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4769 | TarLUNBusy[0] = 1; |
| 4770 | if (currSCCB->Sccb_tag) { |
| 4771 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4772 | FPT_BL_Card[p_card]. |
| 4773 | discQCount--; |
| 4774 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4775 | Sccb_tag] |
| 4776 | = NULL; |
| 4777 | } else { |
| 4778 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4779 | FPT_BL_Card[p_card]. |
| 4780 | discQCount--; |
| 4781 | FPT_BL_Card[p_card]. |
| 4782 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4783 | [currSCCB->TargID]. |
| 4784 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4785 | } |
| 4786 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4787 | return; |
| 4788 | |
| 4789 | } |
| 4790 | |
| 4791 | if (status_byte == SSCHECK) { |
| 4792 | if (FPT_BL_Card[p_card].globalFlags & F_DO_RENEGO) { |
| 4793 | if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4794 | TarEEValue & EE_SYNC_MASK) { |
| 4795 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4796 | TargID]. |
| 4797 | TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4798 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4799 | if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4800 | TarEEValue & EE_WIDE_SCSI) { |
| 4801 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4802 | TargID]. |
| 4803 | TarStatus &= ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4804 | } |
| 4805 | } |
| 4806 | } |
| 4807 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4808 | if (!(currSCCB->Sccb_XferState & F_AUTO_SENSE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4809 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4810 | currSCCB->SccbStatus = SCCB_ERROR; |
| 4811 | currSCCB->TargetStatus = status_byte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4812 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4813 | if (status_byte == SSCHECK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4814 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4815 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4816 | TarLUN_CA = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4817 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4818 | if (currSCCB->RequestSenseLength != |
| 4819 | NO_AUTO_REQUEST_SENSE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4820 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4821 | if (currSCCB->RequestSenseLength == 0) |
| 4822 | currSCCB->RequestSenseLength = |
| 4823 | 14; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4824 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4825 | FPT_ssenss(&FPT_BL_Card[p_card]); |
| 4826 | FPT_BL_Card[p_card].globalFlags |= |
| 4827 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4828 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4829 | if (((FPT_BL_Card[p_card]. |
| 4830 | globalFlags & F_CONLUN_IO) |
| 4831 | && |
| 4832 | ((FPT_sccbMgrTbl[p_card] |
| 4833 | [currSCCB->TargID]. |
| 4834 | TarStatus & TAR_TAG_Q_MASK) != |
| 4835 | TAG_Q_TRYING))) { |
| 4836 | FPT_sccbMgrTbl[p_card] |
| 4837 | [currSCCB->TargID]. |
| 4838 | TarLUNBusy[currSCCB->Lun] = |
| 4839 | 1; |
| 4840 | if (FPT_BL_Card[p_card]. |
| 4841 | discQCount != 0) |
| 4842 | FPT_BL_Card[p_card]. |
| 4843 | discQCount--; |
| 4844 | FPT_BL_Card[p_card]. |
| 4845 | discQ_Tbl[FPT_sccbMgrTbl |
| 4846 | [p_card] |
| 4847 | [currSCCB-> |
| 4848 | TargID]. |
| 4849 | LunDiscQ_Idx |
| 4850 | [currSCCB->Lun]] = |
| 4851 | NULL; |
| 4852 | } else { |
| 4853 | FPT_sccbMgrTbl[p_card] |
| 4854 | [currSCCB->TargID]. |
| 4855 | TarLUNBusy[0] = 1; |
| 4856 | if (currSCCB->Sccb_tag) { |
| 4857 | if (FPT_BL_Card[p_card]. |
| 4858 | discQCount != 0) |
| 4859 | FPT_BL_Card |
| 4860 | [p_card]. |
| 4861 | discQCount--; |
| 4862 | FPT_BL_Card[p_card]. |
| 4863 | discQ_Tbl[currSCCB-> |
| 4864 | Sccb_tag] |
| 4865 | = NULL; |
| 4866 | } else { |
| 4867 | if (FPT_BL_Card[p_card]. |
| 4868 | discQCount != 0) |
| 4869 | FPT_BL_Card |
| 4870 | [p_card]. |
| 4871 | discQCount--; |
| 4872 | FPT_BL_Card[p_card]. |
| 4873 | discQ_Tbl |
| 4874 | [FPT_sccbMgrTbl |
| 4875 | [p_card][currSCCB-> |
| 4876 | TargID]. |
| 4877 | LunDiscQ_Idx[0]] = |
| 4878 | NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4879 | } |
| 4880 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4881 | return; |
| 4882 | } |
| 4883 | } |
| 4884 | } |
| 4885 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4886 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4887 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4888 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4889 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4890 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB-> |
| 4891 | Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4892 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4893 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4894 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4895 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4896 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4897 | |
| 4898 | #define SHORT_WAIT 0x0000000F |
| 4899 | #define LONG_WAIT 0x0000FFFFL |
| 4900 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4901 | /*--------------------------------------------------------------------- |
| 4902 | * |
| 4903 | * Function: Data Transfer Processor |
| 4904 | * |
| 4905 | * Description: This routine performs two tasks. |
| 4906 | * (1) Start data transfer by calling HOST_DATA_XFER_START |
| 4907 | * function. Once data transfer is started, (2) Depends |
| 4908 | * on the type of data transfer mode Scatter/Gather mode |
| 4909 | * or NON Scatter/Gather mode. In NON Scatter/Gather mode, |
| 4910 | * this routine checks Sccb_MGRFlag (F_HOST_XFER_ACT bit) for |
| 4911 | * data transfer done. In Scatter/Gather mode, this routine |
| 4912 | * checks bus master command complete and dual rank busy |
| 4913 | * bit to keep chaining SC transfer command. Similarly, |
| 4914 | * in Scatter/Gather mode, it checks Sccb_MGRFlag |
| 4915 | * (F_HOST_XFER_ACT bit) for data transfer done. |
| 4916 | * |
| 4917 | *---------------------------------------------------------------------*/ |
| 4918 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4919 | static void FPT_dataXferProcessor(u32 port, struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4920 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4921 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4922 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4923 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4924 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4925 | if (currSCCB->Sccb_XferState & F_SG_XFER) { |
| 4926 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
| 4927 | { |
| 4928 | currSCCB->Sccb_sgseg += (unsigned char)SG_BUF_CNT; |
| 4929 | currSCCB->Sccb_SGoffset = 0x00; |
| 4930 | } |
| 4931 | pCurrCard->globalFlags |= F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4932 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4933 | FPT_busMstrSGDataXferStart(port, currSCCB); |
| 4934 | } |
| 4935 | |
| 4936 | else { |
| 4937 | if (!(pCurrCard->globalFlags & F_HOST_XFER_ACT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4938 | pCurrCard->globalFlags |= F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4939 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4940 | FPT_busMstrDataXferStart(port, currSCCB); |
| 4941 | } |
| 4942 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4943 | } |
| 4944 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4945 | /*--------------------------------------------------------------------- |
| 4946 | * |
| 4947 | * Function: BusMaster Scatter Gather Data Transfer Start |
| 4948 | * |
| 4949 | * Description: |
| 4950 | * |
| 4951 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4952 | static void FPT_busMstrSGDataXferStart(u32 p_port, struct sccb *pcurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4953 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4954 | u32 count, addr, tmpSGCnt; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4955 | unsigned int sg_index; |
| 4956 | unsigned char sg_count, i; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4957 | u32 reg_offset; |
| 4958 | struct blogic_sg_seg *segp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4959 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4960 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) |
| 4961 | count = ((u32)HOST_RD_CMD) << 24; |
| 4962 | else |
| 4963 | count = ((u32)HOST_WRT_CMD) << 24; |
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 | sg_count = 0; |
| 4966 | tmpSGCnt = 0; |
| 4967 | sg_index = pcurrSCCB->Sccb_sgseg; |
| 4968 | reg_offset = hp_aramBase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4969 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4970 | i = (unsigned char)(RD_HARPOON(p_port + hp_page_ctrl) & |
| 4971 | ~(SGRAM_ARAM | SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4972 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4973 | WR_HARPOON(p_port + hp_page_ctrl, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4974 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4975 | while ((sg_count < (unsigned char)SG_BUF_CNT) && |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4976 | ((sg_index * (unsigned int)SG_ELEMENT_SIZE) < |
| 4977 | pcurrSCCB->DataLength)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4978 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4979 | segp = (struct blogic_sg_seg *)(pcurrSCCB->DataPointer) + |
| 4980 | sg_index; |
| 4981 | tmpSGCnt += segp->segbytes; |
| 4982 | count |= segp->segbytes; |
| 4983 | addr = segp->segdata; |
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 ((!sg_count) && (pcurrSCCB->Sccb_SGoffset)) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4986 | addr += |
| 4987 | ((count & 0x00FFFFFFL) - pcurrSCCB->Sccb_SGoffset); |
| 4988 | count = |
| 4989 | (count & 0xFF000000L) | pcurrSCCB->Sccb_SGoffset; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4990 | tmpSGCnt = count & 0x00FFFFFFL; |
| 4991 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4992 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4993 | WR_HARP32(p_port, reg_offset, addr); |
| 4994 | reg_offset += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4995 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4996 | WR_HARP32(p_port, reg_offset, count); |
| 4997 | reg_offset += 4; |
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 | count &= 0xFF000000L; |
| 5000 | sg_index++; |
| 5001 | sg_count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5002 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5003 | } /*End While */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5004 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5005 | pcurrSCCB->Sccb_XferCnt = tmpSGCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5006 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5007 | WR_HARPOON(p_port + hp_sg_addr, (sg_count << 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5008 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5009 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
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 | WR_HARP32(p_port, hp_xfercnt_0, tmpSGCnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5012 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5013 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5014 | (DMA_PORT | SCSI_PORT | SCSI_INBIT)); |
| 5015 | WR_HARPOON(p_port + hp_scsisig, S_DATAI_PH); |
| 5016 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5017 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5018 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5019 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5020 | if ((!(RD_HARPOON(p_port + hp_synctarg_0) & NARROW_SCSI)) && |
| 5021 | (tmpSGCnt & 0x000000001)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5022 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5023 | pcurrSCCB->Sccb_XferState |= F_ODD_BALL_CNT; |
| 5024 | tmpSGCnt--; |
| 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, hp_xfercnt_0, tmpSGCnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5028 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5029 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5030 | (SCSI_PORT | DMA_PORT | DMA_RD)); |
| 5031 | WR_HARPOON(p_port + hp_scsisig, S_DATAO_PH); |
| 5032 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5033 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5034 | WR_HARPOON(p_port + hp_page_ctrl, (unsigned char)(i | SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5035 | |
| 5036 | } |
| 5037 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5038 | /*--------------------------------------------------------------------- |
| 5039 | * |
| 5040 | * Function: BusMaster Data Transfer Start |
| 5041 | * |
| 5042 | * Description: |
| 5043 | * |
| 5044 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5045 | static void FPT_busMstrDataXferStart(u32 p_port, struct sccb *pcurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5046 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5047 | u32 addr, count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5048 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5049 | if (!(pcurrSCCB->Sccb_XferState & F_AUTO_SENSE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5050 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5051 | count = pcurrSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5052 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5053 | addr = (u32)(unsigned long)pcurrSCCB->DataPointer + pcurrSCCB->Sccb_ATC; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5054 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5055 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5056 | else { |
| 5057 | addr = pcurrSCCB->SensePointer; |
| 5058 | count = pcurrSCCB->RequestSenseLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5059 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5060 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5062 | HP_SETUP_ADDR_CNT(p_port, addr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5063 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5064 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5065 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5066 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5067 | (DMA_PORT | SCSI_PORT | SCSI_INBIT)); |
| 5068 | WR_HARPOON(p_port + hp_scsisig, S_DATAI_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5069 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5070 | WR_HARPOON(p_port + hp_xfer_cmd, |
| 5071 | (XFER_DMA_HOST | XFER_HOST_AUTO | XFER_DMA_8BIT)); |
| 5072 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5073 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5074 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5075 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5076 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5077 | (SCSI_PORT | DMA_PORT | DMA_RD)); |
| 5078 | WR_HARPOON(p_port + hp_scsisig, S_DATAO_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5079 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5080 | WR_HARPOON(p_port + hp_xfer_cmd, |
| 5081 | (XFER_HOST_DMA | XFER_HOST_AUTO | XFER_DMA_8BIT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5082 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5083 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5084 | } |
| 5085 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5086 | /*--------------------------------------------------------------------- |
| 5087 | * |
| 5088 | * Function: BusMaster Timeout Handler |
| 5089 | * |
| 5090 | * Description: This function is called after a bus master command busy time |
| 5091 | * out is detected. This routines issue halt state machine |
| 5092 | * with a software time out for command busy. If command busy |
| 5093 | * is still asserted at the end of the time out, it issues |
| 5094 | * hard abort with another software time out. It hard abort |
| 5095 | * command busy is also time out, it'll just give up. |
| 5096 | * |
| 5097 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5098 | static unsigned char FPT_busMstrTimeOut(u32 p_port) |
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 | unsigned long timeout; |
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 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5103 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5104 | WR_HARPOON(p_port + hp_sys_ctrl, HALT_MACH); |
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 | while ((!(RD_HARPOON(p_port + hp_ext_status) & CMD_ABORTED)) |
| 5107 | && timeout--) { |
| 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 | if (RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) { |
| 5111 | WR_HARPOON(p_port + hp_sys_ctrl, HARD_ABORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5112 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5113 | timeout = LONG_WAIT; |
| 5114 | while ((RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) |
| 5115 | && timeout--) { |
| 5116 | } |
| 5117 | } |
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 | RD_HARPOON(p_port + hp_int_status); /*Clear command complete */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5120 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5121 | if (RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5122 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5123 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5124 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5125 | else { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5126 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5127 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5128 | } |
| 5129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5130 | /*--------------------------------------------------------------------- |
| 5131 | * |
| 5132 | * Function: Host Data Transfer Abort |
| 5133 | * |
| 5134 | * Description: Abort any in progress transfer. |
| 5135 | * |
| 5136 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5137 | static void FPT_hostDataXferAbort(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5138 | struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5139 | { |
| 5140 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5141 | unsigned long timeout; |
| 5142 | unsigned long remain_cnt; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5143 | u32 sg_ptr; |
| 5144 | struct blogic_sg_seg *segp; |
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 | FPT_BL_Card[p_card].globalFlags &= ~F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5147 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5148 | if (pCurrSCCB->Sccb_XferState & F_AUTO_SENSE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5149 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5150 | if (!(RD_HARPOON(port + hp_int_status) & INT_CMD_COMPL)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5151 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5152 | WR_HARPOON(port + hp_bm_ctrl, |
| 5153 | (RD_HARPOON(port + hp_bm_ctrl) | |
| 5154 | FLUSH_XFER_CNTR)); |
| 5155 | timeout = LONG_WAIT; |
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 | while ((RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) |
| 5158 | && timeout--) { |
| 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 | WR_HARPOON(port + hp_bm_ctrl, |
| 5162 | (RD_HARPOON(port + hp_bm_ctrl) & |
| 5163 | ~FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5164 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5165 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5166 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5167 | if (FPT_busMstrTimeOut(port)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5168 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5169 | if (pCurrSCCB->HostStatus == 0x00) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5170 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5171 | pCurrSCCB->HostStatus = |
| 5172 | SCCB_BM_ERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5173 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5174 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5175 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5176 | if (RD_HARPOON(port + hp_int_status) & |
| 5177 | INT_EXT_STATUS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5178 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5179 | if (RD_HARPOON(port + hp_ext_status) & |
| 5180 | BAD_EXT_STATUS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5181 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5182 | if (pCurrSCCB->HostStatus == |
| 5183 | 0x00) |
| 5184 | { |
| 5185 | pCurrSCCB->HostStatus = |
| 5186 | SCCB_BM_ERR; |
| 5187 | } |
| 5188 | } |
| 5189 | } |
| 5190 | } |
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 | else if (pCurrSCCB->Sccb_XferCnt) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5193 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5194 | if (pCurrSCCB->Sccb_XferState & F_SG_XFER) { |
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_page_ctrl, |
| 5197 | (RD_HARPOON(port + hp_page_ctrl) & |
| 5198 | ~SCATTER_EN)); |
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 | WR_HARPOON(port + hp_sg_addr, 0x00); |
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 | sg_ptr = pCurrSCCB->Sccb_sgseg + SG_BUF_CNT; |
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 (sg_ptr > |
| 5205 | (unsigned int)(pCurrSCCB->DataLength / |
| 5206 | SG_ELEMENT_SIZE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5207 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5208 | sg_ptr = (u32)(pCurrSCCB->DataLength / |
| 5209 | SG_ELEMENT_SIZE); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5210 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5211 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5212 | remain_cnt = pCurrSCCB->Sccb_XferCnt; |
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 | while (remain_cnt < 0x01000000L) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5215 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5216 | sg_ptr--; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5217 | segp = (struct blogic_sg_seg *)(pCurrSCCB-> |
| 5218 | DataPointer) + (sg_ptr * 2); |
| 5219 | if (remain_cnt > (unsigned long)segp->segbytes) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5220 | remain_cnt -= |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5221 | (unsigned long)segp->segbytes; |
| 5222 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5223 | break; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5224 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5226 | if (remain_cnt < 0x01000000L) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5227 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5228 | pCurrSCCB->Sccb_SGoffset = remain_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5229 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5230 | pCurrSCCB->Sccb_sgseg = (unsigned short)sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5231 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5232 | if ((unsigned long)(sg_ptr * SG_ELEMENT_SIZE) == |
| 5233 | pCurrSCCB->DataLength && (remain_cnt == 0)) |
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 | pCurrSCCB->Sccb_XferState |= |
| 5236 | F_ALL_XFERRED; |
| 5237 | } |
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 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5240 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5241 | if (pCurrSCCB->HostStatus == 0x00) { |
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 | pCurrSCCB->HostStatus = |
| 5244 | SCCB_GROSS_FW_ERR; |
| 5245 | } |
| 5246 | } |
| 5247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5248 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5249 | if (!(pCurrSCCB->Sccb_XferState & F_HOST_XFER_DIR)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5250 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5251 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5252 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5253 | FPT_busMstrTimeOut(port); |
| 5254 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5255 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5256 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5257 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5258 | if (RD_HARPOON(port + hp_int_status) & |
| 5259 | INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5260 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5261 | if (RD_HARPOON(port + hp_ext_status) & |
| 5262 | BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5263 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5264 | if (pCurrSCCB->HostStatus == |
| 5265 | 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5266 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5267 | pCurrSCCB->HostStatus = |
| 5268 | SCCB_BM_ERR; |
| 5269 | } |
| 5270 | } |
| 5271 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5272 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5273 | } |
| 5274 | } |
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 | else { |
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 ((RD_HARPOON(port + hp_fifo_cnt)) >= BM_THRESHOLD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5279 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5280 | timeout = SHORT_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5281 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5282 | while ((RD_HARPOON(port + hp_ext_status) & |
| 5283 | BM_CMD_BUSY) |
| 5284 | && ((RD_HARPOON(port + hp_fifo_cnt)) >= |
| 5285 | BM_THRESHOLD) && timeout--) { |
| 5286 | } |
| 5287 | } |
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 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5290 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5291 | WR_HARPOON(port + hp_bm_ctrl, |
| 5292 | (RD_HARPOON(port + hp_bm_ctrl) | |
| 5293 | FLUSH_XFER_CNTR)); |
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 | timeout = LONG_WAIT; |
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 | while ((RD_HARPOON(port + hp_ext_status) & |
| 5298 | BM_CMD_BUSY) && timeout--) { |
| 5299 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5300 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5301 | WR_HARPOON(port + hp_bm_ctrl, |
| 5302 | (RD_HARPOON(port + hp_bm_ctrl) & |
| 5303 | ~FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5304 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5305 | if (RD_HARPOON(port + hp_ext_status) & |
| 5306 | BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5308 | if (pCurrSCCB->HostStatus == 0x00) { |
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 | pCurrSCCB->HostStatus = |
| 5311 | SCCB_BM_ERR; |
| 5312 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5313 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5314 | FPT_busMstrTimeOut(port); |
| 5315 | } |
| 5316 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5317 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5318 | if (RD_HARPOON(port + hp_int_status) & INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5319 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5320 | if (RD_HARPOON(port + hp_ext_status) & |
| 5321 | BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5322 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5323 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5324 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5325 | pCurrSCCB->HostStatus = |
| 5326 | SCCB_BM_ERR; |
| 5327 | } |
| 5328 | } |
| 5329 | } |
| 5330 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5331 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5332 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5333 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5334 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5335 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5336 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5337 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5338 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5339 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5340 | while ((RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) |
| 5341 | && timeout--) { |
| 5342 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5343 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5344 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5345 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5346 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5347 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5348 | pCurrSCCB->HostStatus = SCCB_BM_ERR; |
| 5349 | } |
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 | FPT_busMstrTimeOut(port); |
| 5352 | } |
| 5353 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5354 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5355 | if (RD_HARPOON(port + hp_int_status) & INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5356 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5357 | if (RD_HARPOON(port + hp_ext_status) & BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5358 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5359 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5360 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5361 | pCurrSCCB->HostStatus = SCCB_BM_ERR; |
| 5362 | } |
| 5363 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5364 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5365 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5366 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5367 | if (pCurrSCCB->Sccb_XferState & F_SG_XFER) { |
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 | WR_HARPOON(port + hp_page_ctrl, |
| 5370 | (RD_HARPOON(port + hp_page_ctrl) & |
| 5371 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5372 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5373 | WR_HARPOON(port + hp_sg_addr, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5375 | pCurrSCCB->Sccb_sgseg += SG_BUF_CNT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5376 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5377 | pCurrSCCB->Sccb_SGoffset = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5378 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5379 | if ((u32)(pCurrSCCB->Sccb_sgseg * SG_ELEMENT_SIZE) >= |
| 5380 | pCurrSCCB->DataLength) { |
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 | pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5383 | pCurrSCCB->Sccb_sgseg = |
| 5384 | (unsigned short)(pCurrSCCB->DataLength / |
| 5385 | SG_ELEMENT_SIZE); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5386 | } |
| 5387 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5388 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5389 | else { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5390 | if (!(pCurrSCCB->Sccb_XferState & F_AUTO_SENSE)) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5391 | pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED; |
| 5392 | } |
| 5393 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5394 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5395 | WR_HARPOON(port + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5396 | } |
| 5397 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5398 | /*--------------------------------------------------------------------- |
| 5399 | * |
| 5400 | * Function: Host Data Transfer Restart |
| 5401 | * |
| 5402 | * Description: Reset the available count due to a restore data |
| 5403 | * pointers message. |
| 5404 | * |
| 5405 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5406 | static void FPT_hostDataXferRestart(struct sccb *currSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5407 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5408 | unsigned long data_count; |
| 5409 | unsigned int sg_index; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5410 | struct blogic_sg_seg *segp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5412 | if (currSCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5413 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5414 | currSCCB->Sccb_XferCnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5415 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5416 | sg_index = 0xffff; /*Index by long words into sg list. */ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5417 | data_count = 0; /*Running count of SG xfer counts. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5420 | while (data_count < currSCCB->Sccb_ATC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5421 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5422 | sg_index++; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5423 | segp = (struct blogic_sg_seg *)(currSCCB->DataPointer) + |
| 5424 | (sg_index * 2); |
| 5425 | data_count += segp->segbytes; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5426 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5427 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5428 | if (data_count == currSCCB->Sccb_ATC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5430 | currSCCB->Sccb_SGoffset = 0; |
| 5431 | sg_index++; |
| 5432 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5433 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5434 | else { |
| 5435 | currSCCB->Sccb_SGoffset = |
| 5436 | data_count - currSCCB->Sccb_ATC; |
| 5437 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5439 | currSCCB->Sccb_sgseg = (unsigned short)sg_index; |
| 5440 | } |
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 | else { |
| 5443 | currSCCB->Sccb_XferCnt = |
| 5444 | currSCCB->DataLength - currSCCB->Sccb_ATC; |
| 5445 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5446 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5448 | /*--------------------------------------------------------------------- |
| 5449 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5450 | * Function: FPT_scini |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5451 | * |
| 5452 | * Description: Setup all data structures necessary for SCAM selection. |
| 5453 | * |
| 5454 | *---------------------------------------------------------------------*/ |
| 5455 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5456 | static void FPT_scini(unsigned char p_card, unsigned char p_our_id, |
| 5457 | unsigned char p_power_up) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5458 | { |
| 5459 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5460 | unsigned char loser, assigned_id; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5461 | u32 p_port; |
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 | unsigned char i, k, ScamFlg; |
| 5464 | struct sccb_card *currCard; |
| 5465 | struct nvram_info *pCurrNvRam; |
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 | currCard = &FPT_BL_Card[p_card]; |
| 5468 | p_port = currCard->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5469 | pCurrNvRam = currCard->pNvRamInfo; |
| 5470 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5471 | if (pCurrNvRam) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5472 | ScamFlg = pCurrNvRam->niScamConf; |
| 5473 | i = pCurrNvRam->niSysConf; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5474 | } else { |
| 5475 | ScamFlg = |
| 5476 | (unsigned char)FPT_utilEERead(p_port, SCAM_CONFIG / 2); |
| 5477 | i = (unsigned |
| 5478 | char)(FPT_utilEERead(p_port, (SYSTEM_CONFIG / 2))); |
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 | if (!(i & 0x02)) /* check if reset bus in AutoSCSI parameter set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5481 | return; |
| 5482 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5483 | FPT_inisci(p_card, p_port, p_our_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5484 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5485 | /* Force to wait 1 sec after SCSI bus reset. Some SCAM device FW |
| 5486 | too slow to return to SCAM selection */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5487 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5488 | /* if (p_power_up) |
| 5489 | FPT_Wait1Second(p_port); |
| 5490 | else |
| 5491 | FPT_Wait(p_port, TO_250ms); */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5492 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5493 | FPT_Wait1Second(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5494 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5495 | if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2)) { |
| 5496 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5497 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5498 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5499 | FPT_scsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5500 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5501 | do { |
| 5502 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5503 | FPT_scxferc(p_port, DOM_MSTR); |
| 5504 | loser = |
| 5505 | FPT_scsendi(p_port, |
| 5506 | &FPT_scamInfo[p_our_id].id_string[0]); |
| 5507 | } while (loser == 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5508 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5509 | FPT_scbusf(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5510 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5511 | if ((p_power_up) && (!loser)) { |
| 5512 | FPT_sresb(p_port, p_card); |
| 5513 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5514 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5515 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5516 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5517 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5518 | FPT_scsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5519 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5520 | do { |
| 5521 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5522 | FPT_scxferc(p_port, DOM_MSTR); |
| 5523 | loser = |
| 5524 | FPT_scsendi(p_port, |
| 5525 | &FPT_scamInfo[p_our_id]. |
| 5526 | id_string[0]); |
| 5527 | } while (loser == 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5528 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5529 | FPT_scbusf(p_port); |
| 5530 | } |
| 5531 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5532 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5533 | else { |
| 5534 | loser = 0; |
| 5535 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5537 | if (!loser) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5538 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5539 | FPT_scamInfo[p_our_id].state = ID_ASSIGNED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5540 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5541 | if (ScamFlg & SCAM_ENABLED) { |
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 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 5544 | if ((FPT_scamInfo[i].state == ID_UNASSIGNED) || |
| 5545 | (FPT_scamInfo[i].state == ID_UNUSED)) { |
| 5546 | if (FPT_scsell(p_port, i)) { |
| 5547 | FPT_scamInfo[i].state = LEGACY; |
| 5548 | if ((FPT_scamInfo[i]. |
| 5549 | id_string[0] != 0xFF) |
| 5550 | || (FPT_scamInfo[i]. |
| 5551 | id_string[1] != 0xFA)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5552 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5553 | FPT_scamInfo[i]. |
| 5554 | id_string[0] = 0xFF; |
| 5555 | FPT_scamInfo[i]. |
| 5556 | id_string[1] = 0xFA; |
| 5557 | if (pCurrNvRam == NULL) |
| 5558 | currCard-> |
| 5559 | globalFlags |
| 5560 | |= |
| 5561 | F_UPDATE_EEPROM; |
| 5562 | } |
| 5563 | } |
| 5564 | } |
| 5565 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5566 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5567 | FPT_sresb(p_port, p_card); |
| 5568 | FPT_Wait1Second(p_port); |
| 5569 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5570 | } |
| 5571 | FPT_scsel(p_port); |
| 5572 | FPT_scasid(p_card, p_port); |
| 5573 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5574 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5575 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5576 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5577 | else if ((loser) && (ScamFlg & SCAM_ENABLED)) { |
| 5578 | FPT_scamInfo[p_our_id].id_string[0] = SLV_TYPE_CODE0; |
| 5579 | assigned_id = 0; |
| 5580 | FPT_scwtsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5581 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5582 | do { |
| 5583 | while (FPT_scxferc(p_port, 0x00) != SYNC_PTRN) { |
| 5584 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5585 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5586 | i = FPT_scxferc(p_port, 0x00); |
| 5587 | if (i == ASSIGN_ID) { |
| 5588 | if (! |
| 5589 | (FPT_scsendi |
| 5590 | (p_port, |
| 5591 | &FPT_scamInfo[p_our_id].id_string[0]))) { |
| 5592 | i = FPT_scxferc(p_port, 0x00); |
| 5593 | if (FPT_scvalq(i)) { |
| 5594 | k = FPT_scxferc(p_port, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5595 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5596 | if (FPT_scvalq(k)) { |
| 5597 | currCard->ourId = |
| 5598 | ((unsigned char)(i |
| 5599 | << |
| 5600 | 3) |
| 5601 | + |
| 5602 | (k & |
| 5603 | (unsigned char)7)) |
| 5604 | & (unsigned char) |
| 5605 | 0x3F; |
| 5606 | FPT_inisci(p_card, |
| 5607 | p_port, |
| 5608 | p_our_id); |
| 5609 | FPT_scamInfo[currCard-> |
| 5610 | ourId]. |
| 5611 | state = ID_ASSIGNED; |
| 5612 | FPT_scamInfo[currCard-> |
| 5613 | ourId]. |
| 5614 | id_string[0] |
| 5615 | = SLV_TYPE_CODE0; |
| 5616 | assigned_id = 1; |
| 5617 | } |
| 5618 | } |
| 5619 | } |
| 5620 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5621 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5622 | else if (i == SET_P_FLAG) { |
| 5623 | if (!(FPT_scsendi(p_port, |
| 5624 | &FPT_scamInfo[p_our_id]. |
| 5625 | id_string[0]))) |
| 5626 | FPT_scamInfo[p_our_id].id_string[0] |= |
| 5627 | 0x80; |
| 5628 | } |
| 5629 | } while (!assigned_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5630 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5631 | while (FPT_scxferc(p_port, 0x00) != CFG_CMPLT) { |
| 5632 | } |
| 5633 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5634 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5635 | if (ScamFlg & SCAM_ENABLED) { |
| 5636 | FPT_scbusf(p_port); |
| 5637 | if (currCard->globalFlags & F_UPDATE_EEPROM) { |
| 5638 | FPT_scsavdi(p_card, p_port); |
| 5639 | currCard->globalFlags &= ~F_UPDATE_EEPROM; |
| 5640 | } |
| 5641 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5642 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5643 | /* |
| 5644 | for (i=0,k=0; i < MAX_SCSI_TAR; i++) |
| 5645 | { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5646 | if ((FPT_scamInfo[i].state == ID_ASSIGNED) || |
| 5647 | (FPT_scamInfo[i].state == LEGACY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5648 | k++; |
| 5649 | } |
| 5650 | |
| 5651 | if (k==2) |
| 5652 | currCard->globalFlags |= F_SINGLE_DEVICE; |
| 5653 | else |
| 5654 | currCard->globalFlags &= ~F_SINGLE_DEVICE; |
| 5655 | */ |
| 5656 | } |
| 5657 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5658 | /*--------------------------------------------------------------------- |
| 5659 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5660 | * Function: FPT_scarb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5661 | * |
| 5662 | * Description: Gain control of the bus and wait SCAM select time (250ms) |
| 5663 | * |
| 5664 | *---------------------------------------------------------------------*/ |
| 5665 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5666 | static int FPT_scarb(u32 p_port, unsigned char p_sel_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5667 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5668 | if (p_sel_type == INIT_SELTD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5669 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5670 | while (RD_HARPOON(p_port + hp_scsisig) & (SCSI_SEL | SCSI_BSY)) { |
| 5671 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5672 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5673 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_SEL) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5674 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5675 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5676 | if (RD_HARPOON(p_port + hp_scsidata_0) != 00) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5677 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5678 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5679 | WR_HARPOON(p_port + hp_scsisig, |
| 5680 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5681 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5682 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_SEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5683 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5684 | WR_HARPOON(p_port + hp_scsisig, |
| 5685 | (RD_HARPOON(p_port + hp_scsisig) & |
| 5686 | ~SCSI_BSY)); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5687 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5688 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5689 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5690 | WR_HARPOON(p_port + hp_scsisig, |
| 5691 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5692 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5693 | if (RD_HARPOON(p_port + hp_scsidata_0) != 00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5694 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5695 | WR_HARPOON(p_port + hp_scsisig, |
| 5696 | (RD_HARPOON(p_port + hp_scsisig) & |
| 5697 | ~(SCSI_BSY | SCSI_SEL))); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5698 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5699 | } |
| 5700 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5701 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5702 | WR_HARPOON(p_port + hp_clkctrl_0, (RD_HARPOON(p_port + hp_clkctrl_0) |
| 5703 | & ~ACTdeassert)); |
| 5704 | WR_HARPOON(p_port + hp_scsireset, SCAM_EN); |
| 5705 | WR_HARPOON(p_port + hp_scsidata_0, 0x00); |
| 5706 | WR_HARPOON(p_port + hp_scsidata_1, 0x00); |
| 5707 | WR_HARPOON(p_port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5708 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5709 | WR_HARPOON(p_port + hp_scsisig, |
| 5710 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_MSG)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5711 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5712 | WR_HARPOON(p_port + hp_scsisig, (RD_HARPOON(p_port + hp_scsisig) |
| 5713 | & ~SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5714 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5715 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5716 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5717 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5718 | } |
| 5719 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5720 | /*--------------------------------------------------------------------- |
| 5721 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5722 | * Function: FPT_scbusf |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5723 | * |
| 5724 | * Description: Release the SCSI bus and disable SCAM selection. |
| 5725 | * |
| 5726 | *---------------------------------------------------------------------*/ |
| 5727 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5728 | static void FPT_scbusf(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5729 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5730 | WR_HARPOON(p_port + hp_page_ctrl, |
| 5731 | (RD_HARPOON(p_port + hp_page_ctrl) | G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5732 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5733 | WR_HARPOON(p_port + hp_scsidata_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5734 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5735 | WR_HARPOON(p_port + hp_portctrl_0, (RD_HARPOON(p_port + hp_portctrl_0) |
| 5736 | & ~SCSI_BUS_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5737 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5738 | WR_HARPOON(p_port + hp_scsisig, 0x00); |
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_scsireset, (RD_HARPOON(p_port + hp_scsireset) |
| 5741 | & ~SCAM_EN)); |
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 | WR_HARPOON(p_port + hp_clkctrl_0, (RD_HARPOON(p_port + hp_clkctrl_0) |
| 5744 | | ACTdeassert)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5745 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5746 | WRW_HARPOON((p_port + hp_intstat), (BUS_FREE | AUTO_INT | SCAM_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5747 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5748 | WR_HARPOON(p_port + hp_page_ctrl, |
| 5749 | (RD_HARPOON(p_port + hp_page_ctrl) & ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5750 | } |
| 5751 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5752 | /*--------------------------------------------------------------------- |
| 5753 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5754 | * Function: FPT_scasid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5755 | * |
| 5756 | * Description: Assign an ID to all the SCAM devices. |
| 5757 | * |
| 5758 | *---------------------------------------------------------------------*/ |
| 5759 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5760 | static void FPT_scasid(unsigned char p_card, u32 p_port) |
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 | unsigned char temp_id_string[ID_STRING_LENGTH]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5763 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5764 | unsigned char i, k, scam_id; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 5765 | unsigned char crcBytes[3]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5766 | struct nvram_info *pCurrNvRam; |
| 5767 | unsigned short *pCrcBytes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5768 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5769 | pCurrNvRam = FPT_BL_Card[p_card].pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5770 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5771 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5772 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5773 | while (!i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5774 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5775 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 5776 | temp_id_string[k] = (unsigned char)0x00; |
| 5777 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5778 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5779 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5780 | FPT_scxferc(p_port, ASSIGN_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5781 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5782 | if (!(FPT_sciso(p_port, &temp_id_string[0]))) { |
| 5783 | if (pCurrNvRam) { |
Alexey Dobriyan | fd1e29e | 2006-03-08 00:14:27 -0800 | [diff] [blame] | 5784 | pCrcBytes = (unsigned short *)&crcBytes[0]; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5785 | *pCrcBytes = FPT_CalcCrc16(&temp_id_string[0]); |
| 5786 | crcBytes[2] = FPT_CalcLrc(&temp_id_string[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5787 | temp_id_string[1] = crcBytes[2]; |
| 5788 | temp_id_string[2] = crcBytes[0]; |
| 5789 | temp_id_string[3] = crcBytes[1]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5790 | for (k = 4; k < ID_STRING_LENGTH; k++) |
| 5791 | temp_id_string[k] = (unsigned char)0x00; |
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 | i = FPT_scmachid(p_card, temp_id_string); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5794 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5795 | if (i == CLR_PRIORITY) { |
| 5796 | FPT_scxferc(p_port, MISC_CODE); |
| 5797 | FPT_scxferc(p_port, CLR_P_FLAG); |
| 5798 | i = 0; /*Not the last ID yet. */ |
| 5799 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5800 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5801 | else if (i != NO_ID_AVAIL) { |
| 5802 | if (i < 8) |
| 5803 | FPT_scxferc(p_port, ID_0_7); |
| 5804 | else |
| 5805 | FPT_scxferc(p_port, ID_8_F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5806 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5807 | scam_id = (i & (unsigned char)0x07); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5808 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5809 | for (k = 1; k < 0x08; k <<= 1) |
| 5810 | if (!(k & i)) |
| 5811 | scam_id += 0x08; /*Count number of zeros in DB0-3. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5812 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5813 | FPT_scxferc(p_port, scam_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5814 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5815 | i = 0; /*Not the last ID yet. */ |
| 5816 | } |
| 5817 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5818 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5819 | else { |
| 5820 | i = 1; |
| 5821 | } |
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 | } /*End while */ |
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 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5826 | FPT_scxferc(p_port, CFG_CMPLT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5827 | } |
| 5828 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5829 | /*--------------------------------------------------------------------- |
| 5830 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5831 | * Function: FPT_scsel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5832 | * |
| 5833 | * Description: Select all the SCAM devices. |
| 5834 | * |
| 5835 | *---------------------------------------------------------------------*/ |
| 5836 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5837 | static void FPT_scsel(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5838 | { |
| 5839 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5840 | WR_HARPOON(p_port + hp_scsisig, SCSI_SEL); |
| 5841 | FPT_scwiros(p_port, SCSI_MSG); |
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 | WR_HARPOON(p_port + hp_scsisig, (SCSI_SEL | SCSI_BSY)); |
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 | WR_HARPOON(p_port + hp_scsisig, |
| 5846 | (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
| 5847 | WR_HARPOON(p_port + hp_scsidata_0, |
| 5848 | (unsigned char)(RD_HARPOON(p_port + hp_scsidata_0) | |
| 5849 | (unsigned char)(BIT(7) + BIT(6)))); |
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 | WR_HARPOON(p_port + hp_scsisig, (SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
| 5852 | FPT_scwiros(p_port, SCSI_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5853 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5854 | WR_HARPOON(p_port + hp_scsidata_0, |
| 5855 | (unsigned char)(RD_HARPOON(p_port + hp_scsidata_0) & |
| 5856 | ~(unsigned char)BIT(6))); |
| 5857 | FPT_scwirod(p_port, BIT(6)); |
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 | WR_HARPOON(p_port + hp_scsisig, |
| 5860 | (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5861 | } |
| 5862 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5863 | /*--------------------------------------------------------------------- |
| 5864 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5865 | * Function: FPT_scxferc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5866 | * |
| 5867 | * Description: Handshake the p_data (DB4-0) across the bus. |
| 5868 | * |
| 5869 | *---------------------------------------------------------------------*/ |
| 5870 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5871 | static unsigned char FPT_scxferc(u32 p_port, unsigned char p_data) |
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 | unsigned char curr_data, ret_data; |
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 | 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] | 5876 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5877 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5878 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5879 | curr_data &= ~BIT(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5880 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5881 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5882 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5883 | FPT_scwirod(p_port, BIT(7)); /*Wait for DB7 to be released. */ |
| 5884 | while (!(RD_HARPOON(p_port + hp_scsidata_0) & BIT(5))) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5885 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5886 | ret_data = (RD_HARPOON(p_port + hp_scsidata_0) & (unsigned char)0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5887 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5888 | curr_data |= BIT(6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5889 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5890 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5891 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5892 | curr_data &= ~BIT(5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5893 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5894 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5895 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5896 | FPT_scwirod(p_port, BIT(5)); /*Wait for DB5 to be released. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5897 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5898 | curr_data &= ~(BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0)); /*Release data bits */ |
| 5899 | curr_data |= BIT(7); |
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_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5902 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5903 | curr_data &= ~BIT(6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5904 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5905 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5906 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5907 | FPT_scwirod(p_port, BIT(6)); /*Wait for DB6 to be released. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5908 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5909 | return ret_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5910 | } |
| 5911 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5912 | /*--------------------------------------------------------------------- |
| 5913 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5914 | * Function: FPT_scsendi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5915 | * |
| 5916 | * Description: Transfer our Identification string to determine if we |
| 5917 | * will be the dominant master. |
| 5918 | * |
| 5919 | *---------------------------------------------------------------------*/ |
| 5920 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5921 | static unsigned char FPT_scsendi(u32 p_port, unsigned char p_id_string[]) |
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 ret_data, byte_cnt, bit_cnt, defer; |
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 | defer = 0; |
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 | for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) { |
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 | for (bit_cnt = 0x80; bit_cnt != 0; bit_cnt >>= 1) { |
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 | if (defer) |
| 5932 | ret_data = FPT_scxferc(p_port, 00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5933 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5934 | else if (p_id_string[byte_cnt] & bit_cnt) |
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 = FPT_scxferc(p_port, 02); |
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 | else { |
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 | ret_data = FPT_scxferc(p_port, 01); |
| 5941 | if (ret_data & 02) |
| 5942 | defer = 1; |
| 5943 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5944 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5945 | if ((ret_data & 0x1C) == 0x10) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5946 | return 0x00; /*End of isolation stage, we won! */ |
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 | if (ret_data & 0x1C) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5949 | return 0xFF; |
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 | if ((defer) && (!(ret_data & 0x1F))) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5952 | return 0x01; /*End of isolation stage, we lost. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5953 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5954 | } /*bit loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5955 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5956 | } /*byte loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5957 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5958 | if (defer) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5959 | return 0x01; /*We lost */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5960 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5961 | return 0; /*We WON! Yeeessss! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5962 | } |
| 5963 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5964 | /*--------------------------------------------------------------------- |
| 5965 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5966 | * Function: FPT_sciso |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5967 | * |
| 5968 | * Description: Transfer the Identification string. |
| 5969 | * |
| 5970 | *---------------------------------------------------------------------*/ |
| 5971 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5972 | static unsigned char FPT_sciso(u32 p_port, 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, the_data, byte_cnt, bit_cnt; |
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 | the_data = 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 = 0; bit_cnt < 8; bit_cnt++) { |
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 | ret_data = FPT_scxferc(p_port, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5983 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5984 | if (ret_data & 0xFC) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5985 | return 0xFF; |
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 | else { |
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 | the_data <<= 1; |
| 5990 | if (ret_data & BIT(1)) { |
| 5991 | the_data |= 1; |
| 5992 | } |
| 5993 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5994 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5995 | if ((ret_data & 0x1F) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5996 | /* |
| 5997 | if(bit_cnt != 0 || bit_cnt != 8) |
| 5998 | { |
| 5999 | byte_cnt = 0; |
| 6000 | bit_cnt = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6001 | FPT_scxferc(p_port, SYNC_PTRN); |
| 6002 | FPT_scxferc(p_port, ASSIGN_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6003 | continue; |
| 6004 | } |
| 6005 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6006 | if (byte_cnt) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6007 | return 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6008 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6009 | return 0xFF; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6010 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6011 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6012 | } /*bit loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6013 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6014 | p_id_string[byte_cnt] = the_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6015 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6016 | } /*byte loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6017 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6018 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6019 | } |
| 6020 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6021 | /*--------------------------------------------------------------------- |
| 6022 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6023 | * Function: FPT_scwirod |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6024 | * |
| 6025 | * Description: Sample the SCSI data bus making sure the signal has been |
| 6026 | * deasserted for the correct number of consecutive samples. |
| 6027 | * |
| 6028 | *---------------------------------------------------------------------*/ |
| 6029 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6030 | static void FPT_scwirod(u32 p_port, unsigned char p_data_bit) |
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 | unsigned char i; |
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 | i = 0; |
| 6035 | while (i < MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6036 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6037 | if (RD_HARPOON(p_port + hp_scsidata_0) & p_data_bit) |
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 | i = 0; |
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 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6043 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6044 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6045 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6046 | } |
| 6047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6048 | /*--------------------------------------------------------------------- |
| 6049 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6050 | * Function: FPT_scwiros |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6051 | * |
| 6052 | * Description: Sample the SCSI Signal lines making sure the signal has been |
| 6053 | * deasserted for the correct number of consecutive samples. |
| 6054 | * |
| 6055 | *---------------------------------------------------------------------*/ |
| 6056 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6057 | static void FPT_scwiros(u32 p_port, unsigned char p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6058 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6059 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6060 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6061 | i = 0; |
| 6062 | while (i < MAX_SCSI_TAR) { |
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 | if (RD_HARPOON(p_port + hp_scsisig) & p_data_bit) |
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 | i = 0; |
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 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6069 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6070 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6071 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6072 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6073 | } |
| 6074 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6075 | /*--------------------------------------------------------------------- |
| 6076 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6077 | * Function: FPT_scvalq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6078 | * |
| 6079 | * Description: Make sure we received a valid data byte. |
| 6080 | * |
| 6081 | *---------------------------------------------------------------------*/ |
| 6082 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 6083 | static unsigned char FPT_scvalq(unsigned char p_quintet) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6084 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6085 | unsigned char count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6086 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6087 | for (count = 1; count < 0x08; count <<= 1) { |
| 6088 | if (!(p_quintet & count)) |
| 6089 | p_quintet -= 0x80; |
| 6090 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6091 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6092 | if (p_quintet & 0x18) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6093 | return 0; |
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 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6096 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6097 | } |
| 6098 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6099 | /*--------------------------------------------------------------------- |
| 6100 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6101 | * Function: FPT_scsell |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6102 | * |
| 6103 | * Description: Select the specified device ID using a selection timeout |
| 6104 | * less than 4ms. If somebody responds then it is a legacy |
| 6105 | * drive and this ID must be marked as such. |
| 6106 | * |
| 6107 | *---------------------------------------------------------------------*/ |
| 6108 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6109 | static unsigned char FPT_scsell(u32 p_port, unsigned char targ_id) |
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 long 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 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6114 | (RD_HARPOON(p_port + hp_page_ctrl) | G_INT_DISABLE)); |
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 | ARAM_ACCESS(p_port); |
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 | WR_HARPOON(p_port + hp_addstat, |
| 6119 | (RD_HARPOON(p_port + hp_addstat) | SCAM_TIMER)); |
| 6120 | WR_HARPOON(p_port + hp_seltimeout, TO_4ms); |
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 | for (i = p_port + CMD_STRT; i < p_port + CMD_STRT + 12; i += 2) { |
| 6123 | WRW_HARPOON(i, (MPM_OP + ACOMMAND)); |
| 6124 | } |
| 6125 | WRW_HARPOON(i, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6126 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6127 | WRW_HARPOON((p_port + hp_intstat), |
| 6128 | (RESET | TIMEOUT | SEL | BUS_FREE | AUTO_INT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6129 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6130 | WR_HARPOON(p_port + hp_select_id, targ_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6131 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6132 | WR_HARPOON(p_port + hp_portctrl_0, SCSI_PORT); |
| 6133 | WR_HARPOON(p_port + hp_autostart_3, (SELECT | CMD_ONLY_STRT)); |
| 6134 | WR_HARPOON(p_port + hp_scsictrl_0, (SEL_TAR | ENA_RESEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6135 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6136 | while (!(RDW_HARPOON((p_port + hp_intstat)) & |
| 6137 | (RESET | PROG_HLT | TIMEOUT | AUTO_INT))) { |
| 6138 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6139 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6140 | if (RDW_HARPOON((p_port + hp_intstat)) & RESET) |
| 6141 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6142 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6143 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6144 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6145 | WR_HARPOON(p_port + hp_addstat, |
| 6146 | (RD_HARPOON(p_port + hp_addstat) & ~SCAM_TIMER)); |
| 6147 | WR_HARPOON(p_port + hp_seltimeout, TO_290ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6148 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6149 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6150 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6151 | if (RDW_HARPOON((p_port + hp_intstat)) & (RESET | TIMEOUT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6152 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6153 | WRW_HARPOON((p_port + hp_intstat), |
| 6154 | (RESET | TIMEOUT | SEL | BUS_FREE | PHASE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6155 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6156 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6157 | (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6158 | ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6159 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6160 | return 0; /*No legacy device */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6161 | } |
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 | else { |
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 | while (!(RDW_HARPOON((p_port + hp_intstat)) & BUS_FREE)) { |
| 6166 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_REQ) { |
| 6167 | WR_HARPOON(p_port + hp_scsisig, |
| 6168 | (SCSI_ACK + S_ILL_PH)); |
| 6169 | ACCEPT_MSG(p_port); |
| 6170 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6171 | } |
| 6172 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6173 | WRW_HARPOON((p_port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6174 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6175 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6176 | (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6177 | ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6178 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6179 | return 1; /*Found one of them oldies! */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6180 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6181 | } |
| 6182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6183 | /*--------------------------------------------------------------------- |
| 6184 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6185 | * Function: FPT_scwtsel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6186 | * |
| 6187 | * Description: Wait to be selected by another SCAM initiator. |
| 6188 | * |
| 6189 | *---------------------------------------------------------------------*/ |
| 6190 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6191 | static void FPT_scwtsel(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6192 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6193 | while (!(RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) { |
| 6194 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6195 | } |
| 6196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6197 | /*--------------------------------------------------------------------- |
| 6198 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6199 | * Function: FPT_inisci |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6200 | * |
| 6201 | * Description: Setup the data Structure with the info from the EEPROM. |
| 6202 | * |
| 6203 | *---------------------------------------------------------------------*/ |
| 6204 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6205 | static void FPT_inisci(unsigned char p_card, u32 p_port, unsigned char p_our_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6206 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6207 | unsigned char i, k, max_id; |
| 6208 | unsigned short ee_data; |
| 6209 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6210 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6211 | pCurrNvRam = FPT_BL_Card[p_card].pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6212 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6213 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6214 | max_id = 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6215 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6216 | else |
| 6217 | max_id = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6218 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6219 | if (pCurrNvRam) { |
| 6220 | for (i = 0; i < max_id; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6221 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6222 | for (k = 0; k < 4; k++) |
| 6223 | FPT_scamInfo[i].id_string[k] = |
| 6224 | pCurrNvRam->niScamTbl[i][k]; |
| 6225 | for (k = 4; k < ID_STRING_LENGTH; k++) |
| 6226 | FPT_scamInfo[i].id_string[k] = |
| 6227 | (unsigned char)0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6228 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6229 | if (FPT_scamInfo[i].id_string[0] == 0x00) |
| 6230 | FPT_scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */ |
| 6231 | else |
| 6232 | FPT_scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6233 | |
| 6234 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6235 | } else { |
| 6236 | for (i = 0; i < max_id; i++) { |
| 6237 | for (k = 0; k < ID_STRING_LENGTH; k += 2) { |
| 6238 | ee_data = |
| 6239 | FPT_utilEERead(p_port, |
| 6240 | (unsigned |
| 6241 | short)((EE_SCAMBASE / 2) + |
| 6242 | (unsigned short)(i * |
| 6243 | ((unsigned short)ID_STRING_LENGTH / 2)) + (unsigned short)(k / 2))); |
| 6244 | FPT_scamInfo[i].id_string[k] = |
| 6245 | (unsigned char)ee_data; |
| 6246 | ee_data >>= 8; |
| 6247 | FPT_scamInfo[i].id_string[k + 1] = |
| 6248 | (unsigned char)ee_data; |
| 6249 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6250 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6251 | if ((FPT_scamInfo[i].id_string[0] == 0x00) || |
| 6252 | (FPT_scamInfo[i].id_string[0] == 0xFF)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6253 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6254 | FPT_scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6255 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6256 | else |
| 6257 | FPT_scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6258 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6259 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6260 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6261 | for (k = 0; k < ID_STRING_LENGTH; k++) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6262 | FPT_scamInfo[p_our_id].id_string[k] = FPT_scamHAString[k]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6263 | |
| 6264 | } |
| 6265 | |
| 6266 | /*--------------------------------------------------------------------- |
| 6267 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6268 | * Function: FPT_scmachid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6269 | * |
| 6270 | * Description: Match the Device ID string with our values stored in |
| 6271 | * the EEPROM. |
| 6272 | * |
| 6273 | *---------------------------------------------------------------------*/ |
| 6274 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6275 | static unsigned char FPT_scmachid(unsigned char p_card, |
| 6276 | unsigned char p_id_string[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6277 | { |
| 6278 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6279 | unsigned char i, k, match; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6280 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6281 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6282 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6283 | match = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6284 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6285 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6286 | if (p_id_string[k] != FPT_scamInfo[i].id_string[k]) |
| 6287 | match = 0; |
| 6288 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6289 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6290 | if (match) { |
| 6291 | FPT_scamInfo[i].state = ID_ASSIGNED; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6292 | return i; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6293 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6294 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6295 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6296 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6297 | if (p_id_string[0] & BIT(5)) |
| 6298 | i = 8; |
| 6299 | else |
| 6300 | i = MAX_SCSI_TAR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6301 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6302 | if (((p_id_string[0] & 0x06) == 0x02) |
| 6303 | || ((p_id_string[0] & 0x06) == 0x04)) |
| 6304 | match = p_id_string[1] & (unsigned char)0x1F; |
| 6305 | else |
| 6306 | match = 7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6308 | while (i > 0) { |
| 6309 | i--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6310 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6311 | if (FPT_scamInfo[match].state == ID_UNUSED) { |
| 6312 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6313 | FPT_scamInfo[match].id_string[k] = |
| 6314 | p_id_string[k]; |
| 6315 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6316 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6317 | FPT_scamInfo[match].state = ID_ASSIGNED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6318 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6319 | if (FPT_BL_Card[p_card].pNvRamInfo == NULL) |
| 6320 | FPT_BL_Card[p_card].globalFlags |= |
| 6321 | F_UPDATE_EEPROM; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6322 | return match; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6323 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6324 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6325 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6326 | match--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6327 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6328 | if (match == 0xFF) { |
| 6329 | if (p_id_string[0] & BIT(5)) |
| 6330 | match = 7; |
| 6331 | else |
| 6332 | match = MAX_SCSI_TAR - 1; |
| 6333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6334 | } |
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 | if (p_id_string[0] & BIT(7)) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6337 | return CLR_PRIORITY; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6338 | } |
| 6339 | |
| 6340 | if (p_id_string[0] & BIT(5)) |
| 6341 | i = 8; |
| 6342 | else |
| 6343 | i = MAX_SCSI_TAR; |
| 6344 | |
| 6345 | if (((p_id_string[0] & 0x06) == 0x02) |
| 6346 | || ((p_id_string[0] & 0x06) == 0x04)) |
| 6347 | match = p_id_string[1] & (unsigned char)0x1F; |
| 6348 | else |
| 6349 | match = 7; |
| 6350 | |
| 6351 | while (i > 0) { |
| 6352 | |
| 6353 | i--; |
| 6354 | |
| 6355 | if (FPT_scamInfo[match].state == ID_UNASSIGNED) { |
| 6356 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6357 | FPT_scamInfo[match].id_string[k] = |
| 6358 | p_id_string[k]; |
| 6359 | } |
| 6360 | |
| 6361 | FPT_scamInfo[match].id_string[0] |= BIT(7); |
| 6362 | FPT_scamInfo[match].state = ID_ASSIGNED; |
| 6363 | if (FPT_BL_Card[p_card].pNvRamInfo == NULL) |
| 6364 | FPT_BL_Card[p_card].globalFlags |= |
| 6365 | F_UPDATE_EEPROM; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6366 | return match; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6367 | |
| 6368 | } |
| 6369 | |
| 6370 | match--; |
| 6371 | |
| 6372 | if (match == 0xFF) { |
| 6373 | if (p_id_string[0] & BIT(5)) |
| 6374 | match = 7; |
| 6375 | else |
| 6376 | match = MAX_SCSI_TAR - 1; |
| 6377 | } |
| 6378 | } |
| 6379 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6380 | return NO_ID_AVAIL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6381 | } |
| 6382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6383 | /*--------------------------------------------------------------------- |
| 6384 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6385 | * Function: FPT_scsavdi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6386 | * |
| 6387 | * Description: Save off the device SCAM ID strings. |
| 6388 | * |
| 6389 | *---------------------------------------------------------------------*/ |
| 6390 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6391 | static void FPT_scsavdi(unsigned char p_card, u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6392 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6393 | unsigned char i, k, max_id; |
| 6394 | unsigned short ee_data, sum_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6395 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6396 | sum_data = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6397 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6398 | for (i = 1; i < EE_SCAMBASE / 2; i++) { |
| 6399 | sum_data += FPT_utilEERead(p_port, i); |
| 6400 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6401 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6402 | FPT_utilEEWriteOnOff(p_port, 1); /* Enable write access to the EEPROM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6403 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6404 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6405 | max_id = 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6406 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6407 | else |
| 6408 | max_id = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6409 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6410 | for (i = 0; i < max_id; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6412 | for (k = 0; k < ID_STRING_LENGTH; k += 2) { |
| 6413 | ee_data = FPT_scamInfo[i].id_string[k + 1]; |
| 6414 | ee_data <<= 8; |
| 6415 | ee_data |= FPT_scamInfo[i].id_string[k]; |
| 6416 | sum_data += ee_data; |
| 6417 | FPT_utilEEWrite(p_port, ee_data, |
| 6418 | (unsigned short)((EE_SCAMBASE / 2) + |
| 6419 | (unsigned short)(i * |
| 6420 | ((unsigned short)ID_STRING_LENGTH / 2)) + (unsigned short)(k / 2))); |
| 6421 | } |
| 6422 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6423 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6424 | FPT_utilEEWrite(p_port, sum_data, EEPROM_CHECK_SUM / 2); |
| 6425 | FPT_utilEEWriteOnOff(p_port, 0); /* Turn off write access */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6426 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6427 | |
| 6428 | /*--------------------------------------------------------------------- |
| 6429 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6430 | * Function: FPT_XbowInit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6431 | * |
| 6432 | * Description: Setup the Xbow for normal operation. |
| 6433 | * |
| 6434 | *---------------------------------------------------------------------*/ |
| 6435 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6436 | static void FPT_XbowInit(u32 port, unsigned char ScamFlg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6437 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6438 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6439 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6440 | i = RD_HARPOON(port + hp_page_ctrl); |
| 6441 | WR_HARPOON(port + hp_page_ctrl, (unsigned char)(i | G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6442 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6443 | WR_HARPOON(port + hp_scsireset, 0x00); |
| 6444 | WR_HARPOON(port + hp_portctrl_1, HOST_MODE8); |
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 | WR_HARPOON(port + hp_scsireset, (DMA_RESET | HPSCSI_RESET | PROG_RESET | |
| 6447 | FIFO_CLR)); |
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 | WR_HARPOON(port + hp_scsireset, SCSI_INI); |
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 | WR_HARPOON(port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6452 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6453 | WR_HARPOON(port + hp_scsisig, 0x00); /* Clear any signals we might */ |
| 6454 | WR_HARPOON(port + hp_scsictrl_0, ENA_SCAM_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6455 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6456 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6457 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6458 | FPT_default_intena = RESET | RSEL | PROG_HLT | TIMEOUT | |
| 6459 | BUS_FREE | XFER_CNT_0 | AUTO_INT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6460 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6461 | if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2)) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6462 | FPT_default_intena |= SCAM_SEL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6464 | WRW_HARPOON((port + hp_intena), FPT_default_intena); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6465 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6466 | WR_HARPOON(port + hp_seltimeout, TO_290ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6467 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6468 | /* Turn on SCSI_MODE8 for narrow cards to fix the |
| 6469 | strapping issue with the DUAL CHANNEL card */ |
| 6470 | if (RD_HARPOON(port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6471 | WR_HARPOON(port + hp_addstat, SCSI_MODE8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6472 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6473 | WR_HARPOON(port + hp_page_ctrl, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6474 | |
| 6475 | } |
| 6476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6477 | /*--------------------------------------------------------------------- |
| 6478 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6479 | * Function: FPT_BusMasterInit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6480 | * |
| 6481 | * Description: Initialize the BusMaster for normal operations. |
| 6482 | * |
| 6483 | *---------------------------------------------------------------------*/ |
| 6484 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6485 | static void FPT_BusMasterInit(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6486 | { |
| 6487 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6488 | WR_HARPOON(p_port + hp_sys_ctrl, DRVR_RST); |
| 6489 | WR_HARPOON(p_port + hp_sys_ctrl, 0x00); |
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 | WR_HARPOON(p_port + hp_host_blk_cnt, XFER_BLK64); |
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 | WR_HARPOON(p_port + hp_bm_ctrl, (BMCTRL_DEFAULT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6494 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6495 | WR_HARPOON(p_port + hp_ee_ctrl, (SCSI_TERM_ENA_H)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6496 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6497 | RD_HARPOON(p_port + hp_int_status); /*Clear interrupts. */ |
| 6498 | WR_HARPOON(p_port + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
| 6499 | WR_HARPOON(p_port + hp_page_ctrl, (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6500 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6501 | } |
| 6502 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6503 | /*--------------------------------------------------------------------- |
| 6504 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6505 | * Function: FPT_DiagEEPROM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6506 | * |
| 6507 | * Description: Verfiy checksum and 'Key' and initialize the EEPROM if |
| 6508 | * necessary. |
| 6509 | * |
| 6510 | *---------------------------------------------------------------------*/ |
| 6511 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6512 | static void FPT_DiagEEPROM(u32 p_port) |
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 | unsigned short index, temp, max_wd_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6515 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6516 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6517 | max_wd_cnt = EEPROM_WD_CNT; |
| 6518 | else |
| 6519 | max_wd_cnt = EEPROM_WD_CNT * 2; |
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 | temp = FPT_utilEERead(p_port, FW_SIGNATURE / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6522 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6523 | if (temp == 0x4641) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6524 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6525 | for (index = 2; index < max_wd_cnt; index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6526 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6527 | temp += FPT_utilEERead(p_port, index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6528 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6529 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6530 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6531 | if (temp == FPT_utilEERead(p_port, EEPROM_CHECK_SUM / 2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6532 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6533 | return; /*EEPROM is Okay so return now! */ |
| 6534 | } |
| 6535 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6537 | FPT_utilEEWriteOnOff(p_port, (unsigned char)1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6538 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6539 | for (index = 0; index < max_wd_cnt; index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6540 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6541 | FPT_utilEEWrite(p_port, 0x0000, index); |
| 6542 | } |
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 | temp = 0; |
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 | FPT_utilEEWrite(p_port, 0x4641, FW_SIGNATURE / 2); |
| 6547 | temp += 0x4641; |
| 6548 | FPT_utilEEWrite(p_port, 0x3920, MODEL_NUMB_0 / 2); |
| 6549 | temp += 0x3920; |
| 6550 | FPT_utilEEWrite(p_port, 0x3033, MODEL_NUMB_2 / 2); |
| 6551 | temp += 0x3033; |
| 6552 | FPT_utilEEWrite(p_port, 0x2020, MODEL_NUMB_4 / 2); |
| 6553 | temp += 0x2020; |
| 6554 | FPT_utilEEWrite(p_port, 0x70D3, SYSTEM_CONFIG / 2); |
| 6555 | temp += 0x70D3; |
| 6556 | FPT_utilEEWrite(p_port, 0x0010, BIOS_CONFIG / 2); |
| 6557 | temp += 0x0010; |
| 6558 | FPT_utilEEWrite(p_port, 0x0003, SCAM_CONFIG / 2); |
| 6559 | temp += 0x0003; |
| 6560 | FPT_utilEEWrite(p_port, 0x0007, ADAPTER_SCSI_ID / 2); |
| 6561 | temp += 0x0007; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6562 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6563 | FPT_utilEEWrite(p_port, 0x0000, IGNORE_B_SCAN / 2); |
| 6564 | temp += 0x0000; |
| 6565 | FPT_utilEEWrite(p_port, 0x0000, SEND_START_ENA / 2); |
| 6566 | temp += 0x0000; |
| 6567 | FPT_utilEEWrite(p_port, 0x0000, DEVICE_ENABLE / 2); |
| 6568 | temp += 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6569 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6570 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL01 / 2); |
| 6571 | temp += 0x4242; |
| 6572 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL23 / 2); |
| 6573 | temp += 0x4242; |
| 6574 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL45 / 2); |
| 6575 | temp += 0x4242; |
| 6576 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL67 / 2); |
| 6577 | temp += 0x4242; |
| 6578 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL89 / 2); |
| 6579 | temp += 0x4242; |
| 6580 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLab / 2); |
| 6581 | temp += 0x4242; |
| 6582 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLcd / 2); |
| 6583 | temp += 0x4242; |
| 6584 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLef / 2); |
| 6585 | temp += 0x4242; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6586 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6587 | FPT_utilEEWrite(p_port, 0x6C46, 64 / 2); /*PRODUCT ID */ |
| 6588 | temp += 0x6C46; |
| 6589 | FPT_utilEEWrite(p_port, 0x7361, 66 / 2); /* FlashPoint LT */ |
| 6590 | temp += 0x7361; |
| 6591 | FPT_utilEEWrite(p_port, 0x5068, 68 / 2); |
| 6592 | temp += 0x5068; |
| 6593 | FPT_utilEEWrite(p_port, 0x696F, 70 / 2); |
| 6594 | temp += 0x696F; |
| 6595 | FPT_utilEEWrite(p_port, 0x746E, 72 / 2); |
| 6596 | temp += 0x746E; |
| 6597 | FPT_utilEEWrite(p_port, 0x4C20, 74 / 2); |
| 6598 | temp += 0x4C20; |
| 6599 | FPT_utilEEWrite(p_port, 0x2054, 76 / 2); |
| 6600 | temp += 0x2054; |
| 6601 | FPT_utilEEWrite(p_port, 0x2020, 78 / 2); |
| 6602 | temp += 0x2020; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6603 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6604 | index = ((EE_SCAMBASE / 2) + (7 * 16)); |
| 6605 | FPT_utilEEWrite(p_port, (0x0700 + TYPE_CODE0), index); |
| 6606 | temp += (0x0700 + TYPE_CODE0); |
| 6607 | index++; |
| 6608 | FPT_utilEEWrite(p_port, 0x5542, index); /*Vendor ID code */ |
| 6609 | temp += 0x5542; /* BUSLOGIC */ |
| 6610 | index++; |
| 6611 | FPT_utilEEWrite(p_port, 0x4C53, index); |
| 6612 | temp += 0x4C53; |
| 6613 | index++; |
| 6614 | FPT_utilEEWrite(p_port, 0x474F, index); |
| 6615 | temp += 0x474F; |
| 6616 | index++; |
| 6617 | FPT_utilEEWrite(p_port, 0x4349, index); |
| 6618 | temp += 0x4349; |
| 6619 | index++; |
| 6620 | FPT_utilEEWrite(p_port, 0x5442, index); /*Vendor unique code */ |
| 6621 | temp += 0x5442; /* BT- 930 */ |
| 6622 | index++; |
| 6623 | FPT_utilEEWrite(p_port, 0x202D, index); |
| 6624 | temp += 0x202D; |
| 6625 | index++; |
| 6626 | FPT_utilEEWrite(p_port, 0x3339, index); |
| 6627 | temp += 0x3339; |
| 6628 | index++; /*Serial # */ |
| 6629 | FPT_utilEEWrite(p_port, 0x2030, index); /* 01234567 */ |
| 6630 | temp += 0x2030; |
| 6631 | index++; |
| 6632 | FPT_utilEEWrite(p_port, 0x5453, index); |
| 6633 | temp += 0x5453; |
| 6634 | index++; |
| 6635 | FPT_utilEEWrite(p_port, 0x5645, index); |
| 6636 | temp += 0x5645; |
| 6637 | index++; |
| 6638 | FPT_utilEEWrite(p_port, 0x2045, index); |
| 6639 | temp += 0x2045; |
| 6640 | index++; |
| 6641 | FPT_utilEEWrite(p_port, 0x202F, index); |
| 6642 | temp += 0x202F; |
| 6643 | index++; |
| 6644 | FPT_utilEEWrite(p_port, 0x4F4A, index); |
| 6645 | temp += 0x4F4A; |
| 6646 | index++; |
| 6647 | FPT_utilEEWrite(p_port, 0x204E, index); |
| 6648 | temp += 0x204E; |
| 6649 | index++; |
| 6650 | FPT_utilEEWrite(p_port, 0x3539, index); |
| 6651 | temp += 0x3539; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6652 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6653 | FPT_utilEEWrite(p_port, temp, EEPROM_CHECK_SUM / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6654 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6655 | FPT_utilEEWriteOnOff(p_port, (unsigned char)0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6656 | |
| 6657 | } |
| 6658 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6659 | /*--------------------------------------------------------------------- |
| 6660 | * |
| 6661 | * Function: Queue Search Select |
| 6662 | * |
| 6663 | * Description: Try to find a new command to execute. |
| 6664 | * |
| 6665 | *---------------------------------------------------------------------*/ |
| 6666 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6667 | static void FPT_queueSearchSelect(struct sccb_card *pCurrCard, |
| 6668 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6669 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6670 | unsigned char scan_ptr, lun; |
| 6671 | struct sccb_mgr_tar_info *currTar_Info; |
| 6672 | struct sccb *pOldSccb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6673 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6674 | scan_ptr = pCurrCard->scanIndex; |
| 6675 | do { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6676 | currTar_Info = &FPT_sccbMgrTbl[p_card][scan_ptr]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6677 | if ((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 6678 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 6679 | TAG_Q_TRYING)) { |
| 6680 | if (currTar_Info->TarSelQ_Cnt != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6681 | |
| 6682 | scan_ptr++; |
| 6683 | if (scan_ptr == MAX_SCSI_TAR) |
| 6684 | scan_ptr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6685 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6686 | for (lun = 0; lun < MAX_LUN; lun++) { |
| 6687 | if (currTar_Info->TarLUNBusy[lun] == 0) { |
| 6688 | |
| 6689 | pCurrCard->currentSCCB = |
| 6690 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6691 | pOldSccb = NULL; |
| 6692 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6693 | while ((pCurrCard-> |
| 6694 | currentSCCB != NULL) |
| 6695 | && (lun != |
| 6696 | pCurrCard-> |
| 6697 | currentSCCB->Lun)) { |
| 6698 | pOldSccb = |
| 6699 | pCurrCard-> |
| 6700 | currentSCCB; |
| 6701 | pCurrCard->currentSCCB = |
| 6702 | (struct sccb |
| 6703 | *)(pCurrCard-> |
| 6704 | currentSCCB)-> |
| 6705 | Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6706 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6707 | if (pCurrCard->currentSCCB == |
| 6708 | NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6709 | continue; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6710 | if (pOldSccb != NULL) { |
| 6711 | pOldSccb-> |
| 6712 | Sccb_forwardlink = |
| 6713 | (struct sccb |
| 6714 | *)(pCurrCard-> |
| 6715 | currentSCCB)-> |
| 6716 | Sccb_forwardlink; |
| 6717 | pOldSccb-> |
| 6718 | Sccb_backlink = |
| 6719 | (struct sccb |
| 6720 | *)(pCurrCard-> |
| 6721 | currentSCCB)-> |
| 6722 | Sccb_backlink; |
| 6723 | currTar_Info-> |
| 6724 | TarSelQ_Cnt--; |
| 6725 | } else { |
| 6726 | currTar_Info-> |
| 6727 | TarSelQ_Head = |
| 6728 | (struct sccb |
| 6729 | *)(pCurrCard-> |
| 6730 | currentSCCB)-> |
| 6731 | Sccb_forwardlink; |
| 6732 | |
| 6733 | if (currTar_Info-> |
| 6734 | TarSelQ_Head == |
| 6735 | NULL) { |
| 6736 | currTar_Info-> |
| 6737 | TarSelQ_Tail |
| 6738 | = NULL; |
| 6739 | currTar_Info-> |
| 6740 | TarSelQ_Cnt |
| 6741 | = 0; |
| 6742 | } else { |
| 6743 | currTar_Info-> |
| 6744 | TarSelQ_Cnt--; |
| 6745 | currTar_Info-> |
| 6746 | TarSelQ_Head-> |
| 6747 | Sccb_backlink |
| 6748 | = |
| 6749 | (struct sccb |
| 6750 | *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6751 | } |
| 6752 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6753 | pCurrCard->scanIndex = scan_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6754 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6755 | pCurrCard->globalFlags |= |
| 6756 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6757 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6758 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6759 | } |
| 6760 | } |
| 6761 | } |
| 6762 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6763 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6764 | scan_ptr++; |
| 6765 | if (scan_ptr == MAX_SCSI_TAR) { |
| 6766 | scan_ptr = 0; |
| 6767 | } |
| 6768 | } |
| 6769 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6770 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6771 | if ((currTar_Info->TarSelQ_Cnt != 0) && |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6772 | (currTar_Info->TarLUNBusy[0] == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6773 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6774 | pCurrCard->currentSCCB = |
| 6775 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6776 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6777 | currTar_Info->TarSelQ_Head = |
| 6778 | (struct sccb *)(pCurrCard->currentSCCB)-> |
| 6779 | Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6780 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6781 | if (currTar_Info->TarSelQ_Head == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6782 | currTar_Info->TarSelQ_Tail = NULL; |
| 6783 | currTar_Info->TarSelQ_Cnt = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6784 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6785 | currTar_Info->TarSelQ_Cnt--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6786 | currTar_Info->TarSelQ_Head-> |
| 6787 | Sccb_backlink = (struct sccb *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6788 | } |
| 6789 | |
| 6790 | scan_ptr++; |
| 6791 | if (scan_ptr == MAX_SCSI_TAR) |
| 6792 | scan_ptr = 0; |
| 6793 | |
| 6794 | pCurrCard->scanIndex = scan_ptr; |
| 6795 | |
| 6796 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 6797 | |
| 6798 | break; |
| 6799 | } |
| 6800 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6801 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6802 | scan_ptr++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6803 | if (scan_ptr == MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6804 | scan_ptr = 0; |
| 6805 | } |
| 6806 | } |
| 6807 | } |
| 6808 | } while (scan_ptr != pCurrCard->scanIndex); |
| 6809 | } |
| 6810 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6811 | /*--------------------------------------------------------------------- |
| 6812 | * |
| 6813 | * Function: Queue Select Fail |
| 6814 | * |
| 6815 | * Description: Add the current SCCB to the head of the Queue. |
| 6816 | * |
| 6817 | *---------------------------------------------------------------------*/ |
| 6818 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6819 | static void FPT_queueSelectFail(struct sccb_card *pCurrCard, |
| 6820 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6821 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6822 | unsigned char thisTarg; |
| 6823 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6824 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6825 | if (pCurrCard->currentSCCB != NULL) { |
| 6826 | thisTarg = |
| 6827 | (unsigned char)(((struct sccb *)(pCurrCard->currentSCCB))-> |
| 6828 | TargID); |
| 6829 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6830 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6831 | pCurrCard->currentSCCB->Sccb_backlink = (struct sccb *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6832 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6833 | pCurrCard->currentSCCB->Sccb_forwardlink = |
| 6834 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6835 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6836 | if (currTar_Info->TarSelQ_Cnt == 0) { |
| 6837 | currTar_Info->TarSelQ_Tail = pCurrCard->currentSCCB; |
| 6838 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6839 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6840 | else { |
| 6841 | currTar_Info->TarSelQ_Head->Sccb_backlink = |
| 6842 | pCurrCard->currentSCCB; |
| 6843 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6844 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6845 | currTar_Info->TarSelQ_Head = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6846 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6847 | pCurrCard->currentSCCB = NULL; |
| 6848 | currTar_Info->TarSelQ_Cnt++; |
| 6849 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6850 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6851 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6852 | /*--------------------------------------------------------------------- |
| 6853 | * |
| 6854 | * Function: Queue Command Complete |
| 6855 | * |
| 6856 | * Description: Call the callback function with the current SCCB. |
| 6857 | * |
| 6858 | *---------------------------------------------------------------------*/ |
| 6859 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6860 | static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, |
| 6861 | struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6862 | { |
| 6863 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6864 | unsigned char i, SCSIcmd; |
| 6865 | CALL_BK_FN callback; |
| 6866 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6867 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6868 | SCSIcmd = p_sccb->Cdb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6869 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6870 | if (!(p_sccb->Sccb_XferState & F_ALL_XFERRED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6871 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6872 | if ((p_sccb-> |
| 6873 | ControlByte & (SCCB_DATA_XFER_OUT | SCCB_DATA_XFER_IN)) |
| 6874 | && (p_sccb->HostStatus == SCCB_COMPLETE) |
| 6875 | && (p_sccb->TargetStatus != SSCHECK)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6876 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6877 | if ((SCSIcmd == SCSI_READ) || |
| 6878 | (SCSIcmd == SCSI_WRITE) || |
| 6879 | (SCSIcmd == SCSI_READ_EXTENDED) || |
| 6880 | (SCSIcmd == SCSI_WRITE_EXTENDED) || |
| 6881 | (SCSIcmd == SCSI_WRITE_AND_VERIFY) || |
| 6882 | (SCSIcmd == SCSI_START_STOP_UNIT) || |
| 6883 | (pCurrCard->globalFlags & F_NO_FILTER) |
| 6884 | ) |
| 6885 | p_sccb->HostStatus = SCCB_DATA_UNDER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6886 | } |
| 6887 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6888 | if (p_sccb->SccbStatus == SCCB_IN_PROCESS) { |
| 6889 | if (p_sccb->HostStatus || p_sccb->TargetStatus) |
| 6890 | p_sccb->SccbStatus = SCCB_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6891 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6892 | p_sccb->SccbStatus = SCCB_SUCCESS; |
| 6893 | } |
| 6894 | |
| 6895 | if (p_sccb->Sccb_XferState & F_AUTO_SENSE) { |
| 6896 | |
| 6897 | p_sccb->CdbLength = p_sccb->Save_CdbLen; |
| 6898 | for (i = 0; i < 6; i++) { |
| 6899 | p_sccb->Cdb[i] = p_sccb->Save_Cdb[i]; |
| 6900 | } |
| 6901 | } |
| 6902 | |
| 6903 | if ((p_sccb->OperationCode == RESIDUAL_SG_COMMAND) || |
| 6904 | (p_sccb->OperationCode == RESIDUAL_COMMAND)) { |
| 6905 | |
| 6906 | FPT_utilUpdateResidual(p_sccb); |
| 6907 | } |
| 6908 | |
| 6909 | pCurrCard->cmdCounter--; |
| 6910 | if (!pCurrCard->cmdCounter) { |
| 6911 | |
| 6912 | if (pCurrCard->globalFlags & F_GREEN_PC) { |
| 6913 | WR_HARPOON(pCurrCard->ioPort + hp_clkctrl_0, |
| 6914 | (PWR_DWN | CLKCTRL_DEFAULT)); |
| 6915 | WR_HARPOON(pCurrCard->ioPort + hp_sys_ctrl, STOP_CLK); |
| 6916 | } |
| 6917 | |
| 6918 | WR_HARPOON(pCurrCard->ioPort + hp_semaphore, |
| 6919 | (RD_HARPOON(pCurrCard->ioPort + hp_semaphore) & |
| 6920 | ~SCCB_MGR_ACTIVE)); |
| 6921 | |
| 6922 | } |
| 6923 | |
| 6924 | if (pCurrCard->discQCount != 0) { |
| 6925 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
| 6926 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 6927 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 6928 | TAG_Q_TRYING))) { |
| 6929 | pCurrCard->discQCount--; |
| 6930 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 6931 | LunDiscQ_Idx[p_sccb->Lun]] = NULL; |
| 6932 | } else { |
| 6933 | if (p_sccb->Sccb_tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6934 | pCurrCard->discQCount--; |
| 6935 | pCurrCard->discQ_Tbl[p_sccb->Sccb_tag] = NULL; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6936 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6937 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6938 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 6939 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6940 | } |
| 6941 | } |
| 6942 | |
| 6943 | } |
| 6944 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6945 | callback = (CALL_BK_FN) p_sccb->SccbCallback; |
| 6946 | callback(p_sccb); |
| 6947 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 6948 | pCurrCard->currentSCCB = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6949 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6950 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6951 | /*--------------------------------------------------------------------- |
| 6952 | * |
| 6953 | * Function: Queue Disconnect |
| 6954 | * |
| 6955 | * Description: Add SCCB to our disconnect array. |
| 6956 | * |
| 6957 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6958 | static void FPT_queueDisconnect(struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6959 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6960 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6961 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6962 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6963 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6964 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 6965 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 6966 | FPT_BL_Card[p_card].discQ_Tbl[currTar_Info-> |
| 6967 | LunDiscQ_Idx[p_sccb->Lun]] = |
| 6968 | p_sccb; |
| 6969 | } else { |
| 6970 | if (p_sccb->Sccb_tag) { |
| 6971 | FPT_BL_Card[p_card].discQ_Tbl[p_sccb->Sccb_tag] = |
| 6972 | p_sccb; |
| 6973 | FPT_sccbMgrTbl[p_card][p_sccb->TargID].TarLUNBusy[0] = |
| 6974 | 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6975 | FPT_sccbMgrTbl[p_card][p_sccb->TargID].TarTagQ_Cnt++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6976 | } else { |
| 6977 | FPT_BL_Card[p_card].discQ_Tbl[currTar_Info-> |
| 6978 | LunDiscQ_Idx[0]] = p_sccb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6979 | } |
| 6980 | } |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6981 | FPT_BL_Card[p_card].currentSCCB = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6982 | } |
| 6983 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6984 | /*--------------------------------------------------------------------- |
| 6985 | * |
| 6986 | * Function: Queue Flush SCCB |
| 6987 | * |
| 6988 | * Description: Flush all SCCB's back to the host driver for this target. |
| 6989 | * |
| 6990 | *---------------------------------------------------------------------*/ |
| 6991 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6992 | static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6993 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6994 | unsigned char qtag, thisTarg; |
| 6995 | struct sccb *currSCCB; |
| 6996 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6997 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6998 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 6999 | if (currSCCB != NULL) { |
| 7000 | thisTarg = (unsigned char)currSCCB->TargID; |
| 7001 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7002 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7003 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7004 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7005 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] && |
| 7006 | (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == |
| 7007 | thisTarg)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7008 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7009 | FPT_BL_Card[p_card].discQ_Tbl[qtag]-> |
| 7010 | HostStatus = (unsigned char)error_code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7011 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7012 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 7013 | FPT_BL_Card[p_card]. |
| 7014 | discQ_Tbl[qtag], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7015 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7016 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 7017 | currTar_Info->TarTagQ_Cnt--; |
| 7018 | |
| 7019 | } |
| 7020 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7021 | } |
| 7022 | |
| 7023 | } |
| 7024 | |
| 7025 | /*--------------------------------------------------------------------- |
| 7026 | * |
| 7027 | * Function: Queue Flush Target SCCB |
| 7028 | * |
| 7029 | * Description: Flush all SCCB's back to the host driver for this target. |
| 7030 | * |
| 7031 | *---------------------------------------------------------------------*/ |
| 7032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7033 | static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg, |
| 7034 | unsigned char error_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7035 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7036 | unsigned char qtag; |
| 7037 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7038 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7039 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7040 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7041 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7043 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] && |
| 7044 | (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == thisTarg)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7045 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7046 | FPT_BL_Card[p_card].discQ_Tbl[qtag]->HostStatus = |
| 7047 | (unsigned char)error_code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7048 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7049 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 7050 | FPT_BL_Card[p_card]. |
| 7051 | discQ_Tbl[qtag], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7052 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7053 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 7054 | currTar_Info->TarTagQ_Cnt--; |
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 | } |
| 7057 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7058 | |
| 7059 | } |
| 7060 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7061 | static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7062 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7063 | struct sccb_mgr_tar_info *currTar_Info; |
| 7064 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_SCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7065 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7066 | p_SCCB->Sccb_forwardlink = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7067 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7068 | p_SCCB->Sccb_backlink = currTar_Info->TarSelQ_Tail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7069 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7070 | if (currTar_Info->TarSelQ_Cnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7071 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7072 | currTar_Info->TarSelQ_Head = p_SCCB; |
| 7073 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7074 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7075 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7076 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7077 | currTar_Info->TarSelQ_Tail->Sccb_forwardlink = p_SCCB; |
| 7078 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7079 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7080 | currTar_Info->TarSelQ_Tail = p_SCCB; |
| 7081 | currTar_Info->TarSelQ_Cnt++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7082 | } |
| 7083 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7084 | /*--------------------------------------------------------------------- |
| 7085 | * |
| 7086 | * Function: Queue Find SCCB |
| 7087 | * |
| 7088 | * Description: Search the target select Queue for this SCCB, and |
| 7089 | * remove it if found. |
| 7090 | * |
| 7091 | *---------------------------------------------------------------------*/ |
| 7092 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7093 | static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB, |
| 7094 | unsigned char p_card) |
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 | struct sccb *q_ptr; |
| 7097 | struct sccb_mgr_tar_info *currTar_Info; |
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 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_SCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7100 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7101 | q_ptr = currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7102 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7103 | while (q_ptr != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7104 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7105 | if (q_ptr == p_SCCB) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7106 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7107 | if (currTar_Info->TarSelQ_Head == q_ptr) { |
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 | currTar_Info->TarSelQ_Head = |
| 7110 | q_ptr->Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7111 | } |
| 7112 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7113 | if (currTar_Info->TarSelQ_Tail == q_ptr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7114 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7115 | currTar_Info->TarSelQ_Tail = |
| 7116 | q_ptr->Sccb_backlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7117 | } |
| 7118 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7119 | if (q_ptr->Sccb_forwardlink != NULL) { |
| 7120 | q_ptr->Sccb_forwardlink->Sccb_backlink = |
| 7121 | q_ptr->Sccb_backlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7122 | } |
| 7123 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7124 | if (q_ptr->Sccb_backlink != NULL) { |
| 7125 | q_ptr->Sccb_backlink->Sccb_forwardlink = |
| 7126 | q_ptr->Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7127 | } |
| 7128 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7129 | currTar_Info->TarSelQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7130 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7131 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7132 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7133 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7134 | else { |
| 7135 | q_ptr = q_ptr->Sccb_forwardlink; |
| 7136 | } |
| 7137 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7138 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7139 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7140 | |
| 7141 | } |
| 7142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7143 | /*--------------------------------------------------------------------- |
| 7144 | * |
| 7145 | * Function: Utility Update Residual Count |
| 7146 | * |
| 7147 | * Description: Update the XferCnt to the remaining byte count. |
| 7148 | * If we transferred all the data then just write zero. |
| 7149 | * If Non-SG transfer then report Total Cnt - Actual Transfer |
| 7150 | * Cnt. For SG transfers add the count fields of all |
| 7151 | * remaining SG elements, as well as any partial remaining |
| 7152 | * element. |
| 7153 | * |
| 7154 | *---------------------------------------------------------------------*/ |
| 7155 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7156 | static void FPT_utilUpdateResidual(struct sccb *p_SCCB) |
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 | unsigned long partial_cnt; |
| 7159 | unsigned int sg_index; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7160 | struct blogic_sg_seg *segp; |
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 | if (p_SCCB->Sccb_XferState & F_ALL_XFERRED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7163 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7164 | p_SCCB->DataLength = 0x0000; |
| 7165 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7166 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7167 | else if (p_SCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7168 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7169 | partial_cnt = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7170 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7171 | sg_index = p_SCCB->Sccb_sgseg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7173 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7174 | if (p_SCCB->Sccb_SGoffset) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7175 | |
| 7176 | partial_cnt = p_SCCB->Sccb_SGoffset; |
| 7177 | sg_index++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7178 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7179 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7180 | while (((unsigned long)sg_index * |
| 7181 | (unsigned long)SG_ELEMENT_SIZE) < p_SCCB->DataLength) { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7182 | segp = (struct blogic_sg_seg *)(p_SCCB->DataPointer) + |
| 7183 | (sg_index * 2); |
| 7184 | partial_cnt += segp->segbytes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7185 | sg_index++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7186 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7187 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7188 | p_SCCB->DataLength = partial_cnt; |
| 7189 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7190 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7191 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7192 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7193 | p_SCCB->DataLength -= p_SCCB->Sccb_ATC; |
| 7194 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7195 | } |
| 7196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7197 | /*--------------------------------------------------------------------- |
| 7198 | * |
| 7199 | * Function: Wait 1 Second |
| 7200 | * |
| 7201 | * Description: Wait for 1 second. |
| 7202 | * |
| 7203 | *---------------------------------------------------------------------*/ |
| 7204 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7205 | static void FPT_Wait1Second(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7206 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7207 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7208 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7209 | for (i = 0; i < 4; i++) { |
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 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7212 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7213 | if ((RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST)) |
| 7214 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7215 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7216 | if ((RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) |
| 7217 | break; |
| 7218 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7219 | } |
| 7220 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7221 | /*--------------------------------------------------------------------- |
| 7222 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7223 | * Function: FPT_Wait |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7224 | * |
| 7225 | * Description: Wait the desired delay. |
| 7226 | * |
| 7227 | *---------------------------------------------------------------------*/ |
| 7228 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7229 | static void FPT_Wait(u32 p_port, unsigned char p_delay) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7230 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7231 | unsigned char old_timer; |
| 7232 | unsigned char green_flag; |
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 | old_timer = RD_HARPOON(p_port + hp_seltimeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7235 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7236 | green_flag = RD_HARPOON(p_port + hp_clkctrl_0); |
| 7237 | WR_HARPOON(p_port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7238 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7239 | WR_HARPOON(p_port + hp_seltimeout, p_delay); |
| 7240 | WRW_HARPOON((p_port + hp_intstat), TIMEOUT); |
| 7241 | WRW_HARPOON((p_port + hp_intena), (FPT_default_intena & ~TIMEOUT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7242 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7243 | WR_HARPOON(p_port + hp_portctrl_0, |
| 7244 | (RD_HARPOON(p_port + hp_portctrl_0) | START_TO)); |
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 | while (!(RDW_HARPOON((p_port + hp_intstat)) & TIMEOUT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7247 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7248 | if ((RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST)) |
| 7249 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7250 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7251 | if ((RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) |
| 7252 | break; |
| 7253 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7254 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7255 | WR_HARPOON(p_port + hp_portctrl_0, |
| 7256 | (RD_HARPOON(p_port + hp_portctrl_0) & ~START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7257 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7258 | WRW_HARPOON((p_port + hp_intstat), TIMEOUT); |
| 7259 | WRW_HARPOON((p_port + hp_intena), FPT_default_intena); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7260 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7261 | WR_HARPOON(p_port + hp_clkctrl_0, green_flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7262 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7263 | WR_HARPOON(p_port + hp_seltimeout, old_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7264 | } |
| 7265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7266 | /*--------------------------------------------------------------------- |
| 7267 | * |
| 7268 | * Function: Enable/Disable Write to EEPROM |
| 7269 | * |
| 7270 | * Description: The EEPROM must first be enabled for writes |
| 7271 | * A total of 9 clocks are needed. |
| 7272 | * |
| 7273 | *---------------------------------------------------------------------*/ |
| 7274 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7275 | static void FPT_utilEEWriteOnOff(u32 p_port, unsigned char p_mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7276 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7277 | unsigned char ee_value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7278 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7279 | ee_value = |
| 7280 | (unsigned char)(RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7281 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7282 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7283 | if (p_mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7284 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7285 | FPT_utilEESendCmdAddr(p_port, EWEN, EWEN_ADDR); |
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 | else |
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 | FPT_utilEESendCmdAddr(p_port, EWDS, EWDS_ADDR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7290 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7291 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */ |
| 7292 | 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] | 7293 | } |
| 7294 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7295 | /*--------------------------------------------------------------------- |
| 7296 | * |
| 7297 | * Function: Write EEPROM |
| 7298 | * |
| 7299 | * Description: Write a word to the EEPROM at the specified |
| 7300 | * address. |
| 7301 | * |
| 7302 | *---------------------------------------------------------------------*/ |
| 7303 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7304 | static void FPT_utilEEWrite(u32 p_port, unsigned short ee_data, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7305 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7306 | { |
| 7307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7308 | unsigned char ee_value; |
| 7309 | unsigned short i; |
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 | ee_value = |
| 7312 | (unsigned |
| 7313 | char)((RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7314 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)) | (SEE_MS | SEE_CS)); |
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 | FPT_utilEESendCmdAddr(p_port, EE_WRITE, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7317 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7318 | ee_value |= (SEE_MS + SEE_CS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7319 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7320 | for (i = 0x8000; i != 0; i >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7321 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7322 | if (i & ee_data) |
| 7323 | ee_value |= SEE_DO; |
| 7324 | else |
| 7325 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7326 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7327 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7328 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7329 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7330 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7331 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7332 | ee_value &= ~SEE_CLK; |
| 7333 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7334 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7335 | } |
| 7336 | ee_value &= (EXT_ARB_ACK | SCSI_TERM_ENA_H); |
| 7337 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7338 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7339 | FPT_Wait(p_port, TO_10ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7340 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7341 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS | SEE_CS)); /* Set CS to EEPROM */ |
| 7342 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /* Turn off CS */ |
| 7343 | 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] | 7344 | } |
| 7345 | |
| 7346 | /*--------------------------------------------------------------------- |
| 7347 | * |
| 7348 | * Function: Read EEPROM |
| 7349 | * |
| 7350 | * Description: Read a word from the EEPROM at the desired |
| 7351 | * address. |
| 7352 | * |
| 7353 | *---------------------------------------------------------------------*/ |
| 7354 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7355 | static unsigned short FPT_utilEERead(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7356 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7357 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7358 | unsigned short i, ee_data1, ee_data2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7359 | |
| 7360 | i = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7361 | ee_data1 = FPT_utilEEReadOrg(p_port, ee_addr); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7362 | do { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7363 | ee_data2 = FPT_utilEEReadOrg(p_port, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7364 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7365 | if (ee_data1 == ee_data2) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7366 | return ee_data1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7367 | |
| 7368 | ee_data1 = ee_data2; |
| 7369 | i++; |
| 7370 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7371 | } while (i < 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7372 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7373 | return ee_data1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7374 | } |
| 7375 | |
| 7376 | /*--------------------------------------------------------------------- |
| 7377 | * |
| 7378 | * Function: Read EEPROM Original |
| 7379 | * |
| 7380 | * Description: Read a word from the EEPROM at the desired |
| 7381 | * address. |
| 7382 | * |
| 7383 | *---------------------------------------------------------------------*/ |
| 7384 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7385 | static unsigned short FPT_utilEEReadOrg(u32 p_port, unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7386 | { |
| 7387 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7388 | unsigned char ee_value; |
| 7389 | unsigned short i, ee_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7390 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7391 | ee_value = |
| 7392 | (unsigned |
| 7393 | char)((RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7394 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)) | (SEE_MS | SEE_CS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7395 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7396 | FPT_utilEESendCmdAddr(p_port, EE_READ, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7397 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7398 | ee_value |= (SEE_MS + SEE_CS); |
| 7399 | ee_data = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7400 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7401 | for (i = 1; i <= 16; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7402 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7403 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7404 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7405 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7406 | ee_value &= ~SEE_CLK; |
| 7407 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7408 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7409 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7410 | ee_data <<= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7412 | if (RD_HARPOON(p_port + hp_ee_ctrl) & SEE_DI) |
| 7413 | ee_data |= 1; |
| 7414 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7415 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7416 | ee_value &= ~(SEE_MS + SEE_CS); |
| 7417 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */ |
| 7418 | 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] | 7419 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7420 | return ee_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7421 | } |
| 7422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7423 | /*--------------------------------------------------------------------- |
| 7424 | * |
| 7425 | * Function: Send EE command and Address to the EEPROM |
| 7426 | * |
| 7427 | * Description: Transfers the correct command and sends the address |
| 7428 | * to the eeprom. |
| 7429 | * |
| 7430 | *---------------------------------------------------------------------*/ |
| 7431 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7432 | static void FPT_utilEESendCmdAddr(u32 p_port, unsigned char ee_cmd, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7433 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7434 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7435 | unsigned char ee_value; |
| 7436 | unsigned char narrow_flg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7437 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7438 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7439 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7440 | narrow_flg = |
| 7441 | (unsigned char)(RD_HARPOON(p_port + hp_page_ctrl) & |
| 7442 | NARROW_SCSI_CARD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7443 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7444 | ee_value = SEE_MS; |
| 7445 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7446 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7447 | ee_value |= SEE_CS; /* Set CS to EEPROM */ |
| 7448 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
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 | for (i = 0x04; i != 0; i >>= 1) { |
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 | if (i & ee_cmd) |
| 7453 | ee_value |= SEE_DO; |
| 7454 | else |
| 7455 | ee_value &= ~SEE_DO; |
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 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7458 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7459 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7460 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7461 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7462 | ee_value &= ~SEE_CLK; |
| 7463 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7464 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7465 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7466 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7467 | if (narrow_flg) |
| 7468 | i = 0x0080; |
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 | else |
| 7471 | i = 0x0200; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7472 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7473 | while (i != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7474 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7475 | if (i & ee_addr) |
| 7476 | ee_value |= SEE_DO; |
| 7477 | else |
| 7478 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7479 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7480 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7481 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7482 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7483 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7484 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7485 | ee_value &= ~SEE_CLK; |
| 7486 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7487 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
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 | i >>= 1; |
| 7490 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7491 | } |
| 7492 | |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 7493 | static unsigned short FPT_CalcCrc16(unsigned char buffer[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7494 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7495 | unsigned short crc = 0; |
| 7496 | int i, j; |
| 7497 | unsigned short ch; |
| 7498 | for (i = 0; i < ID_STRING_LENGTH; i++) { |
| 7499 | ch = (unsigned short)buffer[i]; |
| 7500 | for (j = 0; j < 8; j++) { |
| 7501 | if ((crc ^ ch) & 1) |
| 7502 | crc = (crc >> 1) ^ CRCMASK; |
| 7503 | else |
| 7504 | crc >>= 1; |
| 7505 | ch >>= 1; |
| 7506 | } |
| 7507 | } |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7508 | return crc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7509 | } |
| 7510 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 7511 | static unsigned char FPT_CalcLrc(unsigned char buffer[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7512 | { |
| 7513 | int i; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 7514 | unsigned char lrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7515 | lrc = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7516 | for (i = 0; i < ID_STRING_LENGTH; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7517 | lrc ^= buffer[i]; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7518 | return lrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7519 | } |
| 7520 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7521 | /* |
| 7522 | The following inline definitions avoid type conflicts. |
| 7523 | */ |
| 7524 | |
| 7525 | static inline unsigned char |
Khalid Aziz | 839cb99 | 2013-05-16 19:44:13 -0600 | [diff] [blame] | 7526 | FlashPoint__ProbeHostAdapter(struct fpoint_info *FlashPointInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7527 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7528 | return FlashPoint_ProbeHostAdapter((struct sccb_mgr_info *) |
| 7529 | FlashPointInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7530 | } |
| 7531 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7532 | static inline void * |
Khalid Aziz | 839cb99 | 2013-05-16 19:44:13 -0600 | [diff] [blame] | 7533 | FlashPoint__HardwareResetHostAdapter(struct fpoint_info *FlashPointInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7534 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7535 | return FlashPoint_HardwareResetHostAdapter((struct sccb_mgr_info *) |
| 7536 | FlashPointInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7537 | } |
| 7538 | |
| 7539 | static inline void |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7540 | FlashPoint__ReleaseHostAdapter(void *CardHandle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7541 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7542 | FlashPoint_ReleaseHostAdapter(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7543 | } |
| 7544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7545 | static inline void |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7546 | FlashPoint__StartCCB(void *CardHandle, struct blogic_ccb *CCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7547 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7548 | FlashPoint_StartCCB(CardHandle, (struct sccb *)CCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7549 | } |
| 7550 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7551 | static inline void |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7552 | FlashPoint__AbortCCB(void *CardHandle, struct blogic_ccb *CCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7553 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7554 | FlashPoint_AbortCCB(CardHandle, (struct sccb *)CCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7555 | } |
| 7556 | |
Richard Knutsson | 2065e31 | 2007-02-05 16:39:01 -0800 | [diff] [blame] | 7557 | static inline bool |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7558 | FlashPoint__InterruptPending(void *CardHandle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7559 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7560 | return FlashPoint_InterruptPending(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7561 | } |
| 7562 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7563 | static inline int |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7564 | FlashPoint__HandleInterrupt(void *CardHandle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7565 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7566 | return FlashPoint_HandleInterrupt(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7567 | } |
| 7568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7569 | #define FlashPoint_ProbeHostAdapter FlashPoint__ProbeHostAdapter |
| 7570 | #define FlashPoint_HardwareResetHostAdapter FlashPoint__HardwareResetHostAdapter |
| 7571 | #define FlashPoint_ReleaseHostAdapter FlashPoint__ReleaseHostAdapter |
| 7572 | #define FlashPoint_StartCCB FlashPoint__StartCCB |
| 7573 | #define FlashPoint_AbortCCB FlashPoint__AbortCCB |
| 7574 | #define FlashPoint_InterruptPending FlashPoint__InterruptPending |
| 7575 | #define FlashPoint_HandleInterrupt FlashPoint__HandleInterrupt |
| 7576 | |
Matthew Wilcox | 78b4b05 | 2008-03-13 06:55:08 -0600 | [diff] [blame] | 7577 | #else /* !CONFIG_SCSI_FLASHPOINT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7578 | |
| 7579 | /* |
| 7580 | Define prototypes for the FlashPoint SCCB Manager Functions. |
| 7581 | */ |
| 7582 | |
Khalid Aziz | 839cb99 | 2013-05-16 19:44:13 -0600 | [diff] [blame] | 7583 | extern unsigned char FlashPoint_ProbeHostAdapter(struct fpoint_info *); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7584 | extern void *FlashPoint_HardwareResetHostAdapter(struct fpoint_info *); |
| 7585 | extern void FlashPoint_StartCCB(void *, struct blogic_ccb *); |
| 7586 | extern int FlashPoint_AbortCCB(void *, struct blogic_ccb *); |
| 7587 | extern bool FlashPoint_InterruptPending(void *); |
| 7588 | extern int FlashPoint_HandleInterrupt(void *); |
| 7589 | extern void FlashPoint_ReleaseHostAdapter(void *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7590 | |
Matthew Wilcox | 78b4b05 | 2008-03-13 06:55:08 -0600 | [diff] [blame] | 7591 | #endif /* CONFIG_SCSI_FLASHPOINT */ |