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; |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 43 | u16 si_mflags; |
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 | |
| 308 | #define SMIDENT 0x80 |
| 309 | #define DISC_PRIV 0x40 |
| 310 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | #define SM8BIT 0x00 |
| 312 | #define SM16BIT 0x01 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
| 314 | #define SIX_BYTE_CMD 0x06 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | #define TWELVE_BYTE_CMD 0x0C |
| 316 | |
| 317 | #define ASYNC 0x00 |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 318 | #define MAX_OFFSET 0x0F /* Maxbyteoffset for Sync Xfers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | |
| 320 | #define EEPROM_WD_CNT 256 |
| 321 | |
| 322 | #define EEPROM_CHECK_SUM 0 |
| 323 | #define FW_SIGNATURE 2 |
| 324 | #define MODEL_NUMB_0 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | #define MODEL_NUMB_2 6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | #define MODEL_NUMB_4 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | #define SYSTEM_CONFIG 16 |
| 328 | #define SCSI_CONFIG 17 |
| 329 | #define BIOS_CONFIG 18 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | #define SCAM_CONFIG 20 |
| 331 | #define ADAPTER_SCSI_ID 24 |
| 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | #define IGNORE_B_SCAN 32 |
| 334 | #define SEND_START_ENA 34 |
| 335 | #define DEVICE_ENABLE 36 |
| 336 | |
| 337 | #define SYNC_RATE_TBL 38 |
| 338 | #define SYNC_RATE_TBL01 38 |
| 339 | #define SYNC_RATE_TBL23 40 |
| 340 | #define SYNC_RATE_TBL45 42 |
| 341 | #define SYNC_RATE_TBL67 44 |
| 342 | #define SYNC_RATE_TBL89 46 |
| 343 | #define SYNC_RATE_TBLab 48 |
| 344 | #define SYNC_RATE_TBLcd 50 |
| 345 | #define SYNC_RATE_TBLef 52 |
| 346 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 347 | #define EE_SCAMBASE 256 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 349 | #define SCAM_ENABLED BIT(2) |
| 350 | #define SCAM_LEVEL2 BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 352 | #define RENEGO_ENA BIT(10) |
| 353 | #define CONNIO_ENA BIT(11) |
| 354 | #define GREEN_PC_ENA BIT(12) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 356 | #define AUTO_RATE_00 00 |
| 357 | #define AUTO_RATE_05 01 |
| 358 | #define AUTO_RATE_10 02 |
| 359 | #define AUTO_RATE_20 03 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 361 | #define WIDE_NEGO_BIT BIT(7) |
| 362 | #define DISC_ENABLE_BIT BIT(6) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 364 | #define hp_vendor_id_0 0x00 /* LSB */ |
| 365 | #define ORION_VEND_0 0x4B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 367 | #define hp_vendor_id_1 0x01 /* MSB */ |
| 368 | #define ORION_VEND_1 0x10 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 370 | #define hp_device_id_0 0x02 /* LSB */ |
| 371 | #define ORION_DEV_0 0x30 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 373 | #define hp_device_id_1 0x03 /* MSB */ |
| 374 | #define ORION_DEV_1 0x81 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
| 376 | /* Sub Vendor ID and Sub Device ID only available in |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 377 | Harpoon Version 2 and higher */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 379 | #define hp_sub_device_id_0 0x06 /* LSB */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 381 | #define hp_semaphore 0x0C |
| 382 | #define SCCB_MGR_ACTIVE BIT(0) |
| 383 | #define TICKLE_ME BIT(1) |
| 384 | #define SCCB_MGR_PRESENT BIT(3) |
| 385 | #define BIOS_IN_USE BIT(4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 387 | #define hp_sys_ctrl 0x0F |
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 STOP_CLK BIT(0) /*Turn off BusMaster Clock */ |
| 390 | #define DRVR_RST BIT(1) /*Firmware Reset to 80C15 chip */ |
| 391 | #define HALT_MACH BIT(3) /*Halt State Machine */ |
| 392 | #define HARD_ABORT BIT(4) /*Hard Abort */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 394 | #define hp_host_blk_cnt 0x13 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 396 | #define XFER_BLK64 0x06 /* 1 1 0 64 byte per block */ |
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 BM_THRESHOLD 0x40 /* PCI mode can only xfer 16 bytes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 400 | #define hp_int_mask 0x17 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 402 | #define INT_CMD_COMPL BIT(0) /* DMA command complete */ |
| 403 | #define INT_EXT_STATUS BIT(1) /* Extended Status Set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 405 | #define hp_xfer_cnt_lo 0x18 |
| 406 | #define hp_xfer_cnt_hi 0x1A |
| 407 | #define hp_xfer_cmd 0x1B |
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 XFER_HOST_DMA 0x00 /* 0 0 0 Transfer Host -> DMA */ |
| 410 | #define XFER_DMA_HOST 0x01 /* 0 0 1 Transfer DMA -> Host */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 412 | #define XFER_HOST_AUTO 0x00 /* 0 0 Auto Transfer Size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 414 | #define XFER_DMA_8BIT 0x20 /* 0 1 8 BIT Transfer Size */ |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 415 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 416 | #define DISABLE_INT BIT(7) /*Do not interrupt at end of cmd. */ |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 417 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 418 | #define HOST_WRT_CMD ((DISABLE_INT + XFER_HOST_DMA + XFER_HOST_AUTO + XFER_DMA_8BIT)) |
| 419 | #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] | 420 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 421 | #define hp_host_addr_lo 0x1C |
| 422 | #define hp_host_addr_hmi 0x1E |
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 hp_ee_ctrl 0x22 |
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 EXT_ARB_ACK BIT(7) |
| 427 | #define SCSI_TERM_ENA_H BIT(6) /* SCSI high byte terminator */ |
| 428 | #define SEE_MS BIT(5) |
| 429 | #define SEE_CS BIT(3) |
| 430 | #define SEE_CLK BIT(2) |
| 431 | #define SEE_DO BIT(1) |
| 432 | #define SEE_DI BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 434 | #define EE_READ 0x06 |
| 435 | #define EE_WRITE 0x05 |
| 436 | #define EWEN 0x04 |
| 437 | #define EWEN_ADDR 0x03C0 |
| 438 | #define EWDS 0x04 |
| 439 | #define EWDS_ADDR 0x0000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 441 | #define hp_bm_ctrl 0x26 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 443 | #define SCSI_TERM_ENA_L BIT(0) /*Enable/Disable external terminators */ |
| 444 | #define FLUSH_XFER_CNTR BIT(1) /*Flush transfer counter */ |
| 445 | #define FORCE1_XFER BIT(5) /*Always xfer one byte in byte mode */ |
| 446 | #define FAST_SINGLE BIT(6) /*?? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 448 | #define BMCTRL_DEFAULT (FORCE1_XFER|FAST_SINGLE|SCSI_TERM_ENA_L) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 450 | #define hp_sg_addr 0x28 |
| 451 | #define hp_page_ctrl 0x29 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 453 | #define SCATTER_EN BIT(0) |
| 454 | #define SGRAM_ARAM BIT(1) |
| 455 | #define G_INT_DISABLE BIT(3) /* Enable/Disable all Interrupts */ |
| 456 | #define NARROW_SCSI_CARD BIT(4) /* NARROW/WIDE SCSI config pin */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 458 | #define hp_pci_stat_cfg 0x2D |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 460 | #define REC_MASTER_ABORT BIT(5) /*received Master abort */ |
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 hp_rev_num 0x33 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 464 | #define hp_stack_data 0x34 |
| 465 | #define hp_stack_addr 0x35 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 467 | #define hp_ext_status 0x36 |
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 BM_FORCE_OFF BIT(0) /*Bus Master is forced to get off */ |
| 470 | #define PCI_TGT_ABORT BIT(0) /*PCI bus master transaction aborted */ |
| 471 | #define PCI_DEV_TMOUT BIT(1) /*PCI Device Time out */ |
| 472 | #define CMD_ABORTED BIT(4) /*Command aborted */ |
| 473 | #define BM_PARITY_ERR BIT(5) /*parity error on data received */ |
| 474 | #define PIO_OVERRUN BIT(6) /*Slave data overrun */ |
| 475 | #define BM_CMD_BUSY BIT(7) /*Bus master transfer command busy */ |
| 476 | #define BAD_EXT_STATUS (BM_FORCE_OFF | PCI_DEV_TMOUT | CMD_ABORTED | \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | BM_PARITY_ERR | PIO_OVERRUN) |
| 478 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 479 | #define hp_int_status 0x37 |
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 EXT_STATUS_ON BIT(1) /*Extended status is valid */ |
| 482 | #define SCSI_INTERRUPT BIT(2) /*Global indication of a SCSI int. */ |
| 483 | #define INT_ASSERTED BIT(5) /* */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 485 | #define hp_fifo_cnt 0x38 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 487 | #define hp_intena 0x40 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 489 | #define RESET BIT(7) |
| 490 | #define PROG_HLT BIT(6) |
| 491 | #define PARITY BIT(5) |
| 492 | #define FIFO BIT(4) |
| 493 | #define SEL BIT(3) |
| 494 | #define SCAM_SEL BIT(2) |
| 495 | #define RSEL BIT(1) |
| 496 | #define TIMEOUT BIT(0) |
| 497 | #define BUS_FREE BIT(15) |
| 498 | #define XFER_CNT_0 BIT(14) |
| 499 | #define PHASE BIT(13) |
| 500 | #define IUNKWN BIT(12) |
| 501 | #define ICMD_COMP BIT(11) |
| 502 | #define ITICKLE BIT(10) |
| 503 | #define IDO_STRT BIT(9) |
| 504 | #define ITAR_DISC BIT(8) |
| 505 | #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] | 506 | #define CLR_ALL_INT 0xFFFF |
| 507 | #define CLR_ALL_INT_1 0xFF00 |
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 hp_intstat 0x42 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 511 | #define hp_scsisig 0x44 |
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 SCSI_SEL BIT(7) |
| 514 | #define SCSI_BSY BIT(6) |
| 515 | #define SCSI_REQ BIT(5) |
| 516 | #define SCSI_ACK BIT(4) |
| 517 | #define SCSI_ATN BIT(3) |
| 518 | #define SCSI_CD BIT(2) |
| 519 | #define SCSI_MSG BIT(1) |
| 520 | #define SCSI_IOBIT BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 522 | #define S_SCSI_PHZ (BIT(2)+BIT(1)+BIT(0)) |
| 523 | #define S_MSGO_PH (BIT(2)+BIT(1) ) |
| 524 | #define S_MSGI_PH (BIT(2)+BIT(1)+BIT(0)) |
| 525 | #define S_DATAI_PH ( BIT(0)) |
| 526 | #define S_DATAO_PH 0x00 |
| 527 | #define S_ILL_PH ( BIT(1) ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 529 | #define hp_scsictrl_0 0x45 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 531 | #define SEL_TAR BIT(6) |
| 532 | #define ENA_ATN BIT(4) |
| 533 | #define ENA_RESEL BIT(2) |
| 534 | #define SCSI_RST BIT(1) |
| 535 | #define ENA_SCAM_SEL BIT(0) |
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_portctrl_0 0x46 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 539 | #define SCSI_PORT BIT(7) |
| 540 | #define SCSI_INBIT BIT(6) |
| 541 | #define DMA_PORT BIT(5) |
| 542 | #define DMA_RD BIT(4) |
| 543 | #define HOST_PORT BIT(3) |
| 544 | #define HOST_WRT BIT(2) |
| 545 | #define SCSI_BUS_EN BIT(1) |
| 546 | #define START_TO BIT(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 548 | #define hp_scsireset 0x47 |
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 SCSI_INI BIT(6) |
| 551 | #define SCAM_EN BIT(5) |
| 552 | #define DMA_RESET BIT(3) |
| 553 | #define HPSCSI_RESET BIT(2) |
| 554 | #define PROG_RESET BIT(1) |
| 555 | #define FIFO_CLR BIT(0) |
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_xfercnt_0 0x48 |
| 558 | #define hp_xfercnt_2 0x4A |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 560 | #define hp_fifodata_0 0x4C |
| 561 | #define hp_addstat 0x4E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 563 | #define SCAM_TIMER BIT(7) |
| 564 | #define SCSI_MODE8 BIT(3) |
| 565 | #define SCSI_PAR_ERR BIT(0) |
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 hp_prgmcnt_0 0x4F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 569 | #define hp_selfid_0 0x50 |
| 570 | #define hp_selfid_1 0x51 |
| 571 | #define hp_arb_id 0x52 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 573 | #define hp_select_id 0x53 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 575 | #define hp_synctarg_base 0x54 |
| 576 | #define hp_synctarg_12 0x54 |
| 577 | #define hp_synctarg_13 0x55 |
| 578 | #define hp_synctarg_14 0x56 |
| 579 | #define hp_synctarg_15 0x57 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 581 | #define hp_synctarg_8 0x58 |
| 582 | #define hp_synctarg_9 0x59 |
| 583 | #define hp_synctarg_10 0x5A |
| 584 | #define hp_synctarg_11 0x5B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 586 | #define hp_synctarg_4 0x5C |
| 587 | #define hp_synctarg_5 0x5D |
| 588 | #define hp_synctarg_6 0x5E |
| 589 | #define hp_synctarg_7 0x5F |
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 hp_synctarg_0 0x60 |
| 592 | #define hp_synctarg_1 0x61 |
| 593 | #define hp_synctarg_2 0x62 |
| 594 | #define hp_synctarg_3 0x63 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 596 | #define NARROW_SCSI BIT(4) |
| 597 | #define DEFAULT_OFFSET 0x0F |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 599 | #define hp_autostart_0 0x64 |
| 600 | #define hp_autostart_1 0x65 |
| 601 | #define hp_autostart_3 0x67 |
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 AUTO_IMMED BIT(5) |
| 604 | #define SELECT BIT(6) |
| 605 | #define END_DATA (BIT(7)+BIT(6)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 607 | #define hp_gp_reg_0 0x68 |
| 608 | #define hp_gp_reg_1 0x69 |
| 609 | #define hp_gp_reg_3 0x6B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 611 | #define hp_seltimeout 0x6C |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 613 | #define TO_4ms 0x67 /* 3.9959ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 615 | #define TO_5ms 0x03 /* 4.9152ms */ |
| 616 | #define TO_10ms 0x07 /* 11.xxxms */ |
| 617 | #define TO_250ms 0x99 /* 250.68ms */ |
| 618 | #define TO_290ms 0xB1 /* 289.99ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 620 | #define hp_clkctrl_0 0x6D |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 622 | #define PWR_DWN BIT(6) |
| 623 | #define ACTdeassert BIT(4) |
| 624 | #define CLK_40MHZ (BIT(1) + BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 626 | #define CLKCTRL_DEFAULT (ACTdeassert | CLK_40MHZ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 628 | #define hp_fiforead 0x6E |
| 629 | #define hp_fifowrite 0x6F |
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 hp_offsetctr 0x70 |
| 632 | #define hp_xferstat 0x71 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 634 | #define FIFO_EMPTY BIT(6) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 636 | #define hp_portctrl_1 0x72 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 638 | #define CHK_SCSI_P BIT(3) |
| 639 | #define HOST_MODE8 BIT(0) |
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 hp_xfer_pad 0x73 |
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 ID_UNLOCK BIT(3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 645 | #define hp_scsidata_0 0x74 |
| 646 | #define hp_scsidata_1 0x75 |
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_aramBase 0x80 |
| 649 | #define BIOS_DATA_OFFSET 0x60 |
| 650 | #define BIOS_RELATIVE_CARD 0x64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 652 | #define AR3 (BIT(9) + BIT(8)) |
| 653 | #define SDATA BIT(10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 655 | #define CRD_OP BIT(11) /* Cmp Reg. w/ Data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 657 | #define CRR_OP BIT(12) /* Cmp Reg. w. Reg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 659 | #define CPE_OP (BIT(14)+BIT(11)) /* Cmp SCSI phs & Branch EQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 661 | #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] | 662 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 663 | #define ADATA_OUT 0x00 |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 664 | #define ADATA_IN BIT(8) |
| 665 | #define ACOMMAND BIT(10) |
| 666 | #define ASTATUS (BIT(10)+BIT(8)) |
| 667 | #define AMSG_OUT (BIT(10)+BIT(9)) |
| 668 | #define AMSG_IN (BIT(10)+BIT(9)+BIT(8)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 670 | #define BRH_OP BIT(13) /* Branch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 672 | #define ALWAYS 0x00 |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 673 | #define EQUAL BIT(8) |
| 674 | #define NOT_EQ BIT(9) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 676 | #define TCB_OP (BIT(13)+BIT(11)) /* Test condition & branch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 678 | #define FIFO_0 BIT(10) |
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 MPM_OP BIT(15) /* Match phase and move data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 682 | #define MRR_OP BIT(14) /* Move DReg. to Reg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 684 | #define S_IDREG (BIT(2)+BIT(1)+BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 686 | #define D_AR0 0x00 |
| 687 | #define D_AR1 BIT(0) |
| 688 | #define D_BUCKET (BIT(2) + BIT(1) + BIT(0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 690 | #define RAT_OP (BIT(14)+BIT(13)+BIT(11)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | |
Jiri Slaby | 1cafc30 | 2007-10-18 23:40:36 -0700 | [diff] [blame] | 692 | #define SSI_OP (BIT(15)+BIT(11)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 694 | #define SSI_ITAR_DISC (ITAR_DISC >> 8) |
| 695 | #define SSI_IDO_STRT (IDO_STRT >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 697 | #define SSI_ICMD_COMP (ICMD_COMP >> 8) |
| 698 | #define SSI_ITICKLE (ITICKLE >> 8) |
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 SSI_IUNKWN (IUNKWN >> 8) |
| 701 | #define SSI_INO_CC (IUNKWN >> 8) |
| 702 | #define SSI_IRFAIL (IUNKWN >> 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 704 | #define NP 0x10 /*Next Phase */ |
| 705 | #define NTCMD 0x02 /*Non- Tagged Command start */ |
| 706 | #define CMDPZ 0x04 /*Command phase */ |
| 707 | #define DINT 0x12 /*Data Out/In interrupt */ |
| 708 | #define DI 0x13 /*Data Out */ |
| 709 | #define DC 0x19 /*Disconnect Message */ |
| 710 | #define ST 0x1D /*Status Phase */ |
| 711 | #define UNKNWN 0x24 /*Unknown bus action */ |
| 712 | #define CC 0x25 /*Command Completion failure */ |
| 713 | #define TICK 0x26 /*New target reselected us. */ |
| 714 | #define SELCHK 0x28 /*Select & Check SCSI ID latch reg */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 716 | #define ID_MSG_STRT hp_aramBase + 0x00 |
| 717 | #define NON_TAG_ID_MSG hp_aramBase + 0x06 |
| 718 | #define CMD_STRT hp_aramBase + 0x08 |
| 719 | #define SYNC_MSGS hp_aramBase + 0x08 |
Alexey Dobriyan | 85ae97d8 | 2006-03-08 00:14:22 -0800 | [diff] [blame] | 720 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 721 | #define TAG_STRT 0x00 |
| 722 | #define DISCONNECT_START 0x10/2 |
| 723 | #define END_DATA_START 0x14/2 |
| 724 | #define CMD_ONLY_STRT CMDPZ/2 |
| 725 | #define SELCHK_STRT SELCHK/2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | |
| 727 | #define GET_XFER_CNT(port, xfercnt) {RD_HARP32(port,hp_xfercnt_0,xfercnt); xfercnt &= 0xFFFFFF;} |
| 728 | /* #define GET_XFER_CNT(port, xfercnt) (xfercnt = RD_HARPOON(port+hp_xfercnt_2), \ |
| 729 | xfercnt <<= 16,\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 730 | xfercnt |= RDW_HARPOON((unsigned short)(port+hp_xfercnt_0))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | */ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 732 | #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] | 733 | addr >>= 16,\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 734 | WRW_HARPOON((port+hp_host_addr_hmi), (unsigned short)(addr & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | WR_HARP32(port,hp_xfercnt_0,count),\ |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 736 | WRW_HARPOON((port+hp_xfer_cnt_lo), (unsigned short)(count & 0x0000FFFFL)),\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | count >>= 16,\ |
| 738 | WR_HARPOON(port+hp_xfer_cnt_hi, (count & 0xFF))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | |
| 740 | #define ACCEPT_MSG(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\ |
| 741 | WR_HARPOON(port+hp_scsisig, S_ILL_PH);} |
| 742 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | #define ACCEPT_MSG_ATN(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\ |
| 744 | WR_HARPOON(port+hp_scsisig, (S_ILL_PH|SCSI_ATN));} |
| 745 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | #define DISABLE_AUTO(port) (WR_HARPOON(port+hp_scsireset, PROG_RESET),\ |
| 747 | WR_HARPOON(port+hp_scsireset, 0x00)) |
| 748 | |
| 749 | #define ARAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 750 | (RD_HARPOON(p_port+hp_page_ctrl) | SGRAM_ARAM))) |
| 751 | |
| 752 | #define SGRAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 753 | (RD_HARPOON(p_port+hp_page_ctrl) & ~SGRAM_ARAM))) |
| 754 | |
| 755 | #define MDISABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 756 | (RD_HARPOON(p_port+hp_page_ctrl) | G_INT_DISABLE))) |
| 757 | |
| 758 | #define MENABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \ |
| 759 | (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE))) |
| 760 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 761 | static unsigned char FPT_sisyncn(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 762 | unsigned char syncFlag); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 763 | static void FPT_ssel(u32 port, unsigned char p_card); |
| 764 | static void FPT_sres(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 765 | struct sccb_card *pCurrCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 766 | static void FPT_shandem(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 767 | struct sccb *pCurrSCCB); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 768 | static void FPT_stsyncn(u32 port, unsigned char p_card); |
| 769 | static void FPT_sisyncr(u32 port, unsigned char sync_pulse, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 770 | unsigned char offset); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 771 | static void FPT_sssyncv(u32 p_port, unsigned char p_id, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 772 | unsigned char p_sync_value, |
| 773 | struct sccb_mgr_tar_info *currTar_Info); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 774 | static void FPT_sresb(u32 port, unsigned char p_card); |
| 775 | static void FPT_sxfrp(u32 p_port, unsigned char p_card); |
| 776 | static void FPT_schkdd(u32 port, unsigned char p_card); |
| 777 | static unsigned char FPT_RdStack(u32 port, unsigned char index); |
| 778 | static void FPT_WrStack(u32 portBase, unsigned char index, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 779 | unsigned char data); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 780 | static unsigned char FPT_ChkIfChipInitialized(u32 ioPort); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 782 | static void FPT_SendMsg(u32 port, unsigned char message); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 783 | static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg, |
| 784 | unsigned char error_code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 786 | static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card); |
| 787 | static void FPT_RNVRamData(struct nvram_info *pNvRamInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 789 | static unsigned char FPT_siwidn(u32 port, unsigned char p_card); |
| 790 | static void FPT_stwidn(u32 port, unsigned char p_card); |
| 791 | static void FPT_siwidr(u32 port, unsigned char width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 793 | static void FPT_queueSelectFail(struct sccb_card *pCurrCard, |
| 794 | unsigned char p_card); |
| 795 | static void FPT_queueDisconnect(struct sccb *p_SCCB, unsigned char p_card); |
| 796 | static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, |
| 797 | struct sccb *p_SCCB, unsigned char p_card); |
| 798 | static void FPT_queueSearchSelect(struct sccb_card *pCurrCard, |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 799 | unsigned char p_card); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 800 | static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code); |
| 801 | static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char card); |
| 802 | static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB, |
| 803 | unsigned char p_card); |
| 804 | static void FPT_utilUpdateResidual(struct sccb *p_SCCB); |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 805 | static unsigned short FPT_CalcCrc16(unsigned char buffer[]); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 806 | static unsigned char FPT_CalcLrc(unsigned char buffer[]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 808 | static void FPT_Wait1Second(u32 p_port); |
| 809 | static void FPT_Wait(u32 p_port, unsigned char p_delay); |
| 810 | static void FPT_utilEEWriteOnOff(u32 p_port, unsigned char p_mode); |
| 811 | static void FPT_utilEEWrite(u32 p_port, unsigned short ee_data, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 812 | unsigned short ee_addr); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 813 | static unsigned short FPT_utilEERead(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 814 | unsigned short ee_addr); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 815 | static unsigned short FPT_utilEEReadOrg(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 816 | unsigned short ee_addr); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 817 | static void FPT_utilEESendCmdAddr(u32 p_port, unsigned char ee_cmd, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 818 | unsigned short ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 820 | static void FPT_phaseDataOut(u32 port, unsigned char p_card); |
| 821 | static void FPT_phaseDataIn(u32 port, unsigned char p_card); |
| 822 | static void FPT_phaseCommand(u32 port, unsigned char p_card); |
| 823 | static void FPT_phaseStatus(u32 port, unsigned char p_card); |
| 824 | static void FPT_phaseMsgOut(u32 port, unsigned char p_card); |
| 825 | static void FPT_phaseMsgIn(u32 port, unsigned char p_card); |
| 826 | static void FPT_phaseIllegal(u32 port, unsigned char p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 828 | static void FPT_phaseDecode(u32 port, unsigned char p_card); |
| 829 | static void FPT_phaseChkFifo(u32 port, unsigned char p_card); |
| 830 | static void FPT_phaseBusFree(u32 p_port, unsigned char p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 832 | static void FPT_XbowInit(u32 port, unsigned char scamFlg); |
| 833 | static void FPT_BusMasterInit(u32 p_port); |
| 834 | static void FPT_DiagEEPROM(u32 p_port); |
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_dataXferProcessor(u32 port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 837 | struct sccb_card *pCurrCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 838 | static void FPT_busMstrSGDataXferStart(u32 port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 839 | struct sccb *pCurrSCCB); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 840 | static void FPT_busMstrDataXferStart(u32 port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 841 | struct sccb *pCurrSCCB); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 842 | static void FPT_hostDataXferAbort(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 843 | struct sccb *pCurrSCCB); |
| 844 | static void FPT_hostDataXferRestart(struct sccb *currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 846 | static unsigned char FPT_SccbMgr_bad_isr(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 847 | unsigned char p_card, |
| 848 | struct sccb_card *pCurrCard, |
| 849 | unsigned short p_int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 851 | static void FPT_SccbMgrTableInitAll(void); |
| 852 | static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard, |
| 853 | unsigned char p_card); |
| 854 | static void FPT_SccbMgrTableInitTarget(unsigned char p_card, |
| 855 | unsigned char target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 857 | static void FPT_scini(unsigned char p_card, unsigned char p_our_id, |
| 858 | unsigned char p_power_up); |
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 int FPT_scarb(u32 p_port, unsigned char p_sel_type); |
| 861 | static void FPT_scbusf(u32 p_port); |
| 862 | static void FPT_scsel(u32 p_port); |
| 863 | static void FPT_scasid(unsigned char p_card, u32 p_port); |
| 864 | static unsigned char FPT_scxferc(u32 p_port, unsigned char p_data); |
| 865 | static unsigned char FPT_scsendi(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 866 | unsigned char p_id_string[]); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 867 | static unsigned char FPT_sciso(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 868 | unsigned char p_id_string[]); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 869 | static void FPT_scwirod(u32 p_port, unsigned char p_data_bit); |
| 870 | static void FPT_scwiros(u32 p_port, unsigned char p_data_bit); |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 871 | static unsigned char FPT_scvalq(unsigned char p_quintet); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 872 | static unsigned char FPT_scsell(u32 p_port, unsigned char targ_id); |
| 873 | static void FPT_scwtsel(u32 p_port); |
| 874 | static void FPT_inisci(unsigned char p_card, u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 875 | unsigned char p_our_id); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 876 | static void FPT_scsavdi(unsigned char p_card, u32 p_port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 877 | static unsigned char FPT_scmachid(unsigned char p_card, |
| 878 | unsigned char p_id_string[]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 880 | static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card); |
| 881 | static void FPT_autoLoadDefaultMap(u32 p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 883 | static struct sccb_mgr_tar_info FPT_sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR] = |
| 884 | { {{0}} }; |
| 885 | static struct sccb_card FPT_BL_Card[MAX_CARDS] = { {0} }; |
| 886 | static SCCBSCAM_INFO FPT_scamInfo[MAX_SCSI_TAR] = { {{0}} }; |
| 887 | static struct nvram_info FPT_nvRamInfo[MAX_MB_CARDS] = { {0} }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 889 | static unsigned char FPT_mbCards = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 890 | static unsigned char FPT_scamHAString[] = |
| 891 | { 0x63, 0x07, 'B', 'U', 'S', 'L', 'O', 'G', 'I', 'C', |
| 892 | ' ', 'B', 'T', '-', '9', '3', '0', |
| 893 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 894 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 |
| 895 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 897 | static unsigned short FPT_default_intena = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 899 | static void (*FPT_s_PhaseTbl[8]) (u32, unsigned char) = { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 900 | 0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | |
| 902 | /*--------------------------------------------------------------------- |
| 903 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 904 | * Function: FlashPoint_ProbeHostAdapter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | * |
| 906 | * Description: Setup and/or Search for cards and return info to caller. |
| 907 | * |
| 908 | *---------------------------------------------------------------------*/ |
| 909 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 910 | static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 912 | static unsigned char first_time = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 914 | unsigned char i, j, id, ScamFlg; |
| 915 | unsigned short temp, temp2, temp3, temp4, temp5, temp6; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 916 | u32 ioport; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 917 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 919 | ioport = pCardInfo->si_baseaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 921 | if (RD_HARPOON(ioport + hp_vendor_id_0) != ORION_VEND_0) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 922 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 924 | if ((RD_HARPOON(ioport + hp_vendor_id_1) != ORION_VEND_1)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 925 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 927 | if ((RD_HARPOON(ioport + hp_device_id_0) != ORION_DEV_0)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 928 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 930 | if ((RD_HARPOON(ioport + hp_device_id_1) != ORION_DEV_1)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 931 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 933 | if (RD_HARPOON(ioport + hp_rev_num) != 0x0f) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | |
| 935 | /* For new Harpoon then check for sub_device ID LSB |
| 936 | the bits(0-3) must be all ZERO for compatible with |
| 937 | current version of SCCBMgr, else skip this Harpoon |
| 938 | device. */ |
| 939 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 940 | if (RD_HARPOON(ioport + hp_sub_device_id_0) & 0x0f) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 941 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 942 | } |
| 943 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 944 | if (first_time) { |
| 945 | FPT_SccbMgrTableInitAll(); |
| 946 | first_time = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 947 | FPT_mbCards = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 948 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 950 | if (FPT_RdStack(ioport, 0) != 0x00) { |
| 951 | if (FPT_ChkIfChipInitialized(ioport) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | pCurrNvRam = NULL; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 953 | WR_HARPOON(ioport + hp_semaphore, 0x00); |
| 954 | FPT_XbowInit(ioport, 0); /*Must Init the SCSI before attempting */ |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 955 | FPT_DiagEEPROM(ioport); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 956 | } else { |
| 957 | if (FPT_mbCards < MAX_MB_CARDS) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 958 | pCurrNvRam = &FPT_nvRamInfo[FPT_mbCards]; |
| 959 | FPT_mbCards++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | pCurrNvRam->niBaseAddr = ioport; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 961 | FPT_RNVRamData(pCurrNvRam); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 962 | } else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 963 | return (int)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 965 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | pCurrNvRam = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 968 | WR_HARPOON(ioport + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 969 | WR_HARPOON(ioport + hp_sys_ctrl, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 971 | if (pCurrNvRam) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | pCardInfo->si_id = pCurrNvRam->niAdapId; |
| 973 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 974 | pCardInfo->si_id = |
| 975 | (unsigned |
| 976 | char)(FPT_utilEERead(ioport, |
| 977 | (ADAPTER_SCSI_ID / |
| 978 | 2)) & (unsigned char)0x0FF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 980 | pCardInfo->si_lun = 0x00; |
| 981 | pCardInfo->si_fw_revision = ORION_FW_REV; |
| 982 | temp2 = 0x0000; |
| 983 | temp3 = 0x0000; |
| 984 | temp4 = 0x0000; |
| 985 | temp5 = 0x0000; |
| 986 | temp6 = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 988 | for (id = 0; id < (16 / 2); id++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 990 | if (pCurrNvRam) { |
| 991 | temp = (unsigned short)pCurrNvRam->niSyncTbl[id]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) + |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 993 | (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000)); |
| 994 | } else |
| 995 | temp = |
| 996 | FPT_utilEERead(ioport, |
| 997 | (unsigned short)((SYNC_RATE_TBL / 2) |
| 998 | + id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1000 | for (i = 0; i < 2; temp >>= 8, i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1002 | temp2 >>= 1; |
| 1003 | temp3 >>= 1; |
| 1004 | temp4 >>= 1; |
| 1005 | temp5 >>= 1; |
| 1006 | temp6 >>= 1; |
| 1007 | switch (temp & 0x3) { |
| 1008 | case AUTO_RATE_20: /* Synchronous, 20 mega-transfers/second */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1009 | temp6 |= 0x8000; |
| 1010 | fallthrough; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1011 | case AUTO_RATE_10: /* Synchronous, 10 mega-transfers/second */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1012 | temp5 |= 0x8000; |
| 1013 | fallthrough; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1014 | case AUTO_RATE_05: /* Synchronous, 5 mega-transfers/second */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1015 | temp2 |= 0x8000; |
| 1016 | fallthrough; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1017 | case AUTO_RATE_00: /* Asynchronous */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | break; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | if (temp & DISC_ENABLE_BIT) |
| 1022 | temp3 |= 0x8000; |
| 1023 | |
| 1024 | if (temp & WIDE_NEGO_BIT) |
| 1025 | temp4 |= 0x8000; |
| 1026 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1028 | } |
| 1029 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1030 | pCardInfo->si_per_targ_init_sync = temp2; |
| 1031 | pCardInfo->si_per_targ_no_disc = temp3; |
| 1032 | pCardInfo->si_per_targ_wide_nego = temp4; |
| 1033 | pCardInfo->si_per_targ_fast_nego = temp5; |
| 1034 | pCardInfo->si_per_targ_ultra_nego = temp6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1036 | if (pCurrNvRam) |
| 1037 | i = pCurrNvRam->niSysConf; |
| 1038 | else |
| 1039 | i = (unsigned |
| 1040 | char)(FPT_utilEERead(ioport, (SYSTEM_CONFIG / 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1042 | if (pCurrNvRam) |
| 1043 | ScamFlg = pCurrNvRam->niScamConf; |
| 1044 | else |
| 1045 | ScamFlg = |
| 1046 | (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1048 | pCardInfo->si_mflags = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1050 | if (i & 0x01) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1051 | pCardInfo->si_mflags |= SCSI_PARITY_ENA; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1052 | |
| 1053 | if (!(i & 0x02)) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1054 | pCardInfo->si_mflags |= SOFT_RESET; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1055 | |
| 1056 | if (i & 0x10) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1057 | pCardInfo->si_mflags |= EXTENDED_TRANSLATION; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1058 | |
| 1059 | if (ScamFlg & SCAM_ENABLED) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1060 | pCardInfo->si_mflags |= FLAG_SCAM_ENABLED; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1061 | |
| 1062 | if (ScamFlg & SCAM_LEVEL2) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1063 | pCardInfo->si_mflags |= FLAG_SCAM_LEVEL2; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1064 | |
| 1065 | j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L); |
| 1066 | if (i & 0x04) { |
| 1067 | j |= SCSI_TERM_ENA_L; |
| 1068 | } |
| 1069 | WR_HARPOON(ioport + hp_bm_ctrl, j); |
| 1070 | |
| 1071 | j = (RD_HARPOON(ioport + hp_ee_ctrl) & ~SCSI_TERM_ENA_H); |
| 1072 | if (i & 0x08) { |
| 1073 | j |= SCSI_TERM_ENA_H; |
| 1074 | } |
| 1075 | WR_HARPOON(ioport + hp_ee_ctrl, j); |
| 1076 | |
| 1077 | if (!(RD_HARPOON(ioport + hp_page_ctrl) & NARROW_SCSI_CARD)) |
| 1078 | |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1079 | pCardInfo->si_mflags |= SUPPORT_16TAR_32LUN; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1080 | |
| 1081 | pCardInfo->si_card_family = HARPOON_FAMILY; |
| 1082 | pCardInfo->si_bustype = BUSTYPE_PCI; |
| 1083 | |
| 1084 | if (pCurrNvRam) { |
| 1085 | pCardInfo->si_card_model[0] = '9'; |
| 1086 | switch (pCurrNvRam->niModel & 0x0f) { |
| 1087 | case MODEL_LT: |
| 1088 | pCardInfo->si_card_model[1] = '3'; |
| 1089 | pCardInfo->si_card_model[2] = '0'; |
| 1090 | break; |
| 1091 | case MODEL_LW: |
| 1092 | pCardInfo->si_card_model[1] = '5'; |
| 1093 | pCardInfo->si_card_model[2] = '0'; |
| 1094 | break; |
| 1095 | case MODEL_DL: |
| 1096 | pCardInfo->si_card_model[1] = '3'; |
| 1097 | pCardInfo->si_card_model[2] = '2'; |
| 1098 | break; |
| 1099 | case MODEL_DW: |
| 1100 | pCardInfo->si_card_model[1] = '5'; |
| 1101 | pCardInfo->si_card_model[2] = '2'; |
| 1102 | break; |
| 1103 | } |
| 1104 | } else { |
| 1105 | temp = FPT_utilEERead(ioport, (MODEL_NUMB_0 / 2)); |
| 1106 | pCardInfo->si_card_model[0] = (unsigned char)(temp >> 8); |
| 1107 | temp = FPT_utilEERead(ioport, (MODEL_NUMB_2 / 2)); |
| 1108 | |
| 1109 | pCardInfo->si_card_model[1] = (unsigned char)(temp & 0x00FF); |
| 1110 | pCardInfo->si_card_model[2] = (unsigned char)(temp >> 8); |
| 1111 | } |
| 1112 | |
| 1113 | if (pCardInfo->si_card_model[1] == '3') { |
| 1114 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1115 | pCardInfo->si_mflags |= LOW_BYTE_TERM; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1116 | } else if (pCardInfo->si_card_model[2] == '0') { |
| 1117 | temp = RD_HARPOON(ioport + hp_xfer_pad); |
| 1118 | WR_HARPOON(ioport + hp_xfer_pad, (temp & ~BIT(4))); |
| 1119 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1120 | pCardInfo->si_mflags |= LOW_BYTE_TERM; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1121 | WR_HARPOON(ioport + hp_xfer_pad, (temp | BIT(4))); |
| 1122 | if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7)) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1123 | pCardInfo->si_mflags |= HIGH_BYTE_TERM; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1124 | WR_HARPOON(ioport + hp_xfer_pad, temp); |
| 1125 | } else { |
| 1126 | temp = RD_HARPOON(ioport + hp_ee_ctrl); |
| 1127 | temp2 = RD_HARPOON(ioport + hp_xfer_pad); |
| 1128 | WR_HARPOON(ioport + hp_ee_ctrl, (temp | SEE_CS)); |
| 1129 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 | BIT(4))); |
| 1130 | temp3 = 0; |
| 1131 | for (i = 0; i < 8; i++) { |
| 1132 | temp3 <<= 1; |
| 1133 | if (!(RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))) |
| 1134 | temp3 |= 1; |
| 1135 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 & ~BIT(4))); |
| 1136 | WR_HARPOON(ioport + hp_xfer_pad, (temp2 | BIT(4))); |
| 1137 | } |
| 1138 | WR_HARPOON(ioport + hp_ee_ctrl, temp); |
| 1139 | WR_HARPOON(ioport + hp_xfer_pad, temp2); |
| 1140 | if (!(temp3 & BIT(7))) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1141 | pCardInfo->si_mflags |= LOW_BYTE_TERM; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1142 | if (!(temp3 & BIT(6))) |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1143 | pCardInfo->si_mflags |= HIGH_BYTE_TERM; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1144 | } |
| 1145 | |
| 1146 | ARAM_ACCESS(ioport); |
| 1147 | |
| 1148 | for (i = 0; i < 4; i++) { |
| 1149 | |
| 1150 | pCardInfo->si_XlatInfo[i] = |
| 1151 | RD_HARPOON(ioport + hp_aramBase + BIOS_DATA_OFFSET + i); |
| 1152 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | |
| 1154 | /* return with -1 if no sort, else return with |
| 1155 | logical card number sorted by BIOS (zero-based) */ |
| 1156 | |
| 1157 | pCardInfo->si_relative_cardnum = |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1158 | (unsigned |
| 1159 | char)(RD_HARPOON(ioport + hp_aramBase + BIOS_RELATIVE_CARD) - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1161 | SGRAM_ACCESS(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1163 | FPT_s_PhaseTbl[0] = FPT_phaseDataOut; |
| 1164 | FPT_s_PhaseTbl[1] = FPT_phaseDataIn; |
| 1165 | FPT_s_PhaseTbl[2] = FPT_phaseIllegal; |
| 1166 | FPT_s_PhaseTbl[3] = FPT_phaseIllegal; |
| 1167 | FPT_s_PhaseTbl[4] = FPT_phaseCommand; |
| 1168 | FPT_s_PhaseTbl[5] = FPT_phaseStatus; |
| 1169 | FPT_s_PhaseTbl[6] = FPT_phaseMsgOut; |
| 1170 | FPT_s_PhaseTbl[7] = FPT_phaseMsgIn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1172 | pCardInfo->si_present = 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1174 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | } |
| 1176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | /*--------------------------------------------------------------------- |
| 1178 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1179 | * Function: FlashPoint_HardwareResetHostAdapter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | * |
| 1181 | * Description: Setup adapter for normal operation (hard reset). |
| 1182 | * |
| 1183 | *---------------------------------------------------------------------*/ |
| 1184 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1185 | static void *FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1186 | *pCardInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1188 | struct sccb_card *CurrCard = NULL; |
| 1189 | struct nvram_info *pCurrNvRam; |
| 1190 | unsigned char i, j, thisCard, ScamFlg; |
| 1191 | unsigned short temp, sync_bit_map, id; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1192 | u32 ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1194 | ioport = pCardInfo->si_baseaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1195 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1196 | for (thisCard = 0; thisCard <= MAX_CARDS; thisCard++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1198 | if (thisCard == MAX_CARDS) |
| 1199 | return (void *)FAILURE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1201 | if (FPT_BL_Card[thisCard].ioPort == ioport) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1203 | CurrCard = &FPT_BL_Card[thisCard]; |
| 1204 | FPT_SccbMgrTableInitCard(CurrCard, thisCard); |
| 1205 | break; |
| 1206 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1208 | else if (FPT_BL_Card[thisCard].ioPort == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1210 | FPT_BL_Card[thisCard].ioPort = ioport; |
| 1211 | CurrCard = &FPT_BL_Card[thisCard]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1212 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1213 | if (FPT_mbCards) |
| 1214 | for (i = 0; i < FPT_mbCards; i++) { |
| 1215 | if (CurrCard->ioPort == |
| 1216 | FPT_nvRamInfo[i].niBaseAddr) |
| 1217 | CurrCard->pNvRamInfo = |
| 1218 | &FPT_nvRamInfo[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1220 | FPT_SccbMgrTableInitCard(CurrCard, thisCard); |
| 1221 | CurrCard->cardIndex = thisCard; |
| 1222 | CurrCard->cardInfo = pCardInfo; |
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 | break; |
| 1225 | } |
| 1226 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | |
| 1228 | pCurrNvRam = CurrCard->pNvRamInfo; |
| 1229 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1230 | if (pCurrNvRam) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1231 | ScamFlg = pCurrNvRam->niScamConf; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1232 | } else { |
| 1233 | ScamFlg = |
| 1234 | (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | } |
| 1236 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1237 | FPT_BusMasterInit(ioport); |
| 1238 | FPT_XbowInit(ioport, ScamFlg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1240 | FPT_autoLoadDefaultMap(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1241 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1242 | for (i = 0, id = 0x01; i != pCardInfo->si_id; i++, id <<= 1) { |
| 1243 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1245 | WR_HARPOON(ioport + hp_selfid_0, id); |
| 1246 | WR_HARPOON(ioport + hp_selfid_1, 0x00); |
| 1247 | WR_HARPOON(ioport + hp_arb_id, pCardInfo->si_id); |
| 1248 | CurrCard->ourId = pCardInfo->si_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1250 | i = (unsigned char)pCardInfo->si_mflags; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1251 | if (i & SCSI_PARITY_ENA) |
| 1252 | WR_HARPOON(ioport + hp_portctrl_1, (HOST_MODE8 | CHK_SCSI_P)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1253 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1254 | j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L); |
| 1255 | if (i & LOW_BYTE_TERM) |
| 1256 | j |= SCSI_TERM_ENA_L; |
| 1257 | WR_HARPOON(ioport + hp_bm_ctrl, j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1259 | j = (RD_HARPOON(ioport + hp_ee_ctrl) & ~SCSI_TERM_ENA_H); |
| 1260 | if (i & HIGH_BYTE_TERM) |
| 1261 | j |= SCSI_TERM_ENA_H; |
| 1262 | WR_HARPOON(ioport + hp_ee_ctrl, j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1264 | if (!(pCardInfo->si_mflags & SOFT_RESET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1266 | FPT_sresb(ioport, thisCard); |
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_scini(thisCard, pCardInfo->si_id, 0); |
| 1269 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | |
Randy Dunlap | 4d43115 | 2021-05-29 16:48:57 -0700 | [diff] [blame] | 1271 | if (pCardInfo->si_mflags & POST_ALL_UNDERRRUNS) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1272 | CurrCard->globalFlags |= F_NO_FILTER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1274 | if (pCurrNvRam) { |
| 1275 | if (pCurrNvRam->niSysConf & 0x10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | CurrCard->globalFlags |= F_GREEN_PC; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1277 | } else { |
| 1278 | if (FPT_utilEERead(ioport, (SYSTEM_CONFIG / 2)) & GREEN_PC_ENA) |
| 1279 | CurrCard->globalFlags |= F_GREEN_PC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | } |
| 1281 | |
| 1282 | /* Set global flag to indicate Re-Negotiation to be done on all |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1283 | ckeck condition */ |
| 1284 | if (pCurrNvRam) { |
| 1285 | if (pCurrNvRam->niScsiConf & 0x04) |
| 1286 | CurrCard->globalFlags |= F_DO_RENEGO; |
| 1287 | } else { |
| 1288 | if (FPT_utilEERead(ioport, (SCSI_CONFIG / 2)) & RENEGO_ENA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | CurrCard->globalFlags |= F_DO_RENEGO; |
| 1290 | } |
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 (pCurrNvRam) { |
| 1293 | if (pCurrNvRam->niScsiConf & 0x08) |
| 1294 | CurrCard->globalFlags |= F_CONLUN_IO; |
| 1295 | } else { |
| 1296 | if (FPT_utilEERead(ioport, (SCSI_CONFIG / 2)) & CONNIO_ENA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | CurrCard->globalFlags |= F_CONLUN_IO; |
| 1298 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1299 | |
| 1300 | temp = pCardInfo->si_per_targ_no_disc; |
| 1301 | |
| 1302 | for (i = 0, id = 1; i < MAX_SCSI_TAR; i++, id <<= 1) { |
| 1303 | |
| 1304 | if (temp & id) |
| 1305 | FPT_sccbMgrTbl[thisCard][i].TarStatus |= TAR_ALLOW_DISC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | } |
| 1307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1308 | sync_bit_map = 0x0001; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1310 | for (id = 0; id < (MAX_SCSI_TAR / 2); id++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1311 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1312 | if (pCurrNvRam) { |
| 1313 | temp = (unsigned short)pCurrNvRam->niSyncTbl[id]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) + |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1315 | (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000)); |
| 1316 | } else |
| 1317 | temp = |
| 1318 | FPT_utilEERead(ioport, |
| 1319 | (unsigned short)((SYNC_RATE_TBL / 2) |
| 1320 | + id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1321 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1322 | for (i = 0; i < 2; temp >>= 8, i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1323 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1324 | if (pCardInfo->si_per_targ_init_sync & sync_bit_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1326 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1327 | i].TarEEValue = |
| 1328 | (unsigned char)temp; |
| 1329 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1331 | else { |
| 1332 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1333 | i].TarStatus |= |
| 1334 | SYNC_SUPPORTED; |
| 1335 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1336 | i].TarEEValue = |
| 1337 | (unsigned char)(temp & ~EE_SYNC_MASK); |
| 1338 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | /* if ((pCardInfo->si_per_targ_wide_nego & sync_bit_map) || |
| 1341 | (id*2+i >= 8)){ |
| 1342 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1343 | if (pCardInfo->si_per_targ_wide_nego & sync_bit_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1345 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1346 | i].TarEEValue |= |
| 1347 | EE_WIDE_SCSI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1349 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1351 | else { /* NARROW SCSI */ |
| 1352 | FPT_sccbMgrTbl[thisCard][id * 2 + |
| 1353 | i].TarStatus |= |
| 1354 | WIDE_NEGOCIATED; |
| 1355 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1356 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1357 | sync_bit_map <<= 1; |
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 | } |
| 1360 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1362 | WR_HARPOON((ioport + hp_semaphore), |
| 1363 | (unsigned char)(RD_HARPOON((ioport + hp_semaphore)) | |
| 1364 | SCCB_MGR_PRESENT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1366 | return (void *)CurrCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | } |
| 1368 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1369 | static void FlashPoint_ReleaseHostAdapter(void *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1370 | { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1371 | unsigned char i; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1372 | u32 portBase; |
| 1373 | u32 regOffset; |
| 1374 | u32 scamData; |
| 1375 | u32 *pScamTbl; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1376 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1378 | pCurrNvRam = ((struct sccb_card *)pCurrCard)->pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1380 | if (pCurrNvRam) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 1381 | FPT_WrStack(pCurrNvRam->niBaseAddr, 0, pCurrNvRam->niModel); |
| 1382 | FPT_WrStack(pCurrNvRam->niBaseAddr, 1, pCurrNvRam->niSysConf); |
| 1383 | FPT_WrStack(pCurrNvRam->niBaseAddr, 2, pCurrNvRam->niScsiConf); |
| 1384 | FPT_WrStack(pCurrNvRam->niBaseAddr, 3, pCurrNvRam->niScamConf); |
| 1385 | FPT_WrStack(pCurrNvRam->niBaseAddr, 4, pCurrNvRam->niAdapId); |
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 | for (i = 0; i < MAX_SCSI_TAR / 2; i++) |
| 1388 | FPT_WrStack(pCurrNvRam->niBaseAddr, |
| 1389 | (unsigned char)(i + 5), |
| 1390 | pCurrNvRam->niSyncTbl[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | |
| 1392 | portBase = pCurrNvRam->niBaseAddr; |
| 1393 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1394 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 1395 | regOffset = hp_aramBase + 64 + i * 4; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1396 | pScamTbl = (u32 *)&pCurrNvRam->niScamTbl[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | scamData = *pScamTbl; |
| 1398 | WR_HARP32(portBase, regOffset, scamData); |
| 1399 | } |
| 1400 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1401 | } else { |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1402 | FPT_WrStack(((struct sccb_card *)pCurrCard)->ioPort, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1403 | } |
| 1404 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1405 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1406 | static void FPT_RNVRamData(struct nvram_info *pNvRamInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1407 | { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1408 | unsigned char i; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1409 | u32 portBase; |
| 1410 | u32 regOffset; |
| 1411 | u32 scamData; |
| 1412 | u32 *pScamTbl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1414 | pNvRamInfo->niModel = FPT_RdStack(pNvRamInfo->niBaseAddr, 0); |
| 1415 | pNvRamInfo->niSysConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 1); |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 1416 | pNvRamInfo->niScsiConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 2); |
| 1417 | pNvRamInfo->niScamConf = FPT_RdStack(pNvRamInfo->niBaseAddr, 3); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1418 | pNvRamInfo->niAdapId = FPT_RdStack(pNvRamInfo->niBaseAddr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1420 | for (i = 0; i < MAX_SCSI_TAR / 2; i++) |
| 1421 | pNvRamInfo->niSyncTbl[i] = |
| 1422 | FPT_RdStack(pNvRamInfo->niBaseAddr, (unsigned char)(i + 5)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | |
| 1424 | portBase = pNvRamInfo->niBaseAddr; |
| 1425 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1426 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 1427 | regOffset = hp_aramBase + 64 + i * 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | RD_HARP32(portBase, regOffset, scamData); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1429 | pScamTbl = (u32 *)&pNvRamInfo->niScamTbl[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | *pScamTbl = scamData; |
| 1431 | } |
| 1432 | |
| 1433 | } |
| 1434 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1435 | static unsigned char FPT_RdStack(u32 portBase, unsigned char index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | { |
| 1437 | WR_HARPOON(portBase + hp_stack_addr, index); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1438 | return RD_HARPOON(portBase + hp_stack_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | } |
| 1440 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1441 | static void FPT_WrStack(u32 portBase, unsigned char index, unsigned char data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1442 | { |
| 1443 | WR_HARPOON(portBase + hp_stack_addr, index); |
| 1444 | WR_HARPOON(portBase + hp_stack_data, data); |
| 1445 | } |
| 1446 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1447 | static unsigned char FPT_ChkIfChipInitialized(u32 ioPort) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1449 | if ((RD_HARPOON(ioPort + hp_arb_id) & 0x0f) != FPT_RdStack(ioPort, 4)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1450 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1451 | if ((RD_HARPOON(ioPort + hp_clkctrl_0) & CLKCTRL_DEFAULT) |
| 1452 | != CLKCTRL_DEFAULT) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1453 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1454 | if ((RD_HARPOON(ioPort + hp_seltimeout) == TO_250ms) || |
| 1455 | (RD_HARPOON(ioPort + hp_seltimeout) == TO_290ms)) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1456 | return 1; |
| 1457 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | |
| 1459 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1460 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1461 | /*--------------------------------------------------------------------- |
| 1462 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1463 | * Function: FlashPoint_StartCCB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | * |
| 1465 | * Description: Start a command pointed to by p_Sccb. When the |
| 1466 | * command is completed it will be returned via the |
| 1467 | * callback function. |
| 1468 | * |
| 1469 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1470 | static void FlashPoint_StartCCB(void *curr_card, struct sccb *p_Sccb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1472 | u32 ioport; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1473 | unsigned char thisCard, lun; |
| 1474 | struct sccb *pSaveSccb; |
| 1475 | CALL_BK_FN callback; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1476 | struct sccb_card *pCurrCard = curr_card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1478 | thisCard = pCurrCard->cardIndex; |
| 1479 | ioport = pCurrCard->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1480 | |
Adrian Bunk | 1377d8d | 2008-04-23 12:51:10 +0300 | [diff] [blame] | 1481 | if ((p_Sccb->TargID >= MAX_SCSI_TAR) || (p_Sccb->Lun >= MAX_LUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | p_Sccb->HostStatus = SCCB_COMPLETE; |
| 1484 | p_Sccb->SccbStatus = SCCB_ERROR; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1485 | callback = (CALL_BK_FN) p_Sccb->SccbCallback; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | if (callback) |
| 1487 | callback(p_Sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | return; |
| 1490 | } |
| 1491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1492 | FPT_sinits(p_Sccb, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1494 | if (!pCurrCard->cmdCounter) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1495 | WR_HARPOON(ioport + hp_semaphore, |
| 1496 | (RD_HARPOON(ioport + hp_semaphore) |
| 1497 | | SCCB_MGR_ACTIVE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1499 | if (pCurrCard->globalFlags & F_GREEN_PC) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1500 | WR_HARPOON(ioport + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 1501 | WR_HARPOON(ioport + hp_sys_ctrl, 0x00); |
| 1502 | } |
| 1503 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1505 | pCurrCard->cmdCounter++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1507 | if (RD_HARPOON(ioport + hp_semaphore) & BIOS_IN_USE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1508 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1509 | WR_HARPOON(ioport + hp_semaphore, |
| 1510 | (RD_HARPOON(ioport + hp_semaphore) |
| 1511 | | TICKLE_ME)); |
| 1512 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1513 | pSaveSccb = |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1514 | pCurrCard->currentSCCB; |
| 1515 | pCurrCard->currentSCCB = p_Sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1516 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], thisCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1517 | pCurrCard->currentSCCB = |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1518 | pSaveSccb; |
| 1519 | } else { |
| 1520 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1521 | } |
| 1522 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1524 | else if ((RD_HARPOON(ioport + hp_page_ctrl) & G_INT_DISABLE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1526 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
| 1527 | pSaveSccb = |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1528 | pCurrCard->currentSCCB; |
| 1529 | pCurrCard->currentSCCB = p_Sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1530 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], thisCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1531 | pCurrCard->currentSCCB = |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1532 | pSaveSccb; |
| 1533 | } else { |
| 1534 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1535 | } |
| 1536 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1538 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1539 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1540 | MDISABLE_INT(ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1542 | if ((pCurrCard->globalFlags & F_CONLUN_IO) && |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1543 | ((FPT_sccbMgrTbl[thisCard][p_Sccb->TargID]. |
| 1544 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1545 | lun = p_Sccb->Lun; |
| 1546 | else |
| 1547 | lun = 0; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1548 | if ((pCurrCard->currentSCCB == NULL) && |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1549 | (FPT_sccbMgrTbl[thisCard][p_Sccb->TargID].TarSelQ_Cnt == 0) |
| 1550 | && (FPT_sccbMgrTbl[thisCard][p_Sccb->TargID].TarLUNBusy[lun] |
| 1551 | == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1553 | pCurrCard->currentSCCB = p_Sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1554 | FPT_ssel(p_Sccb->SccbIOPort, thisCard); |
| 1555 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1557 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1558 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1559 | if (p_Sccb->OperationCode == RESET_COMMAND) { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1560 | pSaveSccb = pCurrCard->currentSCCB; |
| 1561 | pCurrCard->currentSCCB = p_Sccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1562 | FPT_queueSelectFail(&FPT_BL_Card[thisCard], |
| 1563 | thisCard); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1564 | pCurrCard->currentSCCB = pSaveSccb; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1565 | } else { |
| 1566 | FPT_queueAddSccb(p_Sccb, thisCard); |
| 1567 | } |
| 1568 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1570 | MENABLE_INT(ioport); |
| 1571 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1572 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1573 | } |
| 1574 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | /*--------------------------------------------------------------------- |
| 1576 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1577 | * Function: FlashPoint_AbortCCB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | * |
| 1579 | * Description: Abort the command pointed to by p_Sccb. When the |
| 1580 | * command is completed it will be returned via the |
| 1581 | * callback function. |
| 1582 | * |
| 1583 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1584 | static int FlashPoint_AbortCCB(void *pCurrCard, struct sccb *p_Sccb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1585 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1586 | u32 ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 1588 | unsigned char thisCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1589 | CALL_BK_FN callback; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1590 | struct sccb *pSaveSCCB; |
| 1591 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1593 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1594 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1595 | thisCard = ((struct sccb_card *)pCurrCard)->cardIndex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1596 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1597 | if (!(RD_HARPOON(ioport + hp_page_ctrl) & G_INT_DISABLE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1598 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1599 | if (FPT_queueFindSccb(p_Sccb, thisCard)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1600 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1601 | ((struct sccb_card *)pCurrCard)->cmdCounter--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1602 | |
Alexey Dobriyan | 13e6851 | 2006-03-08 00:14:34 -0800 | [diff] [blame] | 1603 | if (!((struct sccb_card *)pCurrCard)->cmdCounter) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1604 | WR_HARPOON(ioport + hp_semaphore, |
| 1605 | (RD_HARPOON(ioport + hp_semaphore) |
| 1606 | & (unsigned |
| 1607 | char)(~(SCCB_MGR_ACTIVE | |
| 1608 | TICKLE_ME)))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1609 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1610 | p_Sccb->SccbStatus = SCCB_ABORT; |
| 1611 | callback = p_Sccb->SccbCallback; |
| 1612 | callback(p_Sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1614 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1615 | } |
| 1616 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1617 | else { |
| 1618 | if (((struct sccb_card *)pCurrCard)->currentSCCB == |
| 1619 | p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1620 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1621 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1622 | |
| 1623 | } |
| 1624 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1625 | else { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1626 | if (p_Sccb->Sccb_tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | MDISABLE_INT(ioport); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1628 | if (((struct sccb_card *)pCurrCard)-> |
| 1629 | discQ_Tbl[p_Sccb->Sccb_tag] == |
| 1630 | p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1631 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1632 | p_Sccb->Sccb_scsistat = |
| 1633 | ABORT_ST; |
| 1634 | p_Sccb->Sccb_scsimsg = |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 1635 | ABORT_TASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1636 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1637 | if (((struct sccb_card *) |
| 1638 | pCurrCard)->currentSCCB == |
| 1639 | NULL) { |
| 1640 | ((struct sccb_card *) |
| 1641 | pCurrCard)-> |
| 1642 | currentSCCB = p_Sccb; |
| 1643 | FPT_ssel(ioport, |
| 1644 | thisCard); |
| 1645 | } else { |
| 1646 | pSaveSCCB = |
| 1647 | ((struct sccb_card |
| 1648 | *)pCurrCard)-> |
| 1649 | currentSCCB; |
| 1650 | ((struct sccb_card *) |
| 1651 | pCurrCard)-> |
| 1652 | currentSCCB = p_Sccb; |
| 1653 | FPT_queueSelectFail((struct sccb_card *)pCurrCard, thisCard); |
| 1654 | ((struct sccb_card *) |
| 1655 | pCurrCard)-> |
| 1656 | currentSCCB = pSaveSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | } |
| 1658 | } |
| 1659 | MENABLE_INT(ioport); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1660 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1661 | } else { |
| 1662 | currTar_Info = |
| 1663 | &FPT_sccbMgrTbl[thisCard][p_Sccb-> |
| 1664 | TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1666 | if (FPT_BL_Card[thisCard]. |
| 1667 | discQ_Tbl[currTar_Info-> |
| 1668 | LunDiscQ_Idx[p_Sccb->Lun]] |
| 1669 | == p_Sccb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1670 | p_Sccb->SccbStatus = SCCB_ABORT; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1671 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1672 | } |
| 1673 | } |
| 1674 | } |
| 1675 | } |
| 1676 | } |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1677 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1678 | } |
| 1679 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1680 | /*--------------------------------------------------------------------- |
| 1681 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1682 | * Function: FlashPoint_InterruptPending |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1683 | * |
| 1684 | * Description: Do a quick check to determine if there is a pending |
| 1685 | * interrupt for this card and disable the IRQ Pin if so. |
| 1686 | * |
| 1687 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1688 | static unsigned char FlashPoint_InterruptPending(void *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1689 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1690 | u32 ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1691 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1692 | ioport = ((struct sccb_card *)pCurrCard)->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1694 | if (RD_HARPOON(ioport + hp_int_status) & INT_ASSERTED) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1695 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1696 | } |
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 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1700 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | } |
| 1702 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | /*--------------------------------------------------------------------- |
| 1704 | * |
Alexey Dobriyan | d8b6b8b | 2006-03-08 00:14:23 -0800 | [diff] [blame] | 1705 | * Function: FlashPoint_HandleInterrupt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1706 | * |
| 1707 | * Description: This is our entry point when an interrupt is generated |
| 1708 | * by the card and the upper level driver passes it on to |
| 1709 | * us. |
| 1710 | * |
| 1711 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1712 | static int FlashPoint_HandleInterrupt(void *pcard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1714 | struct sccb *currSCCB; |
| 1715 | unsigned char thisCard, result, bm_status, bm_int_st; |
| 1716 | unsigned short hp_int; |
| 1717 | unsigned char i, target; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1718 | struct sccb_card *pCurrCard = pcard; |
| 1719 | u32 ioport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1720 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1721 | thisCard = pCurrCard->cardIndex; |
| 1722 | ioport = pCurrCard->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 | MDISABLE_INT(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 ((bm_int_st = RD_HARPOON(ioport + hp_int_status)) & EXT_STATUS_ON) |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1727 | bm_status = RD_HARPOON(ioport + hp_ext_status) & |
| 1728 | (unsigned char)BAD_EXT_STATUS; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1729 | else |
| 1730 | bm_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1732 | WR_HARPOON(ioport + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1734 | while ((hp_int = RDW_HARPOON((ioport + hp_intstat)) & |
| 1735 | FPT_default_intena) | bm_status) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1737 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1738 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1739 | if (hp_int & (FIFO | TIMEOUT | RESET | SCAM_SEL) || bm_status) { |
| 1740 | result = |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1741 | FPT_SccbMgr_bad_isr(ioport, thisCard, pCurrCard, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1742 | hp_int); |
| 1743 | WRW_HARPOON((ioport + hp_intstat), |
| 1744 | (FIFO | TIMEOUT | RESET | SCAM_SEL)); |
| 1745 | bm_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1746 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1747 | if (result) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1748 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1749 | MENABLE_INT(ioport); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1750 | return result; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1751 | } |
| 1752 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1753 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1754 | else if (hp_int & ICMD_COMP) { |
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 | if (!(hp_int & BUS_FREE)) { |
| 1757 | /* Wait for the BusFree before starting a new command. We |
| 1758 | must also check for being reselected since the BusFree |
| 1759 | may not show up if another device reselects us in 1.5us or |
| 1760 | less. SRR Wednesday, 3/8/1995. |
| 1761 | */ |
| 1762 | while (! |
| 1763 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1764 | (BUS_FREE | RSEL))) ; |
| 1765 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1767 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1769 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1770 | |
| 1771 | /* WRW_HARPOON((ioport+hp_intstat), |
| 1772 | (BUS_FREE | ICMD_COMP | ITAR_DISC | XFER_CNT_0)); |
| 1773 | */ |
| 1774 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1775 | WRW_HARPOON((ioport + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1776 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1777 | FPT_autoCmdCmplt(ioport, thisCard); |
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 | } |
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 | else if (hp_int & ITAR_DISC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1783 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1784 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1785 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1786 | if (RD_HARPOON(ioport + hp_gp_reg_1) == |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 1787 | SAVE_POINTERS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1789 | WR_HARPOON(ioport + hp_gp_reg_1, 0x00); |
| 1790 | currSCCB->Sccb_XferState |= F_NO_DATA_YET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1792 | currSCCB->Sccb_savedATC = currSCCB->Sccb_ATC; |
| 1793 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1794 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1795 | currSCCB->Sccb_scsistat = DISCONNECT_ST; |
| 1796 | FPT_queueDisconnect(currSCCB, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1797 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1798 | /* Wait for the BusFree before starting a new command. We |
| 1799 | must also check for being reselected since the BusFree |
| 1800 | may not show up if another device reselects us in 1.5us or |
| 1801 | less. SRR Wednesday, 3/8/1995. |
| 1802 | */ |
| 1803 | while (! |
| 1804 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1805 | (BUS_FREE | RSEL)) |
| 1806 | && !((RDW_HARPOON((ioport + hp_intstat)) & PHASE) |
| 1807 | && RD_HARPOON((ioport + hp_scsisig)) == |
| 1808 | (SCSI_BSY | SCSI_REQ | SCSI_CD | SCSI_MSG | |
| 1809 | SCSI_IOBIT))) ; |
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 | /* |
| 1812 | The additional loop exit condition above detects a timing problem |
| 1813 | with the revision D/E harpoon chips. The caller should reset the |
| 1814 | host adapter to recover when 0xFE is returned. |
| 1815 | */ |
| 1816 | if (! |
| 1817 | (RDW_HARPOON((ioport + hp_intstat)) & |
| 1818 | (BUS_FREE | RSEL))) { |
| 1819 | MENABLE_INT(ioport); |
| 1820 | return 0xFE; |
| 1821 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1823 | WRW_HARPOON((ioport + hp_intstat), |
| 1824 | (BUS_FREE | ITAR_DISC)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1826 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1827 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1828 | } |
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 | else if (hp_int & RSEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1831 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1832 | WRW_HARPOON((ioport + hp_intstat), |
| 1833 | (PROG_HLT | RSEL | PHASE | BUS_FREE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1834 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1835 | if (RDW_HARPOON((ioport + hp_intstat)) & ITAR_DISC) { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1836 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1837 | FPT_phaseChkFifo(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1839 | if (RD_HARPOON(ioport + hp_gp_reg_1) == |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 1840 | SAVE_POINTERS) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1841 | WR_HARPOON(ioport + hp_gp_reg_1, 0x00); |
| 1842 | currSCCB->Sccb_XferState |= |
| 1843 | F_NO_DATA_YET; |
| 1844 | currSCCB->Sccb_savedATC = |
| 1845 | currSCCB->Sccb_ATC; |
| 1846 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1847 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1848 | WRW_HARPOON((ioport + hp_intstat), |
| 1849 | (BUS_FREE | ITAR_DISC)); |
| 1850 | currSCCB->Sccb_scsistat = DISCONNECT_ST; |
| 1851 | FPT_queueDisconnect(currSCCB, thisCard); |
| 1852 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1853 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1854 | FPT_sres(ioport, thisCard, pCurrCard); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1855 | FPT_phaseDecode(ioport, thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1856 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1857 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1858 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1859 | else if ((hp_int & IDO_STRT) && (!(hp_int & BUS_FREE))) { |
| 1860 | |
| 1861 | WRW_HARPOON((ioport + hp_intstat), |
| 1862 | (IDO_STRT | XFER_CNT_0)); |
| 1863 | FPT_phaseDecode(ioport, thisCard); |
| 1864 | |
| 1865 | } |
| 1866 | |
| 1867 | else if ((hp_int & IUNKWN) || (hp_int & PROG_HLT)) { |
| 1868 | WRW_HARPOON((ioport + hp_intstat), |
| 1869 | (PHASE | IUNKWN | PROG_HLT)); |
| 1870 | if ((RD_HARPOON(ioport + hp_prgmcnt_0) & (unsigned char) |
| 1871 | 0x3f) < (unsigned char)SELCHK) { |
| 1872 | FPT_phaseDecode(ioport, thisCard); |
| 1873 | } else { |
| 1874 | /* Harpoon problem some SCSI target device respond to selection |
| 1875 | with short BUSY pulse (<400ns) this will make the Harpoon is not able |
| 1876 | to latch the correct Target ID into reg. x53. |
| 1877 | The work around require to correct this reg. But when write to this |
| 1878 | reg. (0x53) also increment the FIFO write addr reg (0x6f), thus we |
| 1879 | need to read this reg first then restore it later. After update to 0x53 */ |
| 1880 | |
| 1881 | i = (unsigned |
| 1882 | char)(RD_HARPOON(ioport + hp_fifowrite)); |
| 1883 | target = |
| 1884 | (unsigned |
| 1885 | char)(RD_HARPOON(ioport + hp_gp_reg_3)); |
| 1886 | WR_HARPOON(ioport + hp_xfer_pad, |
| 1887 | (unsigned char)ID_UNLOCK); |
| 1888 | WR_HARPOON(ioport + hp_select_id, |
| 1889 | (unsigned char)(target | target << |
| 1890 | 4)); |
| 1891 | WR_HARPOON(ioport + hp_xfer_pad, |
| 1892 | (unsigned char)0x00); |
| 1893 | WR_HARPOON(ioport + hp_fifowrite, i); |
| 1894 | WR_HARPOON(ioport + hp_autostart_3, |
| 1895 | (AUTO_IMMED + TAG_STRT)); |
| 1896 | } |
| 1897 | } |
| 1898 | |
| 1899 | else if (hp_int & XFER_CNT_0) { |
| 1900 | |
| 1901 | WRW_HARPOON((ioport + hp_intstat), XFER_CNT_0); |
| 1902 | |
| 1903 | FPT_schkdd(ioport, thisCard); |
| 1904 | |
| 1905 | } |
| 1906 | |
| 1907 | else if (hp_int & BUS_FREE) { |
| 1908 | |
| 1909 | WRW_HARPOON((ioport + hp_intstat), BUS_FREE); |
| 1910 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1911 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1912 | |
| 1913 | FPT_hostDataXferAbort(ioport, thisCard, |
| 1914 | currSCCB); |
| 1915 | } |
| 1916 | |
| 1917 | FPT_phaseBusFree(ioport, thisCard); |
| 1918 | } |
| 1919 | |
| 1920 | else if (hp_int & ITICKLE) { |
| 1921 | |
| 1922 | WRW_HARPOON((ioport + hp_intstat), ITICKLE); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1923 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1924 | } |
| 1925 | |
| 1926 | if (((struct sccb_card *)pCurrCard)-> |
| 1927 | globalFlags & F_NEW_SCCB_CMD) { |
| 1928 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1929 | pCurrCard->globalFlags &= ~F_NEW_SCCB_CMD; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1930 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1931 | if (pCurrCard->currentSCCB == NULL) |
| 1932 | FPT_queueSearchSelect(pCurrCard, thisCard); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1933 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1934 | if (pCurrCard->currentSCCB != NULL) { |
| 1935 | pCurrCard->globalFlags &= ~F_NEW_SCCB_CMD; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1936 | FPT_ssel(ioport, thisCard); |
| 1937 | } |
| 1938 | |
| 1939 | break; |
| 1940 | |
| 1941 | } |
| 1942 | |
| 1943 | } /*end while */ |
| 1944 | |
| 1945 | MENABLE_INT(ioport); |
| 1946 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 1947 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1948 | } |
| 1949 | |
| 1950 | /*--------------------------------------------------------------------- |
| 1951 | * |
| 1952 | * Function: Sccb_bad_isr |
| 1953 | * |
| 1954 | * Description: Some type of interrupt has occurred which is slightly |
| 1955 | * out of the ordinary. We will now decode it fully, in |
| 1956 | * this routine. This is broken up in an attempt to save |
| 1957 | * processing time. |
| 1958 | * |
| 1959 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 1960 | 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] | 1961 | struct sccb_card *pCurrCard, |
| 1962 | unsigned short p_int) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1963 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1964 | unsigned char temp, ScamFlg; |
| 1965 | struct sccb_mgr_tar_info *currTar_Info; |
| 1966 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1967 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1968 | if (RD_HARPOON(p_port + hp_ext_status) & |
| 1969 | (BM_FORCE_OFF | PCI_DEV_TMOUT | BM_PARITY_ERR | PIO_OVERRUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1970 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1971 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1972 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1973 | FPT_hostDataXferAbort(p_port, p_card, |
| 1974 | pCurrCard->currentSCCB); |
| 1975 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1977 | if (RD_HARPOON(p_port + hp_pci_stat_cfg) & REC_MASTER_ABORT) |
| 1978 | { |
| 1979 | WR_HARPOON(p_port + hp_pci_stat_cfg, |
| 1980 | (RD_HARPOON(p_port + hp_pci_stat_cfg) & |
| 1981 | ~REC_MASTER_ABORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1982 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1983 | WR_HARPOON(p_port + hp_host_blk_cnt, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1984 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1985 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1986 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1987 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1988 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1989 | if (!pCurrCard->currentSCCB->HostStatus) |
| 1990 | pCurrCard->currentSCCB->HostStatus = |
| 1991 | SCCB_BM_ERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1992 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1993 | FPT_sxfrp(p_port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1994 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 1995 | temp = (unsigned char)(RD_HARPOON(p_port + hp_ee_ctrl) & |
| 1996 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)); |
| 1997 | WR_HARPOON(p_port + hp_ee_ctrl, |
| 1998 | ((unsigned char)temp | SEE_MS | SEE_CS)); |
| 1999 | WR_HARPOON(p_port + hp_ee_ctrl, temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2001 | if (! |
| 2002 | (RDW_HARPOON((p_port + hp_intstat)) & |
| 2003 | (BUS_FREE | RESET))) { |
| 2004 | FPT_phaseDecode(p_port, p_card); |
| 2005 | } |
| 2006 | } |
| 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 | else if (p_int & RESET) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2010 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2011 | WR_HARPOON(p_port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
| 2012 | WR_HARPOON(p_port + hp_sys_ctrl, 0x00); |
| 2013 | if (pCurrCard->currentSCCB != NULL) { |
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 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
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 | FPT_hostDataXferAbort(p_port, p_card, |
| 2018 | pCurrCard->currentSCCB); |
| 2019 | } |
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 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2022 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2023 | FPT_sresb(p_port, p_card); |
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 | while (RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST) { |
| 2026 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2027 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2028 | pCurrNvRam = pCurrCard->pNvRamInfo; |
| 2029 | if (pCurrNvRam) { |
| 2030 | ScamFlg = pCurrNvRam->niScamConf; |
| 2031 | } else { |
| 2032 | ScamFlg = |
| 2033 | (unsigned char)FPT_utilEERead(p_port, |
| 2034 | SCAM_CONFIG / 2); |
| 2035 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2036 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2037 | FPT_XbowInit(p_port, ScamFlg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2038 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2039 | FPT_scini(p_card, pCurrCard->ourId, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2041 | return 0xFF; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2042 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2043 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2044 | else if (p_int & FIFO) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2045 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2046 | WRW_HARPOON((p_port + hp_intstat), FIFO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2048 | if (pCurrCard->currentSCCB != NULL) |
| 2049 | FPT_sxfrp(p_port, p_card); |
| 2050 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2051 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2052 | else if (p_int & TIMEOUT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2053 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2054 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2056 | WRW_HARPOON((p_port + hp_intstat), |
| 2057 | (PROG_HLT | TIMEOUT | SEL | BUS_FREE | PHASE | |
| 2058 | IUNKWN)); |
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 | pCurrCard->currentSCCB->HostStatus = SCCB_SELECTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2062 | currTar_Info = |
| 2063 | &FPT_sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID]; |
| 2064 | if ((pCurrCard->globalFlags & F_CONLUN_IO) |
| 2065 | && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 2066 | TAG_Q_TRYING)) |
| 2067 | currTar_Info->TarLUNBusy[pCurrCard->currentSCCB->Lun] = |
| 2068 | 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2070 | currTar_Info->TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2072 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 2073 | currTar_Info->TarSyncCtrl = 0; |
| 2074 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 2075 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2077 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 2078 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2079 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2080 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2081 | FPT_sssyncv(p_port, pCurrCard->currentSCCB->TargID, NARROW_SCSI, |
| 2082 | currTar_Info); |
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 | FPT_queueCmdComplete(pCurrCard, pCurrCard->currentSCCB, p_card); |
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 | } |
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 | else if (p_int & SCAM_SEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2090 | FPT_scarb(p_port, LEVEL2_TAR); |
| 2091 | FPT_scsel(p_port); |
| 2092 | FPT_scasid(p_card, p_port); |
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 | FPT_scbusf(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2095 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2096 | WRW_HARPOON((p_port + hp_intstat), SCAM_SEL); |
| 2097 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2098 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2099 | return 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | } |
| 2101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2102 | /*--------------------------------------------------------------------- |
| 2103 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2104 | * Function: SccbMgrTableInit |
| 2105 | * |
| 2106 | * Description: Initialize all Sccb manager data structures. |
| 2107 | * |
| 2108 | *---------------------------------------------------------------------*/ |
| 2109 | |
Sudip Mukherjee | cd9d715 | 2015-09-16 19:36:20 +0530 | [diff] [blame] | 2110 | static void FPT_SccbMgrTableInitAll(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2112 | unsigned char thisCard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2114 | for (thisCard = 0; thisCard < MAX_CARDS; thisCard++) { |
| 2115 | FPT_SccbMgrTableInitCard(&FPT_BL_Card[thisCard], thisCard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2116 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2117 | FPT_BL_Card[thisCard].ioPort = 0x00; |
| 2118 | FPT_BL_Card[thisCard].cardInfo = NULL; |
| 2119 | FPT_BL_Card[thisCard].cardIndex = 0xFF; |
| 2120 | FPT_BL_Card[thisCard].ourId = 0x00; |
| 2121 | FPT_BL_Card[thisCard].pNvRamInfo = NULL; |
| 2122 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | } |
| 2124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | /*--------------------------------------------------------------------- |
| 2126 | * |
| 2127 | * Function: SccbMgrTableInit |
| 2128 | * |
| 2129 | * Description: Initialize all Sccb manager data structures. |
| 2130 | * |
| 2131 | *---------------------------------------------------------------------*/ |
| 2132 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2133 | static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard, |
| 2134 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2135 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2136 | unsigned char scsiID, qtag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2137 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2138 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2139 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | } |
| 2141 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2142 | for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++) { |
| 2143 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus = 0; |
| 2144 | FPT_sccbMgrTbl[p_card][scsiID].TarEEValue = 0; |
| 2145 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 2146 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2147 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2148 | pCurrCard->scanIndex = 0x00; |
| 2149 | pCurrCard->currentSCCB = NULL; |
| 2150 | pCurrCard->globalFlags = 0x00; |
| 2151 | pCurrCard->cmdCounter = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | pCurrCard->tagQ_Lst = 0x01; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2153 | pCurrCard->discQCount = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | |
| 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_SccbMgrTableInitTarget(unsigned char p_card, |
| 2166 | unsigned char target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | { |
| 2168 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2169 | unsigned char lun, qtag; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2170 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2172 | currTar_Info = &FPT_sccbMgrTbl[p_card][target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2173 | |
| 2174 | currTar_Info->TarSelQ_Cnt = 0; |
| 2175 | currTar_Info->TarSyncCtrl = 0; |
| 2176 | |
| 2177 | currTar_Info->TarSelQ_Head = NULL; |
| 2178 | currTar_Info->TarSelQ_Tail = NULL; |
| 2179 | currTar_Info->TarTagQ_Cnt = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2180 | currTar_Info->TarLUN_CA = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2181 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2182 | for (lun = 0; lun < MAX_LUN; lun++) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2183 | currTar_Info->TarLUNBusy[lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | currTar_Info->LunDiscQ_Idx[lun] = 0; |
| 2185 | } |
| 2186 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2187 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
| 2188 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] != NULL) { |
| 2189 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == |
| 2190 | target) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2191 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 2192 | FPT_BL_Card[p_card].discQCount--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2193 | } |
| 2194 | } |
| 2195 | } |
| 2196 | } |
| 2197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | /*--------------------------------------------------------------------- |
| 2199 | * |
| 2200 | * Function: sfetm |
| 2201 | * |
| 2202 | * Description: Read in a message byte from the SCSI bus, and check |
| 2203 | * for a parity error. |
| 2204 | * |
| 2205 | *---------------------------------------------------------------------*/ |
| 2206 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2207 | static unsigned char FPT_sfm(u32 port, struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2209 | unsigned char message; |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 2210 | unsigned short TimeOutLoop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2211 | |
| 2212 | TimeOutLoop = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2213 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2214 | (TimeOutLoop++ < 20000)) { |
| 2215 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2217 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2218 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2219 | message = RD_HARPOON(port + hp_scsidata_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2221 | WR_HARPOON(port + hp_scsisig, SCSI_ACK + S_MSGI_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2222 | |
| 2223 | if (TimeOutLoop > 20000) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2224 | message = 0x00; /* force message byte = 0 if Time Out on Req */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2226 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 2227 | (RD_HARPOON(port + hp_addstat) & SCSI_PAR_ERR)) { |
| 2228 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
| 2229 | WR_HARPOON(port + hp_xferstat, 0); |
| 2230 | WR_HARPOON(port + hp_fiforead, 0); |
| 2231 | WR_HARPOON(port + hp_fifowrite, 0); |
| 2232 | if (pCurrSCCB != NULL) { |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2233 | pCurrSCCB->Sccb_scsimsg = MSG_PARITY_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | } |
| 2235 | message = 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2236 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | ACCEPT_MSG_ATN(port); |
| 2238 | TimeOutLoop = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2239 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2240 | (TimeOutLoop++ < 20000)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2241 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2242 | if (TimeOutLoop > 20000) { |
| 2243 | WRW_HARPOON((port + hp_intstat), PARITY); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2244 | return message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2245 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2246 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) != |
| 2247 | S_MSGI_PH) { |
| 2248 | WRW_HARPOON((port + hp_intstat), PARITY); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2249 | return message; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2250 | } |
| 2251 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
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 | RD_HARPOON(port + hp_scsidata_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2255 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2256 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2257 | } while (1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2258 | |
| 2259 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 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); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 2264 | return message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | } |
| 2266 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2267 | /*--------------------------------------------------------------------- |
| 2268 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2269 | * Function: FPT_ssel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | * |
| 2271 | * Description: Load up automation and select target device. |
| 2272 | * |
| 2273 | *---------------------------------------------------------------------*/ |
| 2274 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2275 | static void FPT_ssel(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | { |
| 2277 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2278 | unsigned char auto_loaded, i, target, *theCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2280 | u32 cdb_reg; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2281 | struct sccb_card *CurrCard; |
| 2282 | struct sccb *currSCCB; |
| 2283 | struct sccb_mgr_tar_info *currTar_Info; |
| 2284 | unsigned char lastTag, lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2285 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2286 | CurrCard = &FPT_BL_Card[p_card]; |
| 2287 | currSCCB = CurrCard->currentSCCB; |
| 2288 | target = currSCCB->TargID; |
| 2289 | currTar_Info = &FPT_sccbMgrTbl[p_card][target]; |
| 2290 | lastTag = CurrCard->tagQ_Lst; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2292 | ARAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | |
| 2294 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT) |
| 2295 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
| 2296 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2297 | if (((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2298 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2299 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2300 | lun = currSCCB->Lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2301 | else |
| 2302 | lun = 0; |
| 2303 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2304 | if (CurrCard->globalFlags & F_TAG_STARTED) { |
| 2305 | if (!(currSCCB->ControlByte & F_USE_CMD_Q)) { |
| 2306 | if ((currTar_Info->TarLUN_CA == 0) |
| 2307 | && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) |
| 2308 | == TAG_Q_TRYING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2309 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2310 | if (currTar_Info->TarTagQ_Cnt != 0) { |
| 2311 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2312 | FPT_queueSelectFail(CurrCard, p_card); |
| 2313 | SGRAM_ACCESS(port); |
| 2314 | return; |
| 2315 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2316 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2317 | else { |
| 2318 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2319 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2320 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2321 | } |
| 2322 | /*End non-tagged */ |
| 2323 | else { |
| 2324 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2325 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2326 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2327 | } |
| 2328 | /*!Use cmd Q Tagged */ |
| 2329 | else { |
| 2330 | if (currTar_Info->TarLUN_CA == 1) { |
| 2331 | FPT_queueSelectFail(CurrCard, p_card); |
| 2332 | SGRAM_ACCESS(port); |
| 2333 | return; |
| 2334 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2335 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2336 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2337 | |
| 2338 | } /*else use cmd Q tagged */ |
| 2339 | |
| 2340 | } |
| 2341 | /*if glob tagged started */ |
| 2342 | else { |
| 2343 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2344 | } |
| 2345 | |
| 2346 | if ((((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2347 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 2348 | || (!(currSCCB->ControlByte & F_USE_CMD_Q)))) { |
| 2349 | if (CurrCard->discQCount >= QUEUE_DEPTH) { |
| 2350 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2351 | FPT_queueSelectFail(CurrCard, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | SGRAM_ACCESS(port); |
| 2353 | return; |
| 2354 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2355 | for (i = 1; i < QUEUE_DEPTH; i++) { |
| 2356 | if (++lastTag >= QUEUE_DEPTH) |
| 2357 | lastTag = 1; |
| 2358 | if (CurrCard->discQ_Tbl[lastTag] == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2359 | CurrCard->tagQ_Lst = lastTag; |
| 2360 | currTar_Info->LunDiscQ_Idx[lun] = lastTag; |
| 2361 | CurrCard->discQ_Tbl[lastTag] = currSCCB; |
| 2362 | CurrCard->discQCount++; |
| 2363 | break; |
| 2364 | } |
| 2365 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2366 | if (i == QUEUE_DEPTH) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2367 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2368 | FPT_queueSelectFail(CurrCard, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2369 | SGRAM_ACCESS(port); |
| 2370 | return; |
| 2371 | } |
| 2372 | } |
| 2373 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2374 | auto_loaded = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2375 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2376 | WR_HARPOON(port + hp_select_id, target); |
| 2377 | 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] | 2378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2379 | if (currSCCB->OperationCode == RESET_COMMAND) { |
| 2380 | WRW_HARPOON((port + ID_MSG_STRT), (MPM_OP + AMSG_OUT + |
| 2381 | (currSCCB-> |
| 2382 | Sccb_idmsg & ~DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2384 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + NP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2385 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2386 | currSCCB->Sccb_scsimsg = TARGET_RESET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2387 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2388 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
| 2389 | auto_loaded = 1; |
| 2390 | currSCCB->Sccb_scsistat = SELECT_BDR_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2391 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2392 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 2393 | currTar_Info->TarSyncCtrl = 0; |
| 2394 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2395 | } |
| 2396 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2397 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 2398 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2399 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2400 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2401 | FPT_sssyncv(port, target, NARROW_SCSI, currTar_Info); |
| 2402 | FPT_SccbMgrTableInitTarget(p_card, target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2404 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2406 | else if (currSCCB->Sccb_scsistat == ABORT_ST) { |
| 2407 | WRW_HARPOON((port + ID_MSG_STRT), (MPM_OP + AMSG_OUT + |
| 2408 | (currSCCB-> |
| 2409 | Sccb_idmsg & ~DISC_PRIV))); |
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 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2412 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2413 | WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + |
| 2414 | (((unsigned |
| 2415 | char)(currSCCB-> |
| 2416 | ControlByte & |
| 2417 | TAG_TYPE_MASK) |
| 2418 | >> 6) | (unsigned char) |
| 2419 | 0x20))); |
| 2420 | WRW_HARPOON((port + SYNC_MSGS + 2), |
| 2421 | (MPM_OP + AMSG_OUT + currSCCB->Sccb_tag)); |
| 2422 | WRW_HARPOON((port + SYNC_MSGS + 4), (BRH_OP + ALWAYS + NP)); |
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 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
| 2425 | auto_loaded = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2426 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2427 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2429 | else if (!(currTar_Info->TarStatus & WIDE_NEGOCIATED)) { |
| 2430 | auto_loaded = FPT_siwidn(port, p_card); |
| 2431 | currSCCB->Sccb_scsistat = SELECT_WN_ST; |
| 2432 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2433 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2434 | else if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) |
| 2435 | == SYNC_SUPPORTED)) { |
| 2436 | auto_loaded = FPT_sisyncn(port, p_card, 0); |
| 2437 | currSCCB->Sccb_scsistat = SELECT_SN_ST; |
| 2438 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2440 | if (!auto_loaded) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2442 | if (currSCCB->ControlByte & F_USE_CMD_Q) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2443 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2444 | CurrCard->globalFlags |= F_TAG_STARTED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2446 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) |
| 2447 | == TAG_Q_REJECT) { |
| 2448 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2449 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2450 | /* Fix up the start instruction with a jump to |
| 2451 | Non-Tag-CMD handling */ |
| 2452 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2453 | BRH_OP + ALWAYS + NTCMD); |
| 2454 | |
| 2455 | WRW_HARPOON((port + NON_TAG_ID_MSG), |
| 2456 | (MPM_OP + AMSG_OUT + |
| 2457 | currSCCB->Sccb_idmsg)); |
| 2458 | |
| 2459 | WR_HARPOON(port + hp_autostart_3, |
| 2460 | (SELECT + SELCHK_STRT)); |
| 2461 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2462 | /* Setup our STATE so we know what happened when |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2463 | the wheels fall off. */ |
| 2464 | currSCCB->Sccb_scsistat = SELECT_ST; |
| 2465 | |
| 2466 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2467 | } |
| 2468 | |
| 2469 | else { |
| 2470 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2471 | (MPM_OP + AMSG_OUT + |
| 2472 | currSCCB->Sccb_idmsg)); |
| 2473 | |
| 2474 | WRW_HARPOON((port + ID_MSG_STRT + 2), |
| 2475 | (MPM_OP + AMSG_OUT + |
| 2476 | (((unsigned char)(currSCCB-> |
| 2477 | ControlByte & |
| 2478 | TAG_TYPE_MASK) |
| 2479 | >> 6) | (unsigned char)0x20))); |
| 2480 | |
| 2481 | for (i = 1; i < QUEUE_DEPTH; i++) { |
| 2482 | if (++lastTag >= QUEUE_DEPTH) |
| 2483 | lastTag = 1; |
| 2484 | if (CurrCard->discQ_Tbl[lastTag] == |
| 2485 | NULL) { |
| 2486 | WRW_HARPOON((port + |
| 2487 | ID_MSG_STRT + 6), |
| 2488 | (MPM_OP + AMSG_OUT + |
| 2489 | lastTag)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2490 | CurrCard->tagQ_Lst = lastTag; |
| 2491 | currSCCB->Sccb_tag = lastTag; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2492 | CurrCard->discQ_Tbl[lastTag] = |
| 2493 | currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2494 | CurrCard->discQCount++; |
| 2495 | break; |
| 2496 | } |
| 2497 | } |
| 2498 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2499 | if (i == QUEUE_DEPTH) { |
| 2500 | currTar_Info->TarLUNBusy[lun] = 1; |
| 2501 | FPT_queueSelectFail(CurrCard, p_card); |
| 2502 | SGRAM_ACCESS(port); |
| 2503 | return; |
| 2504 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2506 | currSCCB->Sccb_scsistat = SELECT_Q_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2507 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2508 | WR_HARPOON(port + hp_autostart_3, |
| 2509 | (SELECT + SELCHK_STRT)); |
| 2510 | } |
| 2511 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2512 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2513 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2514 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2515 | WRW_HARPOON((port + ID_MSG_STRT), |
| 2516 | BRH_OP + ALWAYS + NTCMD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2517 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2518 | WRW_HARPOON((port + NON_TAG_ID_MSG), |
| 2519 | (MPM_OP + AMSG_OUT + currSCCB->Sccb_idmsg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2520 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2521 | currSCCB->Sccb_scsistat = SELECT_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2522 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2523 | WR_HARPOON(port + hp_autostart_3, |
| 2524 | (SELECT + SELCHK_STRT)); |
| 2525 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2526 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2527 | theCCB = (unsigned char *)&currSCCB->Cdb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2529 | cdb_reg = port + CMD_STRT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2530 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2531 | for (i = 0; i < currSCCB->CdbLength; i++) { |
| 2532 | WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + *theCCB)); |
| 2533 | cdb_reg += 2; |
| 2534 | theCCB++; |
| 2535 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2537 | if (currSCCB->CdbLength != TWELVE_BYTE_CMD) |
| 2538 | WRW_HARPOON(cdb_reg, (BRH_OP + ALWAYS + NP)); |
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 | } |
| 2541 | /* auto_loaded */ |
| 2542 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
| 2543 | WR_HARPOON(port + hp_xferstat, 0x00); |
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 | WRW_HARPOON((port + hp_intstat), (PROG_HLT | TIMEOUT | SEL | BUS_FREE)); |
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 | WR_HARPOON(port + hp_portctrl_0, (SCSI_PORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2548 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2549 | if (!(currSCCB->Sccb_MGRFlags & F_DEV_SELECTED)) { |
| 2550 | WR_HARPOON(port + hp_scsictrl_0, |
| 2551 | (SEL_TAR | ENA_ATN | ENA_RESEL | ENA_SCAM_SEL)); |
| 2552 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2553 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2554 | /* auto_loaded = (RD_HARPOON(port+hp_autostart_3) & (unsigned char)0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2555 | auto_loaded |= AUTO_IMMED; */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2556 | auto_loaded = AUTO_IMMED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2557 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2558 | DISABLE_AUTO(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2559 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2560 | WR_HARPOON(port + hp_autostart_3, auto_loaded); |
| 2561 | } |
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 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2564 | } |
| 2565 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2566 | /*--------------------------------------------------------------------- |
| 2567 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2568 | * Function: FPT_sres |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2569 | * |
| 2570 | * Description: Hookup the correct CCB and handle the incoming messages. |
| 2571 | * |
| 2572 | *---------------------------------------------------------------------*/ |
| 2573 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2574 | static void FPT_sres(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2575 | struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2576 | { |
| 2577 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2578 | unsigned char our_target, message, lun = 0, tag, msgRetryCount; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2580 | struct sccb_mgr_tar_info *currTar_Info; |
| 2581 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2582 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2583 | if (pCurrCard->currentSCCB != NULL) { |
| 2584 | currTar_Info = |
| 2585 | &FPT_sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2586 | DISABLE_AUTO(port); |
| 2587 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2588 | WR_HARPOON((port + hp_scsictrl_0), (ENA_RESEL | ENA_SCAM_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2589 | |
| 2590 | currSCCB = pCurrCard->currentSCCB; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2591 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2592 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 2593 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
| 2594 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2595 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2596 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 2597 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
| 2598 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2599 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 2600 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 2601 | TAG_Q_TRYING))) { |
| 2602 | currTar_Info->TarLUNBusy[currSCCB->Lun] = 0; |
| 2603 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2604 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2605 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 2606 | LunDiscQ_Idx[currSCCB-> |
| 2607 | Lun]] |
| 2608 | = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2609 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2610 | } else { |
| 2611 | currTar_Info->TarLUNBusy[0] = 0; |
| 2612 | if (currSCCB->Sccb_tag) { |
| 2613 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2614 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2615 | pCurrCard->discQ_Tbl[currSCCB-> |
| 2616 | Sccb_tag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2617 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2618 | } else { |
| 2619 | if (currSCCB->Sccb_scsistat != ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2620 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2621 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 2622 | LunDiscQ_Idx[0]] = |
| 2623 | NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2624 | } |
| 2625 | } |
| 2626 | } |
| 2627 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2628 | FPT_queueSelectFail(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | } |
| 2630 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2631 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2632 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2633 | our_target = (unsigned char)(RD_HARPOON(port + hp_select_id) >> 4); |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2634 | currTar_Info = &FPT_sccbMgrTbl[p_card][our_target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2635 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2636 | msgRetryCount = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2637 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2638 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2639 | currTar_Info = &FPT_sccbMgrTbl[p_card][our_target]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2640 | tag = 0; |
| 2641 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2642 | while (!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) { |
| 2643 | if (!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2644 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2645 | WRW_HARPOON((port + hp_intstat), PHASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2646 | return; |
| 2647 | } |
| 2648 | } |
| 2649 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2650 | WRW_HARPOON((port + hp_intstat), PHASE); |
| 2651 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) == S_MSGI_PH) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2652 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2653 | message = FPT_sfm(port, pCurrCard->currentSCCB); |
| 2654 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2655 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2656 | if (message <= (0x80 | LUN_MASK)) { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2657 | lun = message & (unsigned char)LUN_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2659 | if ((currTar_Info-> |
| 2660 | TarStatus & TAR_TAG_Q_MASK) == |
| 2661 | TAG_Q_TRYING) { |
| 2662 | if (currTar_Info->TarTagQ_Cnt != |
| 2663 | 0) { |
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 | if (! |
| 2666 | (currTar_Info-> |
| 2667 | TarLUN_CA)) { |
| 2668 | ACCEPT_MSG(port); /*Release the ACK for ID msg. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2669 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2670 | message = |
| 2671 | FPT_sfm |
| 2672 | (port, |
| 2673 | pCurrCard-> |
| 2674 | currentSCCB); |
| 2675 | if (message) { |
| 2676 | ACCEPT_MSG |
| 2677 | (port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2678 | } |
| 2679 | |
| 2680 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2681 | message |
| 2682 | = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2684 | if (message != |
| 2685 | 0) { |
| 2686 | tag = |
| 2687 | FPT_sfm |
| 2688 | (port, |
| 2689 | pCurrCard-> |
| 2690 | currentSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2691 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2692 | if (! |
| 2693 | (tag)) |
| 2694 | message |
| 2695 | = |
| 2696 | 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2697 | } |
| 2698 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2699 | } |
| 2700 | /*C.A. exists! */ |
| 2701 | } |
| 2702 | /*End Q cnt != 0 */ |
| 2703 | } |
| 2704 | /*End Tag cmds supported! */ |
| 2705 | } |
| 2706 | /*End valid ID message. */ |
| 2707 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2708 | |
| 2709 | ACCEPT_MSG_ATN(port); |
| 2710 | } |
| 2711 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2712 | } |
| 2713 | /* End good id message. */ |
| 2714 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2715 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2716 | message = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2717 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2718 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2719 | ACCEPT_MSG_ATN(port); |
| 2720 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2721 | while (! |
| 2722 | (RDW_HARPOON((port + hp_intstat)) & |
| 2723 | (PHASE | RESET)) |
| 2724 | && !(RD_HARPOON(port + hp_scsisig) & SCSI_REQ) |
| 2725 | && (RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2726 | |
| 2727 | return; |
| 2728 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2729 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2730 | if (message == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2731 | msgRetryCount++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2732 | if (msgRetryCount == 1) { |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2733 | FPT_SendMsg(port, MSG_PARITY_ERROR); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2734 | } else { |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2735 | FPT_SendMsg(port, TARGET_RESET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2736 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2737 | FPT_sssyncv(port, our_target, NARROW_SCSI, |
| 2738 | currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2739 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2740 | if (FPT_sccbMgrTbl[p_card][our_target]. |
| 2741 | TarEEValue & EE_SYNC_MASK) { |
| 2742 | |
| 2743 | FPT_sccbMgrTbl[p_card][our_target]. |
| 2744 | TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2745 | |
| 2746 | } |
| 2747 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2748 | if (FPT_sccbMgrTbl[p_card][our_target]. |
| 2749 | TarEEValue & EE_WIDE_SCSI) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2750 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2751 | FPT_sccbMgrTbl[p_card][our_target]. |
| 2752 | TarStatus &= ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2753 | } |
| 2754 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2755 | FPT_queueFlushTargSccb(p_card, our_target, |
| 2756 | SCCB_COMPLETE); |
| 2757 | FPT_SccbMgrTableInitTarget(p_card, our_target); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2758 | return; |
| 2759 | } |
| 2760 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2761 | } while (message == 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2762 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2763 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 2764 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2765 | currTar_Info->TarLUNBusy[lun] = 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2766 | pCurrCard->currentSCCB = |
| 2767 | pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[lun]]; |
| 2768 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2769 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2770 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2771 | ACCEPT_MSG_ATN(port); |
| 2772 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2773 | } else { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2774 | currTar_Info->TarLUNBusy[0] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2775 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2776 | if (tag) { |
| 2777 | if (pCurrCard->discQ_Tbl[tag] != NULL) { |
| 2778 | pCurrCard->currentSCCB = |
| 2779 | pCurrCard->discQ_Tbl[tag]; |
| 2780 | currTar_Info->TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2781 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2782 | } else { |
| 2783 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2784 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2785 | } else { |
| 2786 | pCurrCard->currentSCCB = |
| 2787 | pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]]; |
| 2788 | if (pCurrCard->currentSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2789 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2790 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2791 | ACCEPT_MSG_ATN(port); |
| 2792 | } |
| 2793 | } |
| 2794 | } |
| 2795 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2796 | if (pCurrCard->currentSCCB != NULL) { |
| 2797 | if (pCurrCard->currentSCCB->Sccb_scsistat == ABORT_ST) { |
| 2798 | /* During Abort Tag command, the target could have got re-selected |
| 2799 | and completed the command. Check the select Q and remove the CCB |
| 2800 | if it is in the Select Q */ |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2801 | FPT_queueFindSccb(pCurrCard->currentSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2802 | } |
| 2803 | } |
| 2804 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2805 | while (!(RDW_HARPOON((port + hp_intstat)) & (PHASE | RESET)) && |
| 2806 | !(RD_HARPOON(port + hp_scsisig) & SCSI_REQ) && |
| 2807 | (RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2808 | } |
| 2809 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2810 | static void FPT_SendMsg(u32 port, unsigned char message) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2811 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2812 | while (!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) { |
| 2813 | if (!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2814 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2815 | WRW_HARPOON((port + hp_intstat), PHASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2816 | return; |
| 2817 | } |
| 2818 | } |
| 2819 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2820 | WRW_HARPOON((port + hp_intstat), PHASE); |
| 2821 | if ((RD_HARPOON(port + hp_scsisig) & S_SCSI_PHZ) == S_MSGO_PH) { |
| 2822 | WRW_HARPOON((port + hp_intstat), |
| 2823 | (BUS_FREE | PHASE | XFER_CNT_0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2824 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2825 | WR_HARPOON(port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2826 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2827 | WR_HARPOON(port + hp_scsidata_0, message); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2828 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2829 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2830 | |
| 2831 | ACCEPT_MSG(port); |
| 2832 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2833 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2834 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2835 | if ((message == ABORT_TASK_SET) || (message == TARGET_RESET) || |
| 2836 | (message == ABORT_TASK)) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2837 | while (! |
| 2838 | (RDW_HARPOON((port + hp_intstat)) & |
| 2839 | (BUS_FREE | PHASE))) { |
| 2840 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2841 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2842 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 2843 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2844 | } |
| 2845 | } |
| 2846 | } |
| 2847 | } |
| 2848 | |
| 2849 | /*--------------------------------------------------------------------- |
| 2850 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2851 | * Function: FPT_sdecm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2852 | * |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2853 | * Description: Determine the proper response to the message from the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2854 | * target device. |
| 2855 | * |
| 2856 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 2857 | 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] | 2858 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2859 | struct sccb *currSCCB; |
| 2860 | struct sccb_card *CurrCard; |
| 2861 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2862 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2863 | CurrCard = &FPT_BL_Card[p_card]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2864 | currSCCB = CurrCard->currentSCCB; |
| 2865 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2866 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2867 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2868 | if (message == RESTORE_POINTERS) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2869 | if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2870 | currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC; |
| 2871 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2872 | FPT_hostDataXferRestart(currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2873 | } |
| 2874 | |
| 2875 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2876 | WR_HARPOON(port + hp_autostart_1, |
| 2877 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2878 | } |
| 2879 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2880 | else if (message == COMMAND_COMPLETE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2881 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2882 | if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { |
| 2883 | currTar_Info->TarStatus &= |
| 2884 | ~(unsigned char)TAR_TAG_Q_MASK; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 2885 | currTar_Info->TarStatus |= (unsigned char)TAG_Q_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2886 | } |
| 2887 | |
| 2888 | ACCEPT_MSG(port); |
| 2889 | |
| 2890 | } |
| 2891 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2892 | else if ((message == NOP) || (message >= IDENTIFY_BASE) || |
| 2893 | (message == INITIATE_RECOVERY) || |
| 2894 | (message == RELEASE_RECOVERY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2895 | |
| 2896 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2897 | WR_HARPOON(port + hp_autostart_1, |
| 2898 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2899 | } |
| 2900 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 2901 | else if (message == MESSAGE_REJECT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2902 | |
| 2903 | if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) || |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2904 | (currSCCB->Sccb_scsistat == SELECT_WN_ST) || |
| 2905 | ((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING) |
| 2906 | || ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == |
| 2907 | TAG_Q_TRYING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2908 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2909 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2910 | |
| 2911 | ACCEPT_MSG(port); |
| 2912 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2913 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2914 | (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2915 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2916 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2917 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2918 | if (currSCCB->Lun == 0x00) { |
Nathan Chancellor | adb1102 | 2018-09-20 14:10:32 -0700 | [diff] [blame] | 2919 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2920 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2921 | currTar_Info->TarStatus |= |
| 2922 | (unsigned char)SYNC_SUPPORTED; |
| 2923 | |
| 2924 | currTar_Info->TarEEValue &= |
| 2925 | ~EE_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2926 | } |
| 2927 | |
Nathan Chancellor | adb1102 | 2018-09-20 14:10:32 -0700 | [diff] [blame] | 2928 | else if (currSCCB->Sccb_scsistat == |
| 2929 | SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2930 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2931 | currTar_Info->TarStatus = |
| 2932 | (currTar_Info-> |
| 2933 | TarStatus & ~WIDE_ENABLED) | |
| 2934 | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2935 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2936 | currTar_Info->TarEEValue &= |
| 2937 | ~EE_WIDE_SCSI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2938 | |
| 2939 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2940 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2941 | else if ((currTar_Info-> |
| 2942 | TarStatus & TAR_TAG_Q_MASK) == |
| 2943 | TAG_Q_TRYING) { |
| 2944 | currTar_Info->TarStatus = |
| 2945 | (currTar_Info-> |
| 2946 | TarStatus & ~(unsigned char) |
| 2947 | TAR_TAG_Q_MASK) | TAG_Q_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2948 | |
| 2949 | currSCCB->ControlByte &= ~F_USE_CMD_Q; |
| 2950 | CurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2951 | CurrCard->discQ_Tbl[currSCCB-> |
| 2952 | Sccb_tag] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2953 | currSCCB->Sccb_tag = 0x00; |
| 2954 | |
| 2955 | } |
| 2956 | } |
| 2957 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2958 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2959 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2960 | if (currSCCB->Lun == 0x00) { |
| 2961 | WRW_HARPOON((port + hp_intstat), |
| 2962 | BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2963 | CurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 2964 | } |
| 2965 | } |
| 2966 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2967 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2968 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2969 | if ((CurrCard->globalFlags & F_CONLUN_IO) && |
| 2970 | ((currTar_Info-> |
| 2971 | TarStatus & TAR_TAG_Q_MASK) != |
| 2972 | TAG_Q_TRYING)) |
| 2973 | currTar_Info->TarLUNBusy[currSCCB-> |
| 2974 | Lun] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2975 | else |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 2976 | currTar_Info->TarLUNBusy[0] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2977 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2978 | currSCCB->ControlByte &= |
| 2979 | ~(unsigned char)F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2980 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2981 | WR_HARPOON(port + hp_autostart_1, |
| 2982 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2983 | |
| 2984 | } |
| 2985 | } |
| 2986 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2987 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2988 | ACCEPT_MSG(port); |
| 2989 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2990 | while ((!(RD_HARPOON(port + hp_scsisig) & SCSI_REQ)) && |
| 2991 | (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2992 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 2993 | } |
| 2994 | |
| 2995 | if (!(RDW_HARPOON((port + hp_intstat)) & BUS_FREE)) { |
| 2996 | WR_HARPOON(port + hp_autostart_1, |
| 2997 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2998 | } |
| 2999 | } |
| 3000 | } |
| 3001 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3002 | else if (message == EXTENDED_MESSAGE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3003 | |
| 3004 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3005 | FPT_shandem(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3006 | } |
| 3007 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3008 | else if (message == IGNORE_WIDE_RESIDUE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3009 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3010 | ACCEPT_MSG(port); /* ACK the RESIDUE MSG */ |
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 | message = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3013 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3014 | if (currSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3015 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3016 | WR_HARPOON(port + hp_autostart_1, |
| 3017 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3018 | } |
| 3019 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3020 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3021 | |
| 3022 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3023 | currSCCB->Sccb_scsimsg = MESSAGE_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3024 | |
| 3025 | ACCEPT_MSG_ATN(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3026 | WR_HARPOON(port + hp_autostart_1, |
| 3027 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3028 | } |
| 3029 | } |
| 3030 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3031 | /*--------------------------------------------------------------------- |
| 3032 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3033 | * Function: FPT_shandem |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3034 | * |
| 3035 | * Description: Decide what to do with the extended message. |
| 3036 | * |
| 3037 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3038 | 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] | 3039 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3040 | unsigned char length, message; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3042 | length = FPT_sfm(port, pCurrSCCB); |
| 3043 | if (length) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3044 | |
| 3045 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3046 | message = FPT_sfm(port, pCurrSCCB); |
| 3047 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3048 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3049 | if (message == EXTENDED_SDTR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3050 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3051 | if (length == 0x03) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3052 | |
| 3053 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3054 | FPT_stsyncn(port, p_card); |
| 3055 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3056 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3057 | pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3058 | ACCEPT_MSG_ATN(port); |
| 3059 | } |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3060 | } else if (message == EXTENDED_WDTR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3062 | if (length == 0x02) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3063 | |
| 3064 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3065 | FPT_stwidn(port, p_card); |
| 3066 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3067 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3068 | pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3069 | ACCEPT_MSG_ATN(port); |
| 3070 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3071 | WR_HARPOON(port + hp_autostart_1, |
| 3072 | (AUTO_IMMED + |
| 3073 | DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3075 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3076 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3077 | pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3078 | ACCEPT_MSG_ATN(port); |
| 3079 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3080 | WR_HARPOON(port + hp_autostart_1, |
| 3081 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3082 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3083 | } else { |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3084 | if (pCurrSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3085 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3086 | WR_HARPOON(port + hp_autostart_1, |
| 3087 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3088 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3089 | } else { |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3090 | if (pCurrSCCB->Sccb_scsimsg == MSG_PARITY_ERROR) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3091 | WR_HARPOON(port + hp_autostart_1, |
| 3092 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3093 | } |
| 3094 | } |
| 3095 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3096 | /*--------------------------------------------------------------------- |
| 3097 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3098 | * Function: FPT_sisyncn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3099 | * |
| 3100 | * Description: Read in a message byte from the SCSI bus, and check |
| 3101 | * for a parity error. |
| 3102 | * |
| 3103 | *---------------------------------------------------------------------*/ |
| 3104 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3105 | static unsigned char FPT_sisyncn(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3106 | unsigned char syncFlag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3107 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3108 | struct sccb *currSCCB; |
| 3109 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3110 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3111 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3112 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
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 | if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3115 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3116 | WRW_HARPOON((port + ID_MSG_STRT), |
| 3117 | (MPM_OP + AMSG_OUT + |
| 3118 | (currSCCB-> |
| 3119 | Sccb_idmsg & ~(unsigned char)DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3120 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3121 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3122 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3123 | WRW_HARPOON((port + SYNC_MSGS + 0), |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3124 | (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3125 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); |
| 3126 | WRW_HARPOON((port + SYNC_MSGS + 4), |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3127 | (MPM_OP + AMSG_OUT + EXTENDED_SDTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3128 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3129 | if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3130 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3131 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3132 | (MPM_OP + AMSG_OUT + 12)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3133 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3134 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == |
| 3135 | EE_SYNC_10MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3137 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3138 | (MPM_OP + AMSG_OUT + 25)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3139 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3140 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == |
| 3141 | EE_SYNC_5MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3142 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3143 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3144 | (MPM_OP + AMSG_OUT + 50)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3146 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3147 | WRW_HARPOON((port + SYNC_MSGS + 6), |
| 3148 | (MPM_OP + AMSG_OUT + 00)); |
| 3149 | |
| 3150 | WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); |
| 3151 | WRW_HARPOON((port + SYNC_MSGS + 10), |
| 3152 | (MPM_OP + AMSG_OUT + DEFAULT_OFFSET)); |
| 3153 | WRW_HARPOON((port + SYNC_MSGS + 12), (BRH_OP + ALWAYS + NP)); |
| 3154 | |
| 3155 | if (syncFlag == 0) { |
| 3156 | WR_HARPOON(port + hp_autostart_3, |
| 3157 | (SELECT + SELCHK_STRT)); |
| 3158 | currTar_Info->TarStatus = |
| 3159 | ((currTar_Info-> |
| 3160 | TarStatus & ~(unsigned char)TAR_SYNC_MASK) | |
| 3161 | (unsigned char)SYNC_TRYING); |
| 3162 | } else { |
| 3163 | WR_HARPOON(port + hp_autostart_3, |
| 3164 | (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3165 | } |
| 3166 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3167 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3168 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3169 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3170 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3171 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3172 | currTar_Info->TarStatus |= (unsigned char)SYNC_SUPPORTED; |
| 3173 | currTar_Info->TarEEValue &= ~EE_SYNC_MASK; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3174 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3175 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3176 | } |
| 3177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3178 | /*--------------------------------------------------------------------- |
| 3179 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3180 | * Function: FPT_stsyncn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3181 | * |
| 3182 | * Description: The has sent us a Sync Nego message so handle it as |
| 3183 | * necessary. |
| 3184 | * |
| 3185 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3186 | static void FPT_stsyncn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3187 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3188 | unsigned char sync_msg, offset, sync_reg, our_sync_msg; |
| 3189 | struct sccb *currSCCB; |
| 3190 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3191 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3192 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3193 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3194 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3195 | sync_msg = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3196 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3197 | if ((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3198 | WR_HARPOON(port + hp_autostart_1, |
| 3199 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3200 | return; |
| 3201 | } |
| 3202 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3203 | ACCEPT_MSG(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3204 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3205 | offset = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3206 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3207 | if ((offset == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3208 | WR_HARPOON(port + hp_autostart_1, |
| 3209 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3210 | return; |
| 3211 | } |
| 3212 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3213 | if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3214 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3215 | our_sync_msg = 12; /* Setup our Message to 20mb/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3216 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3217 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_10MB) |
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 | our_sync_msg = 25; /* Setup our Message to 10mb/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3220 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3221 | else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_5MB) |
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 | our_sync_msg = 50; /* Setup our Message to 5mb/s */ |
| 3224 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3225 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3226 | our_sync_msg = 0; /* Message = Async */ |
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 < our_sync_msg) { |
| 3229 | sync_msg = our_sync_msg; /*if faster, then set to max. */ |
| 3230 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3231 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3232 | if (offset == ASYNC) |
| 3233 | sync_msg = ASYNC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3234 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3235 | if (offset > MAX_OFFSET) |
| 3236 | offset = MAX_OFFSET; |
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 | sync_reg = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3239 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3240 | if (sync_msg > 12) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3241 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3242 | sync_reg = 0x20; /* Use 10MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3243 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3244 | if (sync_msg > 25) |
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 | sync_reg = 0x40; /* Use 6.6MB/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 | if (sync_msg > 38) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3249 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3250 | sync_reg = 0x60; /* Use 5MB/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 | if (sync_msg > 50) |
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 | sync_reg = 0x80; /* Use 4MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3255 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3256 | if (sync_msg > 62) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3257 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3258 | sync_reg = 0xA0; /* Use 3.33MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3259 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3260 | if (sync_msg > 75) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3261 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3262 | sync_reg = 0xC0; /* Use 2.85MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3263 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3264 | if (sync_msg > 87) |
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 | sync_reg = 0xE0; /* Use 2.5MB/s */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3267 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3268 | if (sync_msg > 100) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3269 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3270 | sync_reg = 0x00; /* Use ASYNC */ |
| 3271 | offset = 0x00; |
| 3272 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3274 | if (currTar_Info->TarStatus & WIDE_ENABLED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3275 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3276 | sync_reg |= offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3277 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3278 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3279 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3280 | sync_reg |= (offset | NARROW_SCSI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3281 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3282 | FPT_sssyncv(port, currSCCB->TargID, sync_reg, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3283 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3284 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3285 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3286 | ACCEPT_MSG(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3287 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3288 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3289 | ~(unsigned char)TAR_SYNC_MASK) | |
| 3290 | (unsigned char)SYNC_SUPPORTED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3292 | WR_HARPOON(port + hp_autostart_1, |
| 3293 | (AUTO_IMMED + DISCONNECT_START)); |
| 3294 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3295 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3296 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3297 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3298 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3299 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3300 | FPT_sisyncr(port, sync_msg, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3301 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3302 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3303 | ~(unsigned char)TAR_SYNC_MASK) | |
| 3304 | (unsigned char)SYNC_SUPPORTED); |
| 3305 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3306 | } |
| 3307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3308 | /*--------------------------------------------------------------------- |
| 3309 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3310 | * Function: FPT_sisyncr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3311 | * |
| 3312 | * Description: Answer the targets sync message. |
| 3313 | * |
| 3314 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3315 | static void FPT_sisyncr(u32 port, unsigned char sync_pulse, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3316 | unsigned char offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3317 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3318 | ARAM_ACCESS(port); |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3319 | WRW_HARPOON((port + SYNC_MSGS + 0), |
| 3320 | (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3321 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3322 | WRW_HARPOON((port + SYNC_MSGS + 4), |
| 3323 | (MPM_OP + AMSG_OUT + EXTENDED_SDTR)); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3324 | WRW_HARPOON((port + SYNC_MSGS + 6), (MPM_OP + AMSG_OUT + sync_pulse)); |
| 3325 | WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); |
| 3326 | WRW_HARPOON((port + SYNC_MSGS + 10), (MPM_OP + AMSG_OUT + offset)); |
| 3327 | WRW_HARPOON((port + SYNC_MSGS + 12), (BRH_OP + ALWAYS + NP)); |
| 3328 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3329 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3330 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
| 3331 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT_1); |
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 | WR_HARPOON(port + hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3334 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3335 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | AUTO_INT))) { |
| 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_siwidn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3342 | * |
| 3343 | * Description: Read in a message byte from the SCSI bus, and check |
| 3344 | * for a parity error. |
| 3345 | * |
| 3346 | *---------------------------------------------------------------------*/ |
| 3347 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3348 | static unsigned char FPT_siwidn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3349 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3350 | struct sccb *currSCCB; |
| 3351 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3352 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3353 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3354 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3355 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3356 | if (!((currTar_Info->TarStatus & TAR_WIDE_MASK) == WIDE_NEGOCIATED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3357 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3358 | WRW_HARPOON((port + ID_MSG_STRT), |
| 3359 | (MPM_OP + AMSG_OUT + |
| 3360 | (currSCCB-> |
| 3361 | Sccb_idmsg & ~(unsigned char)DISC_PRIV))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3362 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3363 | WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3364 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3365 | WRW_HARPOON((port + SYNC_MSGS + 0), |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3366 | (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3367 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); |
| 3368 | WRW_HARPOON((port + SYNC_MSGS + 4), |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3369 | (MPM_OP + AMSG_OUT + EXTENDED_WDTR)); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3370 | WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); |
| 3371 | WRW_HARPOON((port + SYNC_MSGS + 8), |
| 3372 | (MPM_OP + AMSG_OUT + SM16BIT)); |
| 3373 | WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3375 | WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3376 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3377 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3378 | ~(unsigned char)TAR_WIDE_MASK) | |
| 3379 | (unsigned char)WIDE_ENABLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3380 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3381 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3382 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3383 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3384 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3385 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3386 | currTar_Info->TarStatus = ((currTar_Info->TarStatus & |
| 3387 | ~(unsigned char)TAR_WIDE_MASK) | |
| 3388 | WIDE_NEGOCIATED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3389 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3390 | currTar_Info->TarEEValue &= ~EE_WIDE_SCSI; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 3391 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3392 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3393 | } |
| 3394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3395 | /*--------------------------------------------------------------------- |
| 3396 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3397 | * Function: FPT_stwidn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3398 | * |
| 3399 | * Description: The has sent us a Wide Nego message so handle it as |
| 3400 | * necessary. |
| 3401 | * |
| 3402 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3403 | static void FPT_stwidn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3404 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3405 | unsigned char width; |
| 3406 | struct sccb *currSCCB; |
| 3407 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3408 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3409 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3410 | currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3411 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3412 | width = FPT_sfm(port, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3413 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3414 | if ((width == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3415 | WR_HARPOON(port + hp_autostart_1, |
| 3416 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3417 | return; |
| 3418 | } |
| 3419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3420 | if (!(currTar_Info->TarEEValue & EE_WIDE_SCSI)) |
| 3421 | width = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3422 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3423 | if (width) { |
| 3424 | currTar_Info->TarStatus |= WIDE_ENABLED; |
| 3425 | width = 0; |
| 3426 | } else { |
| 3427 | width = NARROW_SCSI; |
| 3428 | currTar_Info->TarStatus &= ~WIDE_ENABLED; |
| 3429 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3430 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3431 | FPT_sssyncv(port, currSCCB->TargID, width, currTar_Info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3432 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3433 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3434 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3435 | currTar_Info->TarStatus |= WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3437 | if (! |
| 3438 | ((currTar_Info->TarStatus & TAR_SYNC_MASK) == |
| 3439 | SYNC_SUPPORTED)) { |
| 3440 | ACCEPT_MSG_ATN(port); |
| 3441 | ARAM_ACCESS(port); |
| 3442 | FPT_sisyncn(port, p_card, 1); |
| 3443 | currSCCB->Sccb_scsistat = SELECT_SN_ST; |
| 3444 | SGRAM_ACCESS(port); |
| 3445 | } else { |
| 3446 | ACCEPT_MSG(port); |
| 3447 | WR_HARPOON(port + hp_autostart_1, |
| 3448 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3449 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3450 | } |
| 3451 | |
| 3452 | else { |
| 3453 | |
| 3454 | ACCEPT_MSG_ATN(port); |
| 3455 | |
| 3456 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) |
| 3457 | width = SM16BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3458 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3459 | width = SM8BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3460 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3461 | FPT_siwidr(port, width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3462 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3463 | currTar_Info->TarStatus |= (WIDE_NEGOCIATED | WIDE_ENABLED); |
| 3464 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3465 | } |
| 3466 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3467 | /*--------------------------------------------------------------------- |
| 3468 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3469 | * Function: FPT_siwidr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3470 | * |
| 3471 | * Description: Answer the targets Wide nego message. |
| 3472 | * |
| 3473 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3474 | static void FPT_siwidr(u32 port, unsigned char width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3475 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3476 | ARAM_ACCESS(port); |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3477 | WRW_HARPOON((port + SYNC_MSGS + 0), |
| 3478 | (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3479 | WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3480 | WRW_HARPOON((port + SYNC_MSGS + 4), |
| 3481 | (MPM_OP + AMSG_OUT + EXTENDED_WDTR)); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3482 | WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); |
| 3483 | WRW_HARPOON((port + SYNC_MSGS + 8), (MPM_OP + AMSG_OUT + width)); |
| 3484 | WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); |
| 3485 | SGRAM_ACCESS(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3486 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3487 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
| 3488 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT_1); |
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 | WR_HARPOON(port + hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT)); |
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 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | AUTO_INT))) { |
| 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_sssyncv |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3499 | * |
| 3500 | * Description: Write the desired value to the Sync Register for the |
| 3501 | * ID specified. |
| 3502 | * |
| 3503 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3504 | static void FPT_sssyncv(u32 p_port, unsigned char p_id, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3505 | unsigned char p_sync_value, |
| 3506 | struct sccb_mgr_tar_info *currTar_Info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3507 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3508 | unsigned char index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3509 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3510 | index = p_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3511 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3512 | switch (index) { |
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 | case 0: |
| 3515 | index = 12; /* hp_synctarg_0 */ |
| 3516 | break; |
| 3517 | case 1: |
| 3518 | index = 13; /* hp_synctarg_1 */ |
| 3519 | break; |
| 3520 | case 2: |
| 3521 | index = 14; /* hp_synctarg_2 */ |
| 3522 | break; |
| 3523 | case 3: |
| 3524 | index = 15; /* hp_synctarg_3 */ |
| 3525 | break; |
| 3526 | case 4: |
| 3527 | index = 8; /* hp_synctarg_4 */ |
| 3528 | break; |
| 3529 | case 5: |
| 3530 | index = 9; /* hp_synctarg_5 */ |
| 3531 | break; |
| 3532 | case 6: |
| 3533 | index = 10; /* hp_synctarg_6 */ |
| 3534 | break; |
| 3535 | case 7: |
| 3536 | index = 11; /* hp_synctarg_7 */ |
| 3537 | break; |
| 3538 | case 8: |
| 3539 | index = 4; /* hp_synctarg_8 */ |
| 3540 | break; |
| 3541 | case 9: |
| 3542 | index = 5; /* hp_synctarg_9 */ |
| 3543 | break; |
| 3544 | case 10: |
| 3545 | index = 6; /* hp_synctarg_10 */ |
| 3546 | break; |
| 3547 | case 11: |
| 3548 | index = 7; /* hp_synctarg_11 */ |
| 3549 | break; |
| 3550 | case 12: |
| 3551 | index = 0; /* hp_synctarg_12 */ |
| 3552 | break; |
| 3553 | case 13: |
| 3554 | index = 1; /* hp_synctarg_13 */ |
| 3555 | break; |
| 3556 | case 14: |
| 3557 | index = 2; /* hp_synctarg_14 */ |
| 3558 | break; |
| 3559 | case 15: |
| 3560 | index = 3; /* hp_synctarg_15 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3561 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3562 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3563 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3564 | WR_HARPOON(p_port + hp_synctarg_base + index, p_sync_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3565 | |
| 3566 | currTar_Info->TarSyncCtrl = p_sync_value; |
| 3567 | } |
| 3568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3569 | /*--------------------------------------------------------------------- |
| 3570 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3571 | * Function: FPT_sresb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3572 | * |
| 3573 | * Description: Reset the desired card's SCSI bus. |
| 3574 | * |
| 3575 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3576 | static void FPT_sresb(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3577 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3578 | unsigned char scsiID, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3579 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3580 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3581 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3582 | WR_HARPOON(port + hp_page_ctrl, |
| 3583 | (RD_HARPOON(port + hp_page_ctrl) | G_INT_DISABLE)); |
| 3584 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3585 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3586 | WR_HARPOON(port + hp_scsictrl_0, SCSI_RST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3587 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3588 | scsiID = RD_HARPOON(port + hp_seltimeout); |
| 3589 | WR_HARPOON(port + hp_seltimeout, TO_5ms); |
| 3590 | WRW_HARPOON((port + hp_intstat), TIMEOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3591 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3592 | WR_HARPOON(port + hp_portctrl_0, (SCSI_PORT | START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3593 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3594 | while (!(RDW_HARPOON((port + hp_intstat)) & TIMEOUT)) { |
| 3595 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3596 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3597 | WR_HARPOON(port + hp_seltimeout, scsiID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3598 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3599 | WR_HARPOON(port + hp_scsictrl_0, ENA_SCAM_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3600 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3601 | FPT_Wait(port, TO_5ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3602 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3603 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
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 | 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] | 3606 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3607 | for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++) { |
| 3608 | currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3609 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3610 | if (currTar_Info->TarEEValue & EE_SYNC_MASK) { |
| 3611 | currTar_Info->TarSyncCtrl = 0; |
| 3612 | currTar_Info->TarStatus &= ~TAR_SYNC_MASK; |
| 3613 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3614 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3615 | if (currTar_Info->TarEEValue & EE_WIDE_SCSI) { |
| 3616 | currTar_Info->TarStatus &= ~TAR_WIDE_MASK; |
| 3617 | } |
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 | FPT_sssyncv(port, scsiID, NARROW_SCSI, currTar_Info); |
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 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 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 | FPT_BL_Card[p_card].scanIndex = 0x00; |
| 3625 | FPT_BL_Card[p_card].currentSCCB = NULL; |
| 3626 | FPT_BL_Card[p_card].globalFlags &= ~(F_TAG_STARTED | F_HOST_XFER_ACT |
| 3627 | | F_NEW_SCCB_CMD); |
| 3628 | FPT_BL_Card[p_card].cmdCounter = 0x00; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3629 | FPT_BL_Card[p_card].discQCount = 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3630 | FPT_BL_Card[p_card].tagQ_Lst = 0x01; |
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 | for (i = 0; i < QUEUE_DEPTH; i++) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3633 | FPT_BL_Card[p_card].discQ_Tbl[i] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3634 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3635 | WR_HARPOON(port + hp_page_ctrl, |
| 3636 | (RD_HARPOON(port + hp_page_ctrl) & ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3637 | |
| 3638 | } |
| 3639 | |
| 3640 | /*--------------------------------------------------------------------- |
| 3641 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3642 | * Function: FPT_ssenss |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3643 | * |
| 3644 | * Description: Setup for the Auto Sense command. |
| 3645 | * |
| 3646 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3647 | static void FPT_ssenss(struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3648 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3649 | unsigned char i; |
| 3650 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3651 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3652 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3653 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3654 | currSCCB->Save_CdbLen = currSCCB->CdbLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3655 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3656 | for (i = 0; i < 6; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3657 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3658 | currSCCB->Save_Cdb[i] = currSCCB->Cdb[i]; |
| 3659 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3660 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3661 | currSCCB->CdbLength = SIX_BYTE_CMD; |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3662 | currSCCB->Cdb[0] = REQUEST_SENSE; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3663 | currSCCB->Cdb[1] = currSCCB->Cdb[1] & (unsigned char)0xE0; /*Keep LUN. */ |
| 3664 | currSCCB->Cdb[2] = 0x00; |
| 3665 | currSCCB->Cdb[3] = 0x00; |
| 3666 | currSCCB->Cdb[4] = currSCCB->RequestSenseLength; |
| 3667 | currSCCB->Cdb[5] = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3668 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3669 | currSCCB->Sccb_XferCnt = (u32)currSCCB->RequestSenseLength; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3670 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3671 | currSCCB->Sccb_ATC = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3672 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3673 | currSCCB->Sccb_XferState |= F_AUTO_SENSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3674 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3675 | currSCCB->Sccb_XferState &= ~F_SG_XFER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3676 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3677 | currSCCB->Sccb_idmsg = currSCCB->Sccb_idmsg & ~(unsigned char)DISC_PRIV; |
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->ControlByte = 0x00; |
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->Sccb_MGRFlags &= F_STATUSLOADED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3682 | } |
| 3683 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3684 | /*--------------------------------------------------------------------- |
| 3685 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3686 | * Function: FPT_sxfrp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3687 | * |
| 3688 | * Description: Transfer data into the bit bucket until the device |
| 3689 | * decides to switch phase. |
| 3690 | * |
| 3691 | *---------------------------------------------------------------------*/ |
| 3692 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3693 | static void FPT_sxfrp(u32 p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3694 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3695 | unsigned char curr_phz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3696 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3697 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3698 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3699 | if (FPT_BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3700 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3701 | FPT_hostDataXferAbort(p_port, p_card, |
| 3702 | FPT_BL_Card[p_card].currentSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3703 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3704 | } |
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 | /* If the Automation handled the end of the transfer then do not |
| 3707 | 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] | 3708 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3709 | if (RDW_HARPOON((p_port + hp_intstat)) & |
| 3710 | (BUS_FREE | XFER_CNT_0 | AUTO_INT)) |
| 3711 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3712 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3713 | WR_HARPOON(p_port + hp_xfercnt_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3714 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3715 | 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] | 3716 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3717 | WRW_HARPOON((p_port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3718 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3719 | WR_HARPOON(p_port + hp_scsisig, curr_phz); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3720 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3721 | while (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET)) && |
| 3722 | (curr_phz == |
| 3723 | (RD_HARPOON(p_port + hp_scsisig) & (unsigned char)S_SCSI_PHZ))) |
| 3724 | { |
| 3725 | if (curr_phz & (unsigned char)SCSI_IOBIT) { |
| 3726 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3727 | (SCSI_PORT | HOST_PORT | SCSI_INBIT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3728 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3729 | if (!(RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY)) { |
| 3730 | RD_HARPOON(p_port + hp_fifodata_0); |
| 3731 | } |
| 3732 | } else { |
| 3733 | WR_HARPOON(p_port + hp_portctrl_0, |
| 3734 | (SCSI_PORT | HOST_PORT | HOST_WRT)); |
| 3735 | if (RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY) { |
| 3736 | WR_HARPOON(p_port + hp_fifodata_0, 0xFA); |
| 3737 | } |
| 3738 | } |
| 3739 | } /* End of While loop for padding data I/O phase */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3740 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3741 | while (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET))) { |
| 3742 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_REQ) |
| 3743 | break; |
| 3744 | } |
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_portctrl_0, |
| 3747 | (SCSI_PORT | HOST_PORT | SCSI_INBIT)); |
| 3748 | while (!(RD_HARPOON(p_port + hp_xferstat) & FIFO_EMPTY)) { |
| 3749 | RD_HARPOON(p_port + hp_fifodata_0); |
| 3750 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3751 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3752 | if (!(RDW_HARPOON((p_port + hp_intstat)) & (BUS_FREE | RESET))) { |
| 3753 | WR_HARPOON(p_port + hp_autostart_0, |
| 3754 | (AUTO_IMMED + DISCONNECT_START)); |
| 3755 | while (!(RDW_HARPOON((p_port + hp_intstat)) & AUTO_INT)) { |
| 3756 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3757 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3758 | if (RDW_HARPOON((p_port + hp_intstat)) & |
| 3759 | (ICMD_COMP | ITAR_DISC)) |
| 3760 | while (! |
| 3761 | (RDW_HARPOON((p_port + hp_intstat)) & |
| 3762 | (BUS_FREE | RSEL))) ; |
| 3763 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3764 | } |
| 3765 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3766 | /*--------------------------------------------------------------------- |
| 3767 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3768 | * Function: FPT_schkdd |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3769 | * |
| 3770 | * Description: Make sure data has been flushed from both FIFOs and abort |
| 3771 | * the operations if necessary. |
| 3772 | * |
| 3773 | *---------------------------------------------------------------------*/ |
| 3774 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3775 | static void FPT_schkdd(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3776 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3777 | unsigned short TimeOutLoop; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 3778 | unsigned char sPhase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3779 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3780 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3781 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3782 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3783 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3784 | if ((currSCCB->Sccb_scsistat != DATA_OUT_ST) && |
| 3785 | (currSCCB->Sccb_scsistat != DATA_IN_ST)) { |
| 3786 | return; |
| 3787 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3788 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3789 | if (currSCCB->Sccb_XferState & F_ODD_BALL_CNT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3791 | currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3792 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3793 | currSCCB->Sccb_XferCnt = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3794 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3795 | currSCCB->Sccb_XferState &= ~F_ODD_BALL_CNT; |
| 3796 | WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00); |
| 3797 | WR_HARPOON(port + hp_xferstat, 0x00); |
| 3798 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3799 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3800 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3801 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3802 | currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt; |
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 | currSCCB->Sccb_XferCnt = 0; |
| 3805 | } |
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 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 3808 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3809 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3810 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 3811 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 3812 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3813 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3814 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
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 | while (RD_HARPOON(port + hp_scsisig) & SCSI_ACK) { |
| 3817 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3818 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3819 | TimeOutLoop = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3820 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3821 | while (RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY) { |
| 3822 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 3823 | return; |
| 3824 | } |
| 3825 | if (RD_HARPOON(port + hp_offsetctr) & (unsigned char)0x1F) { |
| 3826 | break; |
| 3827 | } |
| 3828 | if (RDW_HARPOON((port + hp_intstat)) & RESET) { |
| 3829 | return; |
| 3830 | } |
| 3831 | if ((RD_HARPOON(port + hp_scsisig) & SCSI_REQ) |
| 3832 | || (TimeOutLoop++ > 0x3000)) |
| 3833 | break; |
| 3834 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3835 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3836 | sPhase = RD_HARPOON(port + hp_scsisig) & (SCSI_BSY | S_SCSI_PHZ); |
| 3837 | if ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) || |
| 3838 | (RD_HARPOON(port + hp_offsetctr) & (unsigned char)0x1F) || |
| 3839 | (sPhase == (SCSI_BSY | S_DATAO_PH)) || |
| 3840 | (sPhase == (SCSI_BSY | S_DATAI_PH))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3841 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3842 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3843 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3844 | if (!(currSCCB->Sccb_XferState & F_ALL_XFERRED)) { |
| 3845 | if (currSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
| 3846 | FPT_phaseDataIn(port, p_card); |
| 3847 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3848 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3849 | else { |
| 3850 | FPT_phaseDataOut(port, p_card); |
| 3851 | } |
| 3852 | } else { |
| 3853 | FPT_sxfrp(port, p_card); |
| 3854 | if (!(RDW_HARPOON((port + hp_intstat)) & |
| 3855 | (BUS_FREE | ICMD_COMP | ITAR_DISC | RESET))) { |
| 3856 | WRW_HARPOON((port + hp_intstat), AUTO_INT); |
| 3857 | FPT_phaseDecode(port, p_card); |
| 3858 | } |
| 3859 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3860 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3861 | } |
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 | else { |
| 3864 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
| 3865 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3866 | } |
| 3867 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3868 | /*--------------------------------------------------------------------- |
| 3869 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3870 | * Function: FPT_sinits |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3871 | * |
| 3872 | * Description: Setup SCCB manager fields in this SCCB. |
| 3873 | * |
| 3874 | *---------------------------------------------------------------------*/ |
| 3875 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3876 | static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3877 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3878 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3879 | |
Dan Carpenter | 5d7ebb9 | 2009-12-28 20:08:39 +0200 | [diff] [blame] | 3880 | if ((p_sccb->TargID >= MAX_SCSI_TAR) || (p_sccb->Lun >= MAX_LUN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3881 | return; |
| 3882 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3883 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3884 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3885 | p_sccb->Sccb_XferState = 0x00; |
| 3886 | p_sccb->Sccb_XferCnt = p_sccb->DataLength; |
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 | if ((p_sccb->OperationCode == SCATTER_GATHER_COMMAND) || |
| 3889 | (p_sccb->OperationCode == RESIDUAL_SG_COMMAND)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3890 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3891 | p_sccb->Sccb_SGoffset = 0; |
| 3892 | p_sccb->Sccb_XferState = F_SG_XFER; |
| 3893 | p_sccb->Sccb_XferCnt = 0x00; |
| 3894 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3895 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3896 | if (p_sccb->DataLength == 0x00) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3897 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3898 | p_sccb->Sccb_XferState |= F_ALL_XFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3899 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3900 | if (p_sccb->ControlByte & F_USE_CMD_Q) { |
| 3901 | if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT) |
| 3902 | p_sccb->ControlByte &= ~F_USE_CMD_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3903 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3904 | else |
| 3905 | currTar_Info->TarStatus |= TAG_Q_TRYING; |
| 3906 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3907 | |
| 3908 | /* For !single SCSI device in system & device allow Disconnect |
| 3909 | or command is tag_q type then send Cmd with Disconnect Enable |
| 3910 | else send Cmd with Disconnect Disable */ |
| 3911 | |
| 3912 | /* |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 3913 | if (((!(FPT_BL_Card[p_card].globalFlags & F_SINGLE_DEVICE)) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3914 | (currTar_Info->TarStatus & TAR_ALLOW_DISC)) || |
| 3915 | (currTar_Info->TarStatus & TAG_Q_TRYING)) { |
| 3916 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3917 | if ((currTar_Info->TarStatus & TAR_ALLOW_DISC) || |
| 3918 | (currTar_Info->TarStatus & TAG_Q_TRYING)) { |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3919 | p_sccb->Sccb_idmsg = IDENTIFY(true, p_sccb->Lun); |
| 3920 | } else { |
| 3921 | p_sccb->Sccb_idmsg = IDENTIFY(false, p_sccb->Lun); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3922 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3923 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3924 | p_sccb->HostStatus = 0x00; |
| 3925 | p_sccb->TargetStatus = 0x00; |
| 3926 | p_sccb->Sccb_tag = 0x00; |
| 3927 | p_sccb->Sccb_MGRFlags = 0x00; |
| 3928 | p_sccb->Sccb_sgseg = 0x00; |
| 3929 | p_sccb->Sccb_ATC = 0x00; |
| 3930 | p_sccb->Sccb_savedATC = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3931 | /* |
| 3932 | p_sccb->SccbVirtDataPtr = 0x00; |
| 3933 | p_sccb->Sccb_forwardlink = NULL; |
| 3934 | p_sccb->Sccb_backlink = NULL; |
| 3935 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3936 | p_sccb->Sccb_scsistat = BUS_FREE_ST; |
| 3937 | p_sccb->SccbStatus = SCCB_IN_PROCESS; |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 3938 | p_sccb->Sccb_scsimsg = NOP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3939 | |
| 3940 | } |
| 3941 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3942 | /*--------------------------------------------------------------------- |
| 3943 | * |
| 3944 | * Function: Phase Decode |
| 3945 | * |
| 3946 | * Description: Determine the phase and call the appropriate function. |
| 3947 | * |
| 3948 | *---------------------------------------------------------------------*/ |
| 3949 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3950 | static void FPT_phaseDecode(u32 p_port, unsigned char p_card) |
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 | unsigned char phase_ref; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3953 | void (*phase) (u32, unsigned char); |
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 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3956 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3957 | phase_ref = |
| 3958 | (unsigned char)(RD_HARPOON(p_port + hp_scsisig) & S_SCSI_PHZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3959 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3960 | phase = FPT_s_PhaseTbl[phase_ref]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3961 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3962 | (*phase) (p_port, p_card); /* Call the correct phase func */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3963 | } |
| 3964 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3965 | /*--------------------------------------------------------------------- |
| 3966 | * |
| 3967 | * Function: Data Out Phase |
| 3968 | * |
| 3969 | * Description: Start up both the BusMaster and Xbow. |
| 3970 | * |
| 3971 | *---------------------------------------------------------------------*/ |
| 3972 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 3973 | static void FPT_phaseDataOut(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3974 | { |
| 3975 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3976 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3977 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3978 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 3979 | if (currSCCB == NULL) { |
| 3980 | return; /* Exit if No SCCB record */ |
| 3981 | } |
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 | currSCCB->Sccb_scsistat = DATA_OUT_ST; |
| 3984 | currSCCB->Sccb_XferState &= ~(F_HOST_XFER_DIR | F_NO_DATA_YET); |
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 | WR_HARPOON(port + hp_portctrl_0, SCSI_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 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3989 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3990 | WR_HARPOON(port + hp_autostart_0, (END_DATA + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3991 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3992 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3993 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3994 | if (currSCCB->Sccb_XferCnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3995 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 3996 | if ((currSCCB->ControlByte & SCCB_DATA_XFER_OUT) && |
| 3997 | (currSCCB->HostStatus == SCCB_COMPLETE)) |
| 3998 | currSCCB->HostStatus = SCCB_DATA_OVER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3999 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4000 | FPT_sxfrp(port, p_card); |
| 4001 | if (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | RESET))) |
| 4002 | FPT_phaseDecode(port, p_card); |
| 4003 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4004 | } |
| 4005 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4006 | /*--------------------------------------------------------------------- |
| 4007 | * |
| 4008 | * Function: Data In Phase |
| 4009 | * |
| 4010 | * Description: Startup the BusMaster and the XBOW. |
| 4011 | * |
| 4012 | *---------------------------------------------------------------------*/ |
| 4013 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4014 | static void FPT_phaseDataIn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4015 | { |
| 4016 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4017 | struct sccb *currSCCB; |
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 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
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 | if (currSCCB == NULL) { |
| 4022 | return; /* Exit if No SCCB record */ |
| 4023 | } |
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 | currSCCB->Sccb_scsistat = DATA_IN_ST; |
| 4026 | currSCCB->Sccb_XferState |= F_HOST_XFER_DIR; |
| 4027 | currSCCB->Sccb_XferState &= ~F_NO_DATA_YET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4029 | WR_HARPOON(port + hp_portctrl_0, SCSI_PORT); |
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 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4033 | WR_HARPOON(port + hp_autostart_0, (END_DATA + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4034 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4035 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4036 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4037 | if (currSCCB->Sccb_XferCnt == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4038 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4039 | if ((currSCCB->ControlByte & SCCB_DATA_XFER_IN) && |
| 4040 | (currSCCB->HostStatus == SCCB_COMPLETE)) |
| 4041 | currSCCB->HostStatus = SCCB_DATA_OVER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4043 | FPT_sxfrp(port, p_card); |
| 4044 | if (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | RESET))) |
| 4045 | FPT_phaseDecode(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4046 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4047 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4048 | } |
| 4049 | |
| 4050 | /*--------------------------------------------------------------------- |
| 4051 | * |
| 4052 | * Function: Command Phase |
| 4053 | * |
| 4054 | * Description: Load the CDB into the automation and start it up. |
| 4055 | * |
| 4056 | *---------------------------------------------------------------------*/ |
| 4057 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4058 | static void FPT_phaseCommand(u32 p_port, unsigned char p_card) |
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 | struct sccb *currSCCB; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4061 | u32 cdb_reg; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4062 | unsigned char i; |
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 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
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 | if (currSCCB->OperationCode == RESET_COMMAND) { |
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 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4069 | currSCCB->CdbLength = SIX_BYTE_CMD; |
| 4070 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4071 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4072 | WR_HARPOON(p_port + hp_scsisig, 0x00); |
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 | ARAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4075 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4076 | cdb_reg = p_port + CMD_STRT; |
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 | for (i = 0; i < currSCCB->CdbLength; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4079 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4080 | if (currSCCB->OperationCode == RESET_COMMAND) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4081 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4082 | WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + 0x00)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4083 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4084 | else |
| 4085 | WRW_HARPOON(cdb_reg, |
| 4086 | (MPM_OP + ACOMMAND + currSCCB->Cdb[i])); |
| 4087 | cdb_reg += 2; |
| 4088 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4089 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4090 | if (currSCCB->CdbLength != TWELVE_BYTE_CMD) |
| 4091 | WRW_HARPOON(cdb_reg, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4092 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4093 | WR_HARPOON(p_port + hp_portctrl_0, (SCSI_PORT)); |
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->Sccb_scsistat = COMMAND_ST; |
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 | WR_HARPOON(p_port + hp_autostart_3, (AUTO_IMMED | CMD_ONLY_STRT)); |
| 4098 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4099 | } |
| 4100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4101 | /*--------------------------------------------------------------------- |
| 4102 | * |
| 4103 | * Function: Status phase |
| 4104 | * |
| 4105 | * Description: Bring in the status and command complete message bytes |
| 4106 | * |
| 4107 | *---------------------------------------------------------------------*/ |
| 4108 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4109 | static void FPT_phaseStatus(u32 port, unsigned char p_card) |
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 | /* Start-up the automation to finish off this command and let the |
| 4112 | isr handle the interrupt for command complete when it comes in. |
| 4113 | We could wait here for the interrupt to be generated? |
| 4114 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4115 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4116 | WR_HARPOON(port + hp_scsisig, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4117 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4118 | WR_HARPOON(port + hp_autostart_0, (AUTO_IMMED + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4119 | } |
| 4120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4121 | /*--------------------------------------------------------------------- |
| 4122 | * |
| 4123 | * Function: Phase Message Out |
| 4124 | * |
| 4125 | * Description: Send out our message (if we have one) and handle whatever |
| 4126 | * else is involed. |
| 4127 | * |
| 4128 | *---------------------------------------------------------------------*/ |
| 4129 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4130 | static void FPT_phaseMsgOut(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4131 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4132 | unsigned char message, scsiID; |
| 4133 | struct sccb *currSCCB; |
| 4134 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4135 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4136 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4137 | |
| 4138 | if (currSCCB != NULL) { |
| 4139 | |
| 4140 | message = currSCCB->Sccb_scsimsg; |
| 4141 | scsiID = currSCCB->TargID; |
| 4142 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4143 | if (message == TARGET_RESET) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4144 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4145 | currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4146 | currTar_Info->TarSyncCtrl = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4147 | FPT_sssyncv(port, scsiID, NARROW_SCSI, currTar_Info); |
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 | if (FPT_sccbMgrTbl[p_card][scsiID]. |
| 4150 | TarEEValue & EE_SYNC_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4151 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4152 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus &= |
| 4153 | ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4154 | |
| 4155 | } |
| 4156 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4157 | if (FPT_sccbMgrTbl[p_card][scsiID]. |
| 4158 | TarEEValue & EE_WIDE_SCSI) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4159 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4160 | FPT_sccbMgrTbl[p_card][scsiID].TarStatus &= |
| 4161 | ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4162 | } |
| 4163 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4164 | FPT_queueFlushSccb(p_card, SCCB_COMPLETE); |
| 4165 | FPT_SccbMgrTableInitTarget(p_card, scsiID); |
| 4166 | } else if (currSCCB->Sccb_scsistat == ABORT_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4167 | currSCCB->HostStatus = SCCB_COMPLETE; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4168 | if (FPT_BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] != |
| 4169 | NULL) { |
| 4170 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4171 | Sccb_tag] = NULL; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4172 | FPT_sccbMgrTbl[p_card][scsiID].TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4173 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4174 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4175 | } |
| 4176 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4177 | else if (currSCCB->Sccb_scsistat < COMMAND_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4178 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4179 | if (message == NOP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4180 | currSCCB->Sccb_MGRFlags |= F_DEV_SELECTED; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4181 | |
| 4182 | FPT_ssel(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4183 | return; |
| 4184 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4185 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4186 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4187 | if (message == ABORT_TASK_SET) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4188 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4189 | FPT_queueFlushSccb(p_card, SCCB_COMPLETE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4190 | } |
| 4191 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4192 | } else { |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4193 | message = ABORT_TASK_SET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4194 | } |
| 4195 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4196 | WRW_HARPOON((port + hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4197 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4198 | WR_HARPOON(port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4199 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4200 | WR_HARPOON(port + hp_scsidata_0, message); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4201 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4202 | WR_HARPOON(port + hp_scsisig, (SCSI_ACK + S_ILL_PH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4203 | |
| 4204 | ACCEPT_MSG(port); |
| 4205 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4206 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4207 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4208 | if ((message == ABORT_TASK_SET) || (message == TARGET_RESET) || |
| 4209 | (message == ABORT_TASK)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4210 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4211 | while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | PHASE))) { |
| 4212 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4213 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4214 | if (RDW_HARPOON((port + hp_intstat)) & BUS_FREE) { |
| 4215 | WRW_HARPOON((port + hp_intstat), BUS_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4216 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4217 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4218 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4219 | if ((FPT_BL_Card[p_card]. |
| 4220 | globalFlags & F_CONLUN_IO) |
| 4221 | && |
| 4222 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4223 | TarStatus & TAR_TAG_Q_MASK) != |
| 4224 | TAG_Q_TRYING)) |
| 4225 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4226 | TargID]. |
| 4227 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4228 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4229 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4230 | TargID]. |
| 4231 | TarLUNBusy[0] = 0; |
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 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 4234 | currSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4235 | } |
| 4236 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4237 | else { |
| 4238 | FPT_BL_Card[p_card].globalFlags |= |
| 4239 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4240 | } |
| 4241 | } |
| 4242 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4243 | else { |
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 | FPT_sxfrp(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4246 | } |
| 4247 | } |
| 4248 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4249 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4250 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4251 | if (message == MSG_PARITY_ERROR) { |
| 4252 | currSCCB->Sccb_scsimsg = NOP; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4253 | WR_HARPOON(port + hp_autostart_1, |
| 4254 | (AUTO_IMMED + DISCONNECT_START)); |
| 4255 | } else { |
| 4256 | FPT_sxfrp(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4257 | } |
| 4258 | } |
| 4259 | } |
| 4260 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4261 | /*--------------------------------------------------------------------- |
| 4262 | * |
| 4263 | * Function: Message In phase |
| 4264 | * |
| 4265 | * Description: Bring in the message and determine what to do with it. |
| 4266 | * |
| 4267 | *---------------------------------------------------------------------*/ |
| 4268 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4269 | static void FPT_phaseMsgIn(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4270 | { |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 4271 | unsigned char message; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4272 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4273 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4274 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
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 | if (FPT_BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4277 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4278 | FPT_phaseChkFifo(port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4279 | } |
| 4280 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4281 | message = RD_HARPOON(port + hp_scsidata_0); |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4282 | if ((message == DISCONNECT) || (message == SAVE_POINTERS)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4283 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4284 | WR_HARPOON(port + hp_autostart_1, |
| 4285 | (AUTO_IMMED + END_DATA_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4286 | |
| 4287 | } |
| 4288 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4289 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4290 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4291 | message = FPT_sfm(port, currSCCB); |
| 4292 | if (message) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4293 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4294 | FPT_sdecm(message, port, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4295 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4296 | } else { |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4297 | if (currSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4298 | ACCEPT_MSG(port); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4299 | WR_HARPOON(port + hp_autostart_1, |
| 4300 | (AUTO_IMMED + DISCONNECT_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4301 | } |
| 4302 | } |
| 4303 | |
| 4304 | } |
| 4305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4306 | /*--------------------------------------------------------------------- |
| 4307 | * |
| 4308 | * Function: Illegal phase |
| 4309 | * |
| 4310 | * Description: Target switched to some illegal phase, so all we can do |
| 4311 | * is report an error back to the host (if that is possible) |
| 4312 | * and send an ABORT message to the misbehaving target. |
| 4313 | * |
| 4314 | *---------------------------------------------------------------------*/ |
| 4315 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4316 | static void FPT_phaseIllegal(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4317 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4318 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4319 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4320 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
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 | WR_HARPOON(port + hp_scsisig, RD_HARPOON(port + hp_scsisig)); |
| 4323 | if (currSCCB != NULL) { |
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 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4326 | currSCCB->Sccb_scsistat = ABORT_ST; |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4327 | currSCCB->Sccb_scsimsg = ABORT_TASK_SET; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4328 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4329 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4330 | ACCEPT_MSG_ATN(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4331 | } |
| 4332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4333 | /*--------------------------------------------------------------------- |
| 4334 | * |
| 4335 | * Function: Phase Check FIFO |
| 4336 | * |
| 4337 | * Description: Make sure data has been flushed from both FIFOs and abort |
| 4338 | * the operations if necessary. |
| 4339 | * |
| 4340 | *---------------------------------------------------------------------*/ |
| 4341 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4342 | static void FPT_phaseChkFifo(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4343 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4344 | u32 xfercnt; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4345 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4346 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4347 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
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 | if (currSCCB->Sccb_scsistat == DATA_IN_ST) { |
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 | while ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) && |
| 4352 | (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY)) { |
| 4353 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4354 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4355 | if (!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) { |
| 4356 | currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4357 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4358 | currSCCB->Sccb_XferCnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4359 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4360 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 4361 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
| 4362 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 4363 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 4364 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4365 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4366 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4367 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4368 | FPT_dataXferProcessor(port, &FPT_BL_Card[p_card]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4369 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4370 | while ((!(RD_HARPOON(port + hp_xferstat) & FIFO_EMPTY)) |
| 4371 | && (RD_HARPOON(port + hp_ext_status) & |
| 4372 | BM_CMD_BUSY)) { |
| 4373 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4374 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4375 | } |
| 4376 | } |
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 | /*End Data In specific code. */ |
| 4379 | GET_XFER_CNT(port, xfercnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4381 | WR_HARPOON(port + hp_xfercnt_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4382 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4383 | WR_HARPOON(port + hp_portctrl_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4384 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4385 | currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - xfercnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4386 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4387 | currSCCB->Sccb_XferCnt = 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 | if ((RDW_HARPOON((port + hp_intstat)) & PARITY) && |
| 4390 | (currSCCB->HostStatus == SCCB_COMPLETE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4391 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4392 | currSCCB->HostStatus = SCCB_PARITY_ERR; |
| 4393 | WRW_HARPOON((port + hp_intstat), PARITY); |
| 4394 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4395 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4396 | FPT_hostDataXferAbort(port, p_card, currSCCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4397 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4398 | WR_HARPOON(port + hp_fifowrite, 0x00); |
| 4399 | WR_HARPOON(port + hp_fiforead, 0x00); |
| 4400 | WR_HARPOON(port + hp_xferstat, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4401 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4402 | WRW_HARPOON((port + hp_intstat), XFER_CNT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4403 | } |
| 4404 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4405 | /*--------------------------------------------------------------------- |
| 4406 | * |
| 4407 | * Function: Phase Bus Free |
| 4408 | * |
| 4409 | * Description: We just went bus free so figure out if it was |
| 4410 | * because of command complete or from a disconnect. |
| 4411 | * |
| 4412 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4413 | static void FPT_phaseBusFree(u32 port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4414 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4415 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4416 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4417 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4418 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4419 | if (currSCCB != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4420 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4421 | DISABLE_AUTO(port); |
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 | if (currSCCB->OperationCode == RESET_COMMAND) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4424 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4425 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4426 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4427 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4428 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4429 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4430 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4431 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4432 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4433 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4434 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, |
| 4435 | p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4437 | FPT_queueSearchSelect(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4439 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4440 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4441 | else if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
| 4442 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= |
| 4443 | (unsigned char)SYNC_SUPPORTED; |
| 4444 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4445 | ~EE_SYNC_MASK; |
| 4446 | } |
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 | else if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
| 4449 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus = |
| 4450 | (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4451 | TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4452 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4453 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4454 | ~EE_WIDE_SCSI; |
| 4455 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4456 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4457 | else if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { |
| 4458 | /* Make sure this is not a phony BUS_FREE. If we were |
| 4459 | reselected or if BUSY is NOT on then this is a |
| 4460 | valid BUS FREE. SRR Wednesday, 5/10/1995. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4461 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4462 | if ((!(RD_HARPOON(port + hp_scsisig) & SCSI_BSY)) || |
| 4463 | (RDW_HARPOON((port + hp_intstat)) & RSEL)) { |
| 4464 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4465 | TarStatus &= ~TAR_TAG_Q_MASK; |
| 4466 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4467 | TarStatus |= TAG_Q_REJECT; |
| 4468 | } |
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 | else { |
| 4471 | return; |
| 4472 | } |
| 4473 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4474 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4475 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4476 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4477 | currSCCB->Sccb_scsistat = BUS_FREE_ST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4478 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4479 | if (!currSCCB->HostStatus) { |
| 4480 | currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; |
| 4481 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4482 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4483 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4484 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4485 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4486 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4487 | TarLUNBusy[currSCCB->Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4488 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4489 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4490 | TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4492 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, |
| 4493 | p_card); |
| 4494 | return; |
| 4495 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4496 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4497 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4498 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4499 | } /*end if !=null */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4500 | } |
| 4501 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4502 | /*--------------------------------------------------------------------- |
| 4503 | * |
| 4504 | * Function: Auto Load Default Map |
| 4505 | * |
zuoqilin | 083d248 | 2021-03-04 13:51:20 +0800 | [diff] [blame] | 4506 | * Description: Load the Automation RAM with the default map values. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4507 | * |
| 4508 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4509 | static void FPT_autoLoadDefaultMap(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4510 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4511 | u32 map_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4512 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4513 | ARAM_ACCESS(p_port); |
| 4514 | map_addr = p_port + hp_aramBase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4515 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4516 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0xC0)); /*ID MESSAGE */ |
| 4517 | map_addr += 2; |
| 4518 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0x20)); /*SIMPLE TAG QUEUEING MSG */ |
| 4519 | map_addr += 2; |
| 4520 | WRW_HARPOON(map_addr, RAT_OP); /*RESET ATTENTION */ |
| 4521 | map_addr += 2; |
| 4522 | WRW_HARPOON(map_addr, (MPM_OP + AMSG_OUT + 0x00)); /*TAG ID MSG */ |
| 4523 | map_addr += 2; |
| 4524 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 0 */ |
| 4525 | map_addr += 2; |
| 4526 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 1 */ |
| 4527 | map_addr += 2; |
| 4528 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 2 */ |
| 4529 | map_addr += 2; |
| 4530 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 3 */ |
| 4531 | map_addr += 2; |
| 4532 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 4 */ |
| 4533 | map_addr += 2; |
| 4534 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 5 */ |
| 4535 | map_addr += 2; |
| 4536 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 6 */ |
| 4537 | map_addr += 2; |
| 4538 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 7 */ |
| 4539 | map_addr += 2; |
| 4540 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 8 */ |
| 4541 | map_addr += 2; |
| 4542 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 9 */ |
| 4543 | map_addr += 2; |
| 4544 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 10 */ |
| 4545 | map_addr += 2; |
| 4546 | WRW_HARPOON(map_addr, (MPM_OP + ACOMMAND + 0x00)); /*CDB BYTE 11 */ |
| 4547 | map_addr += 2; |
| 4548 | WRW_HARPOON(map_addr, (CPE_OP + ADATA_OUT + DINT)); /*JUMP IF DATA OUT */ |
| 4549 | map_addr += 2; |
| 4550 | WRW_HARPOON(map_addr, (TCB_OP + FIFO_0 + DI)); /*JUMP IF NO DATA IN FIFO */ |
| 4551 | map_addr += 2; /*This means AYNC DATA IN */ |
| 4552 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IDO_STRT)); /*STOP AND INTERRUPT */ |
| 4553 | map_addr += 2; |
| 4554 | WRW_HARPOON(map_addr, (CPE_OP + ADATA_IN + DINT)); /*JUMP IF NOT DATA IN PHZ */ |
| 4555 | map_addr += 2; |
| 4556 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + ST)); /*IF NOT MSG IN CHECK 4 DATA IN */ |
| 4557 | map_addr += 2; |
| 4558 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x02)); /*SAVE DATA PTR MSG? */ |
| 4559 | map_addr += 2; |
| 4560 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + DC)); /*GO CHECK FOR DISCONNECT MSG */ |
| 4561 | map_addr += 2; |
| 4562 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_AR1)); /*SAVE DATA PTRS MSG */ |
| 4563 | map_addr += 2; |
| 4564 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + ST)); /*IF NOT MSG IN CHECK DATA IN */ |
| 4565 | map_addr += 2; |
| 4566 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x04)); /*DISCONNECT MSG? */ |
| 4567 | map_addr += 2; |
| 4568 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + UNKNWN)); /*UKNKNOWN MSG */ |
| 4569 | map_addr += 2; |
| 4570 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_BUCKET)); /*XFER DISCONNECT MSG */ |
| 4571 | map_addr += 2; |
| 4572 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ITAR_DISC)); /*STOP AND INTERRUPT */ |
| 4573 | map_addr += 2; |
| 4574 | WRW_HARPOON(map_addr, (CPN_OP + ASTATUS + UNKNWN)); /*JUMP IF NOT STATUS PHZ. */ |
| 4575 | map_addr += 2; |
| 4576 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_AR0)); /*GET STATUS BYTE */ |
| 4577 | map_addr += 2; |
| 4578 | WRW_HARPOON(map_addr, (CPN_OP + AMSG_IN + CC)); /*ERROR IF NOT MSG IN PHZ */ |
| 4579 | map_addr += 2; |
| 4580 | WRW_HARPOON(map_addr, (CRD_OP + SDATA + 0x00)); /*CHECK FOR CMD COMPLETE MSG. */ |
| 4581 | map_addr += 2; |
| 4582 | WRW_HARPOON(map_addr, (BRH_OP + NOT_EQ + CC)); /*ERROR IF NOT CMD COMPLETE MSG. */ |
| 4583 | map_addr += 2; |
| 4584 | WRW_HARPOON(map_addr, (MRR_OP + SDATA + D_BUCKET)); /*GET CMD COMPLETE MSG */ |
| 4585 | map_addr += 2; |
| 4586 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ICMD_COMP)); /*END OF COMMAND */ |
| 4587 | map_addr += 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4588 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4589 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IUNKWN)); /*RECEIVED UNKNOWN MSG BYTE */ |
| 4590 | map_addr += 2; |
| 4591 | WRW_HARPOON(map_addr, (SSI_OP + SSI_INO_CC)); /*NO COMMAND COMPLETE AFTER STATUS */ |
| 4592 | map_addr += 2; |
| 4593 | WRW_HARPOON(map_addr, (SSI_OP + SSI_ITICKLE)); /*BIOS Tickled the Mgr */ |
| 4594 | map_addr += 2; |
| 4595 | WRW_HARPOON(map_addr, (SSI_OP + SSI_IRFAIL)); /*EXPECTED ID/TAG MESSAGES AND */ |
| 4596 | map_addr += 2; /* DIDN'T GET ONE */ |
| 4597 | WRW_HARPOON(map_addr, (CRR_OP + AR3 + S_IDREG)); /* comp SCSI SEL ID & AR3 */ |
| 4598 | map_addr += 2; |
| 4599 | WRW_HARPOON(map_addr, (BRH_OP + EQUAL + 0x00)); /*SEL ID OK then Conti. */ |
| 4600 | map_addr += 2; |
| 4601 | 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] | 4602 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4603 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4604 | } |
| 4605 | |
| 4606 | /*--------------------------------------------------------------------- |
| 4607 | * |
| 4608 | * Function: Auto Command Complete |
| 4609 | * |
| 4610 | * Description: Post command back to host and find another command |
| 4611 | * to execute. |
| 4612 | * |
| 4613 | *---------------------------------------------------------------------*/ |
| 4614 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4615 | static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4616 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4617 | struct sccb *currSCCB; |
| 4618 | unsigned char status_byte; |
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 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4621 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4622 | status_byte = RD_HARPOON(p_port + hp_gp_reg_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4623 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4624 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUN_CA = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4625 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4626 | if (status_byte != SAM_STAT_GOOD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4627 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4628 | if (status_byte == SAM_STAT_TASK_SET_FULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4629 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4630 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4631 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4632 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4633 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4634 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4635 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4636 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4637 | FPT_BL_Card[p_card]. |
| 4638 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4639 | [currSCCB->TargID]. |
| 4640 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4641 | NULL; |
| 4642 | } else { |
| 4643 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4644 | TarLUNBusy[0] = 1; |
| 4645 | if (currSCCB->Sccb_tag) { |
| 4646 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4647 | FPT_BL_Card[p_card]. |
| 4648 | discQCount--; |
| 4649 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4650 | Sccb_tag] |
| 4651 | = NULL; |
| 4652 | } else { |
| 4653 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4654 | FPT_BL_Card[p_card]. |
| 4655 | discQCount--; |
| 4656 | FPT_BL_Card[p_card]. |
| 4657 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4658 | [currSCCB->TargID]. |
| 4659 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4660 | } |
| 4661 | } |
| 4662 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4663 | currSCCB->Sccb_MGRFlags |= F_STATUSLOADED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4664 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4665 | FPT_queueSelectFail(&FPT_BL_Card[p_card], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4666 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4667 | return; |
| 4668 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4669 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4670 | if (currSCCB->Sccb_scsistat == SELECT_SN_ST) { |
| 4671 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= |
| 4672 | (unsigned char)SYNC_SUPPORTED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4673 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4674 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4675 | ~EE_SYNC_MASK; |
| 4676 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4677 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4678 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4679 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4680 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4681 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4682 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4683 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4684 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4685 | FPT_BL_Card[p_card]. |
| 4686 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4687 | [currSCCB->TargID]. |
| 4688 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4689 | NULL; |
| 4690 | } else { |
| 4691 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4692 | TarLUNBusy[0] = 1; |
| 4693 | if (currSCCB->Sccb_tag) { |
| 4694 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4695 | FPT_BL_Card[p_card]. |
| 4696 | discQCount--; |
| 4697 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4698 | Sccb_tag] |
| 4699 | = NULL; |
| 4700 | } else { |
| 4701 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4702 | FPT_BL_Card[p_card]. |
| 4703 | discQCount--; |
| 4704 | FPT_BL_Card[p_card]. |
| 4705 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4706 | [currSCCB->TargID]. |
| 4707 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4708 | } |
| 4709 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4710 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4711 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4712 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4713 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4714 | if (currSCCB->Sccb_scsistat == SELECT_WN_ST) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4715 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4716 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarStatus = |
| 4717 | (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4718 | TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4719 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4720 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= |
| 4721 | ~EE_WIDE_SCSI; |
| 4722 | FPT_BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4723 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4724 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4725 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4726 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 4727 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4728 | TarLUNBusy[currSCCB->Lun] = 1; |
| 4729 | if (FPT_BL_Card[p_card].discQCount != 0) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 4730 | FPT_BL_Card[p_card].discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4731 | FPT_BL_Card[p_card]. |
| 4732 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4733 | [currSCCB->TargID]. |
| 4734 | LunDiscQ_Idx[currSCCB->Lun]] = |
| 4735 | NULL; |
| 4736 | } else { |
| 4737 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4738 | TarLUNBusy[0] = 1; |
| 4739 | if (currSCCB->Sccb_tag) { |
| 4740 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4741 | FPT_BL_Card[p_card]. |
| 4742 | discQCount--; |
| 4743 | FPT_BL_Card[p_card].discQ_Tbl[currSCCB-> |
| 4744 | Sccb_tag] |
| 4745 | = NULL; |
| 4746 | } else { |
| 4747 | if (FPT_BL_Card[p_card].discQCount != 0) |
| 4748 | FPT_BL_Card[p_card]. |
| 4749 | discQCount--; |
| 4750 | FPT_BL_Card[p_card]. |
| 4751 | discQ_Tbl[FPT_sccbMgrTbl[p_card] |
| 4752 | [currSCCB->TargID]. |
| 4753 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4754 | } |
| 4755 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4756 | return; |
| 4757 | |
| 4758 | } |
| 4759 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4760 | if (status_byte == SAM_STAT_CHECK_CONDITION) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4761 | if (FPT_BL_Card[p_card].globalFlags & F_DO_RENEGO) { |
| 4762 | if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4763 | TarEEValue & EE_SYNC_MASK) { |
| 4764 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4765 | TargID]. |
| 4766 | TarStatus &= ~TAR_SYNC_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4767 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4768 | if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4769 | TarEEValue & EE_WIDE_SCSI) { |
| 4770 | FPT_sccbMgrTbl[p_card][currSCCB-> |
| 4771 | TargID]. |
| 4772 | TarStatus &= ~TAR_WIDE_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4773 | } |
| 4774 | } |
| 4775 | } |
| 4776 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4777 | if (!(currSCCB->Sccb_XferState & F_AUTO_SENSE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4778 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4779 | currSCCB->SccbStatus = SCCB_ERROR; |
| 4780 | currSCCB->TargetStatus = status_byte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4781 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 4782 | if (status_byte == SAM_STAT_CHECK_CONDITION) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4783 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4784 | FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4785 | TarLUN_CA = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4786 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4787 | if (currSCCB->RequestSenseLength != |
| 4788 | NO_AUTO_REQUEST_SENSE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4789 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4790 | if (currSCCB->RequestSenseLength == 0) |
| 4791 | currSCCB->RequestSenseLength = |
| 4792 | 14; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4793 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4794 | FPT_ssenss(&FPT_BL_Card[p_card]); |
| 4795 | FPT_BL_Card[p_card].globalFlags |= |
| 4796 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4797 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4798 | if (((FPT_BL_Card[p_card]. |
| 4799 | globalFlags & F_CONLUN_IO) |
| 4800 | && |
| 4801 | ((FPT_sccbMgrTbl[p_card] |
| 4802 | [currSCCB->TargID]. |
| 4803 | TarStatus & TAR_TAG_Q_MASK) != |
| 4804 | TAG_Q_TRYING))) { |
| 4805 | FPT_sccbMgrTbl[p_card] |
| 4806 | [currSCCB->TargID]. |
| 4807 | TarLUNBusy[currSCCB->Lun] = |
| 4808 | 1; |
| 4809 | if (FPT_BL_Card[p_card]. |
| 4810 | discQCount != 0) |
| 4811 | FPT_BL_Card[p_card]. |
| 4812 | discQCount--; |
| 4813 | FPT_BL_Card[p_card]. |
| 4814 | discQ_Tbl[FPT_sccbMgrTbl |
| 4815 | [p_card] |
| 4816 | [currSCCB-> |
| 4817 | TargID]. |
| 4818 | LunDiscQ_Idx |
| 4819 | [currSCCB->Lun]] = |
| 4820 | NULL; |
| 4821 | } else { |
| 4822 | FPT_sccbMgrTbl[p_card] |
| 4823 | [currSCCB->TargID]. |
| 4824 | TarLUNBusy[0] = 1; |
| 4825 | if (currSCCB->Sccb_tag) { |
| 4826 | if (FPT_BL_Card[p_card]. |
| 4827 | discQCount != 0) |
| 4828 | FPT_BL_Card |
| 4829 | [p_card]. |
| 4830 | discQCount--; |
| 4831 | FPT_BL_Card[p_card]. |
| 4832 | discQ_Tbl[currSCCB-> |
| 4833 | Sccb_tag] |
| 4834 | = NULL; |
| 4835 | } else { |
| 4836 | if (FPT_BL_Card[p_card]. |
| 4837 | discQCount != 0) |
| 4838 | FPT_BL_Card |
| 4839 | [p_card]. |
| 4840 | discQCount--; |
| 4841 | FPT_BL_Card[p_card]. |
| 4842 | discQ_Tbl |
| 4843 | [FPT_sccbMgrTbl |
| 4844 | [p_card][currSCCB-> |
| 4845 | TargID]. |
| 4846 | LunDiscQ_Idx[0]] = |
| 4847 | NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4848 | } |
| 4849 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4850 | return; |
| 4851 | } |
| 4852 | } |
| 4853 | } |
| 4854 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4855 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4856 | if ((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 4857 | ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. |
| 4858 | TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)) |
| 4859 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB-> |
| 4860 | Lun] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4861 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4862 | FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4863 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4864 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], currSCCB, p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4865 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4866 | |
| 4867 | #define SHORT_WAIT 0x0000000F |
| 4868 | #define LONG_WAIT 0x0000FFFFL |
| 4869 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4870 | /*--------------------------------------------------------------------- |
| 4871 | * |
| 4872 | * Function: Data Transfer Processor |
| 4873 | * |
| 4874 | * Description: This routine performs two tasks. |
| 4875 | * (1) Start data transfer by calling HOST_DATA_XFER_START |
| 4876 | * function. Once data transfer is started, (2) Depends |
| 4877 | * on the type of data transfer mode Scatter/Gather mode |
| 4878 | * or NON Scatter/Gather mode. In NON Scatter/Gather mode, |
| 4879 | * this routine checks Sccb_MGRFlag (F_HOST_XFER_ACT bit) for |
| 4880 | * data transfer done. In Scatter/Gather mode, this routine |
| 4881 | * checks bus master command complete and dual rank busy |
| 4882 | * bit to keep chaining SC transfer command. Similarly, |
| 4883 | * in Scatter/Gather mode, it checks Sccb_MGRFlag |
| 4884 | * (F_HOST_XFER_ACT bit) for data transfer done. |
| 4885 | * |
| 4886 | *---------------------------------------------------------------------*/ |
| 4887 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4888 | static void FPT_dataXferProcessor(u32 port, struct sccb_card *pCurrCard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4889 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4890 | struct sccb *currSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4891 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4892 | currSCCB = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4893 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4894 | if (currSCCB->Sccb_XferState & F_SG_XFER) { |
| 4895 | if (pCurrCard->globalFlags & F_HOST_XFER_ACT) |
| 4896 | { |
| 4897 | currSCCB->Sccb_sgseg += (unsigned char)SG_BUF_CNT; |
| 4898 | currSCCB->Sccb_SGoffset = 0x00; |
| 4899 | } |
| 4900 | pCurrCard->globalFlags |= F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4901 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4902 | FPT_busMstrSGDataXferStart(port, currSCCB); |
| 4903 | } |
| 4904 | |
| 4905 | else { |
| 4906 | if (!(pCurrCard->globalFlags & F_HOST_XFER_ACT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4907 | pCurrCard->globalFlags |= F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4908 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4909 | FPT_busMstrDataXferStart(port, currSCCB); |
| 4910 | } |
| 4911 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4912 | } |
| 4913 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4914 | /*--------------------------------------------------------------------- |
| 4915 | * |
| 4916 | * Function: BusMaster Scatter Gather Data Transfer Start |
| 4917 | * |
| 4918 | * Description: |
| 4919 | * |
| 4920 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4921 | static void FPT_busMstrSGDataXferStart(u32 p_port, struct sccb *pcurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4922 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4923 | u32 count, addr, tmpSGCnt; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4924 | unsigned int sg_index; |
| 4925 | unsigned char sg_count, i; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4926 | u32 reg_offset; |
| 4927 | struct blogic_sg_seg *segp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4928 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4929 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) |
| 4930 | count = ((u32)HOST_RD_CMD) << 24; |
| 4931 | else |
| 4932 | count = ((u32)HOST_WRT_CMD) << 24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4933 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4934 | sg_count = 0; |
| 4935 | tmpSGCnt = 0; |
| 4936 | sg_index = pcurrSCCB->Sccb_sgseg; |
| 4937 | reg_offset = hp_aramBase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4938 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4939 | i = (unsigned char)(RD_HARPOON(p_port + hp_page_ctrl) & |
| 4940 | ~(SGRAM_ARAM | SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4941 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4942 | WR_HARPOON(p_port + hp_page_ctrl, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4943 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4944 | while ((sg_count < (unsigned char)SG_BUF_CNT) && |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4945 | ((sg_index * (unsigned int)SG_ELEMENT_SIZE) < |
| 4946 | pcurrSCCB->DataLength)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4947 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 4948 | segp = (struct blogic_sg_seg *)(pcurrSCCB->DataPointer) + |
| 4949 | sg_index; |
| 4950 | tmpSGCnt += segp->segbytes; |
| 4951 | count |= segp->segbytes; |
| 4952 | addr = segp->segdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4953 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4954 | if ((!sg_count) && (pcurrSCCB->Sccb_SGoffset)) { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4955 | addr += |
| 4956 | ((count & 0x00FFFFFFL) - pcurrSCCB->Sccb_SGoffset); |
| 4957 | count = |
| 4958 | (count & 0xFF000000L) | pcurrSCCB->Sccb_SGoffset; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4959 | tmpSGCnt = count & 0x00FFFFFFL; |
| 4960 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4961 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4962 | WR_HARP32(p_port, reg_offset, addr); |
| 4963 | reg_offset += 4; |
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 | WR_HARP32(p_port, reg_offset, count); |
| 4966 | reg_offset += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4967 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4968 | count &= 0xFF000000L; |
| 4969 | sg_index++; |
| 4970 | sg_count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4971 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4972 | } /*End While */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4973 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4974 | pcurrSCCB->Sccb_XferCnt = tmpSGCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4975 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4976 | WR_HARPOON(p_port + hp_sg_addr, (sg_count << 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4977 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4978 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4979 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4980 | WR_HARP32(p_port, hp_xfercnt_0, tmpSGCnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4981 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4982 | WR_HARPOON(p_port + hp_portctrl_0, |
| 4983 | (DMA_PORT | SCSI_PORT | SCSI_INBIT)); |
| 4984 | WR_HARPOON(p_port + hp_scsisig, S_DATAI_PH); |
| 4985 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4986 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4987 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4988 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4989 | if ((!(RD_HARPOON(p_port + hp_synctarg_0) & NARROW_SCSI)) && |
| 4990 | (tmpSGCnt & 0x000000001)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4991 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4992 | pcurrSCCB->Sccb_XferState |= F_ODD_BALL_CNT; |
| 4993 | tmpSGCnt--; |
| 4994 | } |
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, hp_xfercnt_0, tmpSGCnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4997 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 4998 | WR_HARPOON(p_port + hp_portctrl_0, |
| 4999 | (SCSI_PORT | DMA_PORT | DMA_RD)); |
| 5000 | WR_HARPOON(p_port + hp_scsisig, S_DATAO_PH); |
| 5001 | } |
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 | WR_HARPOON(p_port + hp_page_ctrl, (unsigned char)(i | SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5004 | |
| 5005 | } |
| 5006 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5007 | /*--------------------------------------------------------------------- |
| 5008 | * |
| 5009 | * Function: BusMaster Data Transfer Start |
| 5010 | * |
| 5011 | * Description: |
| 5012 | * |
| 5013 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5014 | static void FPT_busMstrDataXferStart(u32 p_port, struct sccb *pcurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5015 | { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5016 | u32 addr, count; |
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 | if (!(pcurrSCCB->Sccb_XferState & F_AUTO_SENSE)) { |
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 | count = pcurrSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5021 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5022 | addr = (u32)(unsigned long)pcurrSCCB->DataPointer + pcurrSCCB->Sccb_ATC; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5023 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5024 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5025 | else { |
| 5026 | addr = pcurrSCCB->SensePointer; |
| 5027 | count = pcurrSCCB->RequestSenseLength; |
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 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5030 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5031 | HP_SETUP_ADDR_CNT(p_port, addr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5033 | if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5034 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5035 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5036 | (DMA_PORT | SCSI_PORT | SCSI_INBIT)); |
| 5037 | WR_HARPOON(p_port + hp_scsisig, S_DATAI_PH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5038 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5039 | WR_HARPOON(p_port + hp_xfer_cmd, |
| 5040 | (XFER_DMA_HOST | XFER_HOST_AUTO | XFER_DMA_8BIT)); |
| 5041 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5042 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5043 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5044 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5045 | WR_HARPOON(p_port + hp_portctrl_0, |
| 5046 | (SCSI_PORT | DMA_PORT | DMA_RD)); |
| 5047 | WR_HARPOON(p_port + hp_scsisig, S_DATAO_PH); |
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 | WR_HARPOON(p_port + hp_xfer_cmd, |
| 5050 | (XFER_HOST_DMA | XFER_HOST_AUTO | XFER_DMA_8BIT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5051 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5052 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5053 | } |
| 5054 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5055 | /*--------------------------------------------------------------------- |
| 5056 | * |
| 5057 | * Function: BusMaster Timeout Handler |
| 5058 | * |
| 5059 | * Description: This function is called after a bus master command busy time |
| 5060 | * out is detected. This routines issue halt state machine |
| 5061 | * with a software time out for command busy. If command busy |
| 5062 | * is still asserted at the end of the time out, it issues |
| 5063 | * hard abort with another software time out. It hard abort |
| 5064 | * command busy is also time out, it'll just give up. |
| 5065 | * |
| 5066 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5067 | static unsigned char FPT_busMstrTimeOut(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5068 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5069 | unsigned long timeout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5070 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5071 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5072 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5073 | WR_HARPOON(p_port + hp_sys_ctrl, HALT_MACH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5074 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5075 | while ((!(RD_HARPOON(p_port + hp_ext_status) & CMD_ABORTED)) |
| 5076 | && timeout--) { |
| 5077 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5078 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5079 | if (RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) { |
| 5080 | WR_HARPOON(p_port + hp_sys_ctrl, HARD_ABORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5081 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5082 | timeout = LONG_WAIT; |
| 5083 | while ((RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) |
| 5084 | && timeout--) { |
| 5085 | } |
| 5086 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5087 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5088 | RD_HARPOON(p_port + hp_int_status); /*Clear command complete */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5089 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5090 | if (RD_HARPOON(p_port + hp_ext_status) & BM_CMD_BUSY) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5091 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5092 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5093 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5094 | else { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5095 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5096 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5097 | } |
| 5098 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5099 | /*--------------------------------------------------------------------- |
| 5100 | * |
| 5101 | * Function: Host Data Transfer Abort |
| 5102 | * |
| 5103 | * Description: Abort any in progress transfer. |
| 5104 | * |
| 5105 | *---------------------------------------------------------------------*/ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5106 | static void FPT_hostDataXferAbort(u32 port, unsigned char p_card, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5107 | struct sccb *pCurrSCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5108 | { |
| 5109 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5110 | unsigned long timeout; |
| 5111 | unsigned long remain_cnt; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5112 | u32 sg_ptr; |
| 5113 | struct blogic_sg_seg *segp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5114 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5115 | FPT_BL_Card[p_card].globalFlags &= ~F_HOST_XFER_ACT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5116 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5117 | if (pCurrSCCB->Sccb_XferState & F_AUTO_SENSE) { |
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 | if (!(RD_HARPOON(port + hp_int_status) & INT_CMD_COMPL)) { |
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 | WR_HARPOON(port + hp_bm_ctrl, |
| 5122 | (RD_HARPOON(port + hp_bm_ctrl) | |
| 5123 | FLUSH_XFER_CNTR)); |
| 5124 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5125 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5126 | while ((RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) |
| 5127 | && timeout--) { |
| 5128 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5129 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5130 | WR_HARPOON(port + hp_bm_ctrl, |
| 5131 | (RD_HARPOON(port + hp_bm_ctrl) & |
| 5132 | ~FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5133 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5134 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5135 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5136 | if (FPT_busMstrTimeOut(port)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5137 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5138 | if (pCurrSCCB->HostStatus == 0x00) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5139 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5140 | pCurrSCCB->HostStatus = |
| 5141 | SCCB_BM_ERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5142 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5143 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5144 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5145 | if (RD_HARPOON(port + hp_int_status) & |
| 5146 | INT_EXT_STATUS) |
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 (RD_HARPOON(port + hp_ext_status) & |
| 5149 | BAD_EXT_STATUS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5150 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5151 | if (pCurrSCCB->HostStatus == |
| 5152 | 0x00) |
| 5153 | { |
| 5154 | pCurrSCCB->HostStatus = |
| 5155 | SCCB_BM_ERR; |
| 5156 | } |
| 5157 | } |
| 5158 | } |
| 5159 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5160 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5161 | else if (pCurrSCCB->Sccb_XferCnt) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5162 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5163 | if (pCurrSCCB->Sccb_XferState & F_SG_XFER) { |
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 | WR_HARPOON(port + hp_page_ctrl, |
| 5166 | (RD_HARPOON(port + hp_page_ctrl) & |
| 5167 | ~SCATTER_EN)); |
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 | WR_HARPOON(port + hp_sg_addr, 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 | sg_ptr = pCurrSCCB->Sccb_sgseg + SG_BUF_CNT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5172 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5173 | if (sg_ptr > |
| 5174 | (unsigned int)(pCurrSCCB->DataLength / |
| 5175 | SG_ELEMENT_SIZE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5176 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5177 | sg_ptr = (u32)(pCurrSCCB->DataLength / |
| 5178 | SG_ELEMENT_SIZE); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5179 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5180 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5181 | remain_cnt = pCurrSCCB->Sccb_XferCnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5182 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5183 | while (remain_cnt < 0x01000000L) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5184 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5185 | sg_ptr--; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5186 | segp = (struct blogic_sg_seg *)(pCurrSCCB-> |
| 5187 | DataPointer) + (sg_ptr * 2); |
| 5188 | if (remain_cnt > (unsigned long)segp->segbytes) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5189 | remain_cnt -= |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5190 | (unsigned long)segp->segbytes; |
| 5191 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5192 | break; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5193 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5194 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5195 | if (remain_cnt < 0x01000000L) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5196 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5197 | pCurrSCCB->Sccb_SGoffset = remain_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5198 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5199 | pCurrSCCB->Sccb_sgseg = (unsigned short)sg_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5200 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5201 | if ((unsigned long)(sg_ptr * SG_ELEMENT_SIZE) == |
| 5202 | pCurrSCCB->DataLength && (remain_cnt == 0)) |
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 | pCurrSCCB->Sccb_XferState |= |
| 5205 | F_ALL_XFERRED; |
| 5206 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5207 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5208 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5209 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5210 | if (pCurrSCCB->HostStatus == 0x00) { |
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 | pCurrSCCB->HostStatus = |
| 5213 | SCCB_GROSS_FW_ERR; |
| 5214 | } |
| 5215 | } |
| 5216 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5217 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5218 | if (!(pCurrSCCB->Sccb_XferState & F_HOST_XFER_DIR)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5219 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5220 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5221 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5222 | FPT_busMstrTimeOut(port); |
| 5223 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5224 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5225 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5226 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5227 | if (RD_HARPOON(port + hp_int_status) & |
| 5228 | INT_EXT_STATUS) { |
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 | if (RD_HARPOON(port + hp_ext_status) & |
| 5231 | BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5232 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5233 | if (pCurrSCCB->HostStatus == |
| 5234 | 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5235 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5236 | pCurrSCCB->HostStatus = |
| 5237 | SCCB_BM_ERR; |
| 5238 | } |
| 5239 | } |
| 5240 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5241 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5242 | } |
| 5243 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5244 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5245 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5246 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5247 | if ((RD_HARPOON(port + hp_fifo_cnt)) >= BM_THRESHOLD) { |
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 | timeout = SHORT_WAIT; |
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 | while ((RD_HARPOON(port + hp_ext_status) & |
| 5252 | BM_CMD_BUSY) |
| 5253 | && ((RD_HARPOON(port + hp_fifo_cnt)) >= |
| 5254 | BM_THRESHOLD) && timeout--) { |
| 5255 | } |
| 5256 | } |
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_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5259 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5260 | WR_HARPOON(port + hp_bm_ctrl, |
| 5261 | (RD_HARPOON(port + hp_bm_ctrl) | |
| 5262 | FLUSH_XFER_CNTR)); |
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 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5266 | while ((RD_HARPOON(port + hp_ext_status) & |
| 5267 | BM_CMD_BUSY) && timeout--) { |
| 5268 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5269 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5270 | WR_HARPOON(port + hp_bm_ctrl, |
| 5271 | (RD_HARPOON(port + hp_bm_ctrl) & |
| 5272 | ~FLUSH_XFER_CNTR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5273 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5274 | if (RD_HARPOON(port + hp_ext_status) & |
| 5275 | BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5276 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5277 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5278 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5279 | pCurrSCCB->HostStatus = |
| 5280 | SCCB_BM_ERR; |
| 5281 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5282 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5283 | FPT_busMstrTimeOut(port); |
| 5284 | } |
| 5285 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5286 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5287 | if (RD_HARPOON(port + hp_int_status) & INT_EXT_STATUS) { |
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) & |
| 5290 | BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5291 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5292 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5293 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5294 | pCurrSCCB->HostStatus = |
| 5295 | SCCB_BM_ERR; |
| 5296 | } |
| 5297 | } |
| 5298 | } |
| 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 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5302 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5303 | else { |
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) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5306 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5307 | timeout = LONG_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5308 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5309 | while ((RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) |
| 5310 | && timeout--) { |
| 5311 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5312 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5313 | if (RD_HARPOON(port + hp_ext_status) & BM_CMD_BUSY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5314 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5315 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5316 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5317 | pCurrSCCB->HostStatus = SCCB_BM_ERR; |
| 5318 | } |
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 | FPT_busMstrTimeOut(port); |
| 5321 | } |
| 5322 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5323 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5324 | if (RD_HARPOON(port + hp_int_status) & INT_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5325 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5326 | if (RD_HARPOON(port + hp_ext_status) & BAD_EXT_STATUS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5327 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5328 | if (pCurrSCCB->HostStatus == 0x00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5329 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5330 | pCurrSCCB->HostStatus = SCCB_BM_ERR; |
| 5331 | } |
| 5332 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5333 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5334 | } |
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 (pCurrSCCB->Sccb_XferState & F_SG_XFER) { |
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 | WR_HARPOON(port + hp_page_ctrl, |
| 5339 | (RD_HARPOON(port + hp_page_ctrl) & |
| 5340 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5341 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5342 | WR_HARPOON(port + hp_sg_addr, 0x00); |
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 | pCurrSCCB->Sccb_sgseg += SG_BUF_CNT; |
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 | pCurrSCCB->Sccb_SGoffset = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5347 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5348 | if ((u32)(pCurrSCCB->Sccb_sgseg * SG_ELEMENT_SIZE) >= |
| 5349 | pCurrSCCB->DataLength) { |
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 | pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5352 | pCurrSCCB->Sccb_sgseg = |
| 5353 | (unsigned short)(pCurrSCCB->DataLength / |
| 5354 | SG_ELEMENT_SIZE); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5355 | } |
| 5356 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5357 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5358 | else { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5359 | if (!(pCurrSCCB->Sccb_XferState & F_AUTO_SENSE)) |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5360 | pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED; |
| 5361 | } |
| 5362 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5363 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5364 | WR_HARPOON(port + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5365 | } |
| 5366 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5367 | /*--------------------------------------------------------------------- |
| 5368 | * |
| 5369 | * Function: Host Data Transfer Restart |
| 5370 | * |
| 5371 | * Description: Reset the available count due to a restore data |
| 5372 | * pointers message. |
| 5373 | * |
| 5374 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5375 | static void FPT_hostDataXferRestart(struct sccb *currSCCB) |
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 | unsigned long data_count; |
| 5378 | unsigned int sg_index; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5379 | struct blogic_sg_seg *segp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5381 | if (currSCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5382 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5383 | currSCCB->Sccb_XferCnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5384 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5385 | sg_index = 0xffff; /*Index by long words into sg list. */ |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5386 | data_count = 0; /*Running count of SG xfer counts. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | while (data_count < currSCCB->Sccb_ATC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5390 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5391 | sg_index++; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5392 | segp = (struct blogic_sg_seg *)(currSCCB->DataPointer) + |
| 5393 | (sg_index * 2); |
| 5394 | data_count += segp->segbytes; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5395 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5396 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5397 | if (data_count == currSCCB->Sccb_ATC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5398 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5399 | currSCCB->Sccb_SGoffset = 0; |
| 5400 | sg_index++; |
| 5401 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5402 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5403 | else { |
| 5404 | currSCCB->Sccb_SGoffset = |
| 5405 | data_count - currSCCB->Sccb_ATC; |
| 5406 | } |
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 | currSCCB->Sccb_sgseg = (unsigned short)sg_index; |
| 5409 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5410 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5411 | else { |
| 5412 | currSCCB->Sccb_XferCnt = |
| 5413 | currSCCB->DataLength - currSCCB->Sccb_ATC; |
| 5414 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5415 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5416 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5417 | /*--------------------------------------------------------------------- |
| 5418 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5419 | * Function: FPT_scini |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5420 | * |
| 5421 | * Description: Setup all data structures necessary for SCAM selection. |
| 5422 | * |
| 5423 | *---------------------------------------------------------------------*/ |
| 5424 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5425 | static void FPT_scini(unsigned char p_card, unsigned char p_our_id, |
| 5426 | unsigned char p_power_up) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5427 | { |
| 5428 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5429 | unsigned char loser, assigned_id; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5430 | u32 p_port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5431 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5432 | unsigned char i, k, ScamFlg; |
| 5433 | struct sccb_card *currCard; |
| 5434 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5435 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5436 | currCard = &FPT_BL_Card[p_card]; |
| 5437 | p_port = currCard->ioPort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5438 | pCurrNvRam = currCard->pNvRamInfo; |
| 5439 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5440 | if (pCurrNvRam) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5441 | ScamFlg = pCurrNvRam->niScamConf; |
| 5442 | i = pCurrNvRam->niSysConf; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5443 | } else { |
| 5444 | ScamFlg = |
| 5445 | (unsigned char)FPT_utilEERead(p_port, SCAM_CONFIG / 2); |
| 5446 | i = (unsigned |
| 5447 | char)(FPT_utilEERead(p_port, (SYSTEM_CONFIG / 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5448 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5449 | if (!(i & 0x02)) /* check if reset bus in AutoSCSI parameter set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5450 | return; |
| 5451 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5452 | FPT_inisci(p_card, p_port, p_our_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5453 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5454 | /* Force to wait 1 sec after SCSI bus reset. Some SCAM device FW |
| 5455 | too slow to return to SCAM selection */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5456 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5457 | /* if (p_power_up) |
| 5458 | FPT_Wait1Second(p_port); |
| 5459 | else |
| 5460 | FPT_Wait(p_port, TO_250ms); */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5461 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5462 | FPT_Wait1Second(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5463 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5464 | if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2)) { |
| 5465 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5466 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5467 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5468 | FPT_scsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5469 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5470 | do { |
| 5471 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5472 | FPT_scxferc(p_port, DOM_MSTR); |
| 5473 | loser = |
| 5474 | FPT_scsendi(p_port, |
| 5475 | &FPT_scamInfo[p_our_id].id_string[0]); |
| 5476 | } while (loser == 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5477 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5478 | FPT_scbusf(p_port); |
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 ((p_power_up) && (!loser)) { |
| 5481 | FPT_sresb(p_port, p_card); |
| 5482 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5483 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5484 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5485 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5486 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5487 | FPT_scsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5488 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5489 | do { |
| 5490 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5491 | FPT_scxferc(p_port, DOM_MSTR); |
| 5492 | loser = |
| 5493 | FPT_scsendi(p_port, |
| 5494 | &FPT_scamInfo[p_our_id]. |
| 5495 | id_string[0]); |
| 5496 | } while (loser == 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5497 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5498 | FPT_scbusf(p_port); |
| 5499 | } |
| 5500 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5501 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5502 | else { |
| 5503 | loser = 0; |
| 5504 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5506 | if (!loser) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5507 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5508 | FPT_scamInfo[p_our_id].state = ID_ASSIGNED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5509 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5510 | if (ScamFlg & SCAM_ENABLED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5511 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5512 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
| 5513 | if ((FPT_scamInfo[i].state == ID_UNASSIGNED) || |
| 5514 | (FPT_scamInfo[i].state == ID_UNUSED)) { |
| 5515 | if (FPT_scsell(p_port, i)) { |
| 5516 | FPT_scamInfo[i].state = LEGACY; |
| 5517 | if ((FPT_scamInfo[i]. |
| 5518 | id_string[0] != 0xFF) |
| 5519 | || (FPT_scamInfo[i]. |
| 5520 | id_string[1] != 0xFA)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5521 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5522 | FPT_scamInfo[i]. |
| 5523 | id_string[0] = 0xFF; |
| 5524 | FPT_scamInfo[i]. |
| 5525 | id_string[1] = 0xFA; |
| 5526 | if (pCurrNvRam == NULL) |
| 5527 | currCard-> |
| 5528 | globalFlags |
| 5529 | |= |
| 5530 | F_UPDATE_EEPROM; |
| 5531 | } |
| 5532 | } |
| 5533 | } |
| 5534 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5535 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5536 | FPT_sresb(p_port, p_card); |
| 5537 | FPT_Wait1Second(p_port); |
| 5538 | while (!(FPT_scarb(p_port, INIT_SELTD))) { |
| 5539 | } |
| 5540 | FPT_scsel(p_port); |
| 5541 | FPT_scasid(p_card, p_port); |
| 5542 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5543 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5544 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5545 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5546 | else if ((loser) && (ScamFlg & SCAM_ENABLED)) { |
| 5547 | FPT_scamInfo[p_our_id].id_string[0] = SLV_TYPE_CODE0; |
| 5548 | assigned_id = 0; |
| 5549 | FPT_scwtsel(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5550 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5551 | do { |
| 5552 | while (FPT_scxferc(p_port, 0x00) != SYNC_PTRN) { |
| 5553 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5554 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5555 | i = FPT_scxferc(p_port, 0x00); |
| 5556 | if (i == ASSIGN_ID) { |
| 5557 | if (! |
| 5558 | (FPT_scsendi |
| 5559 | (p_port, |
| 5560 | &FPT_scamInfo[p_our_id].id_string[0]))) { |
| 5561 | i = FPT_scxferc(p_port, 0x00); |
| 5562 | if (FPT_scvalq(i)) { |
| 5563 | k = FPT_scxferc(p_port, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5564 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5565 | if (FPT_scvalq(k)) { |
| 5566 | currCard->ourId = |
| 5567 | ((unsigned char)(i |
| 5568 | << |
| 5569 | 3) |
| 5570 | + |
| 5571 | (k & |
| 5572 | (unsigned char)7)) |
| 5573 | & (unsigned char) |
| 5574 | 0x3F; |
| 5575 | FPT_inisci(p_card, |
| 5576 | p_port, |
| 5577 | p_our_id); |
| 5578 | FPT_scamInfo[currCard-> |
| 5579 | ourId]. |
| 5580 | state = ID_ASSIGNED; |
| 5581 | FPT_scamInfo[currCard-> |
| 5582 | ourId]. |
| 5583 | id_string[0] |
| 5584 | = SLV_TYPE_CODE0; |
| 5585 | assigned_id = 1; |
| 5586 | } |
| 5587 | } |
| 5588 | } |
| 5589 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5590 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5591 | else if (i == SET_P_FLAG) { |
| 5592 | if (!(FPT_scsendi(p_port, |
| 5593 | &FPT_scamInfo[p_our_id]. |
| 5594 | id_string[0]))) |
| 5595 | FPT_scamInfo[p_our_id].id_string[0] |= |
| 5596 | 0x80; |
| 5597 | } |
| 5598 | } while (!assigned_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5599 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5600 | while (FPT_scxferc(p_port, 0x00) != CFG_CMPLT) { |
| 5601 | } |
| 5602 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5603 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5604 | if (ScamFlg & SCAM_ENABLED) { |
| 5605 | FPT_scbusf(p_port); |
| 5606 | if (currCard->globalFlags & F_UPDATE_EEPROM) { |
| 5607 | FPT_scsavdi(p_card, p_port); |
| 5608 | currCard->globalFlags &= ~F_UPDATE_EEPROM; |
| 5609 | } |
| 5610 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5611 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5612 | /* |
| 5613 | for (i=0,k=0; i < MAX_SCSI_TAR; i++) |
| 5614 | { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5615 | if ((FPT_scamInfo[i].state == ID_ASSIGNED) || |
| 5616 | (FPT_scamInfo[i].state == LEGACY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5617 | k++; |
| 5618 | } |
| 5619 | |
| 5620 | if (k==2) |
| 5621 | currCard->globalFlags |= F_SINGLE_DEVICE; |
| 5622 | else |
| 5623 | currCard->globalFlags &= ~F_SINGLE_DEVICE; |
| 5624 | */ |
| 5625 | } |
| 5626 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5627 | /*--------------------------------------------------------------------- |
| 5628 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5629 | * Function: FPT_scarb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5630 | * |
| 5631 | * Description: Gain control of the bus and wait SCAM select time (250ms) |
| 5632 | * |
| 5633 | *---------------------------------------------------------------------*/ |
| 5634 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5635 | static int FPT_scarb(u32 p_port, unsigned char p_sel_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5636 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5637 | if (p_sel_type == INIT_SELTD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5638 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5639 | while (RD_HARPOON(p_port + hp_scsisig) & (SCSI_SEL | SCSI_BSY)) { |
| 5640 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5641 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5642 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_SEL) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5643 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5644 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5645 | if (RD_HARPOON(p_port + hp_scsidata_0) != 00) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5646 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5647 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5648 | WR_HARPOON(p_port + hp_scsisig, |
| 5649 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5650 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5651 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_SEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5652 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5653 | WR_HARPOON(p_port + hp_scsisig, |
| 5654 | (RD_HARPOON(p_port + hp_scsisig) & |
| 5655 | ~SCSI_BSY)); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5656 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5657 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5658 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5659 | WR_HARPOON(p_port + hp_scsisig, |
| 5660 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5661 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5662 | if (RD_HARPOON(p_port + hp_scsidata_0) != 00) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5663 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5664 | WR_HARPOON(p_port + hp_scsisig, |
| 5665 | (RD_HARPOON(p_port + hp_scsisig) & |
| 5666 | ~(SCSI_BSY | SCSI_SEL))); |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5667 | return 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5668 | } |
| 5669 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5670 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5671 | WR_HARPOON(p_port + hp_clkctrl_0, (RD_HARPOON(p_port + hp_clkctrl_0) |
| 5672 | & ~ACTdeassert)); |
| 5673 | WR_HARPOON(p_port + hp_scsireset, SCAM_EN); |
| 5674 | WR_HARPOON(p_port + hp_scsidata_0, 0x00); |
| 5675 | WR_HARPOON(p_port + hp_scsidata_1, 0x00); |
| 5676 | WR_HARPOON(p_port + hp_portctrl_0, SCSI_BUS_EN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5677 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5678 | WR_HARPOON(p_port + hp_scsisig, |
| 5679 | (RD_HARPOON(p_port + hp_scsisig) | SCSI_MSG)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5680 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5681 | WR_HARPOON(p_port + hp_scsisig, (RD_HARPOON(p_port + hp_scsisig) |
| 5682 | & ~SCSI_BSY)); |
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 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5685 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5686 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5687 | } |
| 5688 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5689 | /*--------------------------------------------------------------------- |
| 5690 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5691 | * Function: FPT_scbusf |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5692 | * |
| 5693 | * Description: Release the SCSI bus and disable SCAM selection. |
| 5694 | * |
| 5695 | *---------------------------------------------------------------------*/ |
| 5696 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5697 | static void FPT_scbusf(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5698 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5699 | WR_HARPOON(p_port + hp_page_ctrl, |
| 5700 | (RD_HARPOON(p_port + hp_page_ctrl) | G_INT_DISABLE)); |
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_scsidata_0, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5703 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5704 | WR_HARPOON(p_port + hp_portctrl_0, (RD_HARPOON(p_port + hp_portctrl_0) |
| 5705 | & ~SCSI_BUS_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5706 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5707 | WR_HARPOON(p_port + hp_scsisig, 0x00); |
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_scsireset, (RD_HARPOON(p_port + hp_scsireset) |
| 5710 | & ~SCAM_EN)); |
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_clkctrl_0, (RD_HARPOON(p_port + hp_clkctrl_0) |
| 5713 | | ACTdeassert)); |
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 | WRW_HARPOON((p_port + hp_intstat), (BUS_FREE | AUTO_INT | SCAM_SEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5716 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5717 | WR_HARPOON(p_port + hp_page_ctrl, |
| 5718 | (RD_HARPOON(p_port + hp_page_ctrl) & ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5719 | } |
| 5720 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5721 | /*--------------------------------------------------------------------- |
| 5722 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5723 | * Function: FPT_scasid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5724 | * |
| 5725 | * Description: Assign an ID to all the SCAM devices. |
| 5726 | * |
| 5727 | *---------------------------------------------------------------------*/ |
| 5728 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5729 | static void FPT_scasid(unsigned char p_card, u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5730 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5731 | unsigned char temp_id_string[ID_STRING_LENGTH]; |
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 | unsigned char i, k, scam_id; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 5734 | unsigned char crcBytes[3]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5735 | struct nvram_info *pCurrNvRam; |
| 5736 | unsigned short *pCrcBytes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5737 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5738 | pCurrNvRam = FPT_BL_Card[p_card].pNvRamInfo; |
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 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5741 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5742 | while (!i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5743 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5744 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 5745 | temp_id_string[k] = (unsigned char)0x00; |
| 5746 | } |
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 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5749 | FPT_scxferc(p_port, ASSIGN_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5750 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5751 | if (!(FPT_sciso(p_port, &temp_id_string[0]))) { |
| 5752 | if (pCurrNvRam) { |
Alexey Dobriyan | fd1e29e | 2006-03-08 00:14:27 -0800 | [diff] [blame] | 5753 | pCrcBytes = (unsigned short *)&crcBytes[0]; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5754 | *pCrcBytes = FPT_CalcCrc16(&temp_id_string[0]); |
| 5755 | crcBytes[2] = FPT_CalcLrc(&temp_id_string[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5756 | temp_id_string[1] = crcBytes[2]; |
| 5757 | temp_id_string[2] = crcBytes[0]; |
| 5758 | temp_id_string[3] = crcBytes[1]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5759 | for (k = 4; k < ID_STRING_LENGTH; k++) |
| 5760 | temp_id_string[k] = (unsigned char)0x00; |
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 | i = FPT_scmachid(p_card, temp_id_string); |
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 | if (i == CLR_PRIORITY) { |
| 5765 | FPT_scxferc(p_port, MISC_CODE); |
| 5766 | FPT_scxferc(p_port, CLR_P_FLAG); |
| 5767 | i = 0; /*Not the last ID yet. */ |
| 5768 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5769 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5770 | else if (i != NO_ID_AVAIL) { |
| 5771 | if (i < 8) |
| 5772 | FPT_scxferc(p_port, ID_0_7); |
| 5773 | else |
| 5774 | FPT_scxferc(p_port, ID_8_F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5775 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5776 | scam_id = (i & (unsigned char)0x07); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5777 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5778 | for (k = 1; k < 0x08; k <<= 1) |
| 5779 | if (!(k & i)) |
| 5780 | scam_id += 0x08; /*Count number of zeros in DB0-3. */ |
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 | FPT_scxferc(p_port, scam_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5783 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5784 | i = 0; /*Not the last ID yet. */ |
| 5785 | } |
| 5786 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5787 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5788 | else { |
| 5789 | i = 1; |
| 5790 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5791 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5792 | } /*End while */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5793 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5794 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5795 | FPT_scxferc(p_port, CFG_CMPLT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5796 | } |
| 5797 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5798 | /*--------------------------------------------------------------------- |
| 5799 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5800 | * Function: FPT_scsel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5801 | * |
| 5802 | * Description: Select all the SCAM devices. |
| 5803 | * |
| 5804 | *---------------------------------------------------------------------*/ |
| 5805 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5806 | static void FPT_scsel(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5807 | { |
| 5808 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5809 | WR_HARPOON(p_port + hp_scsisig, SCSI_SEL); |
| 5810 | FPT_scwiros(p_port, SCSI_MSG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5811 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5812 | WR_HARPOON(p_port + hp_scsisig, (SCSI_SEL | SCSI_BSY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5813 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5814 | WR_HARPOON(p_port + hp_scsisig, |
| 5815 | (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
| 5816 | WR_HARPOON(p_port + hp_scsidata_0, |
| 5817 | (unsigned char)(RD_HARPOON(p_port + hp_scsidata_0) | |
| 5818 | (unsigned char)(BIT(7) + BIT(6)))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5819 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5820 | WR_HARPOON(p_port + hp_scsisig, (SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
| 5821 | FPT_scwiros(p_port, SCSI_SEL); |
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 | WR_HARPOON(p_port + hp_scsidata_0, |
| 5824 | (unsigned char)(RD_HARPOON(p_port + hp_scsidata_0) & |
| 5825 | ~(unsigned char)BIT(6))); |
| 5826 | FPT_scwirod(p_port, BIT(6)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5827 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5828 | WR_HARPOON(p_port + hp_scsisig, |
| 5829 | (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5830 | } |
| 5831 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5832 | /*--------------------------------------------------------------------- |
| 5833 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5834 | * Function: FPT_scxferc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5835 | * |
| 5836 | * Description: Handshake the p_data (DB4-0) across the bus. |
| 5837 | * |
| 5838 | *---------------------------------------------------------------------*/ |
| 5839 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5840 | static unsigned char FPT_scxferc(u32 p_port, unsigned char p_data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5841 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5842 | unsigned char curr_data, ret_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5843 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5844 | 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] | 5845 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5846 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5847 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5848 | curr_data &= ~BIT(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5849 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5850 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5851 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5852 | FPT_scwirod(p_port, BIT(7)); /*Wait for DB7 to be released. */ |
| 5853 | while (!(RD_HARPOON(p_port + hp_scsidata_0) & BIT(5))) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5854 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5855 | ret_data = (RD_HARPOON(p_port + hp_scsidata_0) & (unsigned char)0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5856 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5857 | curr_data |= 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_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5860 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5861 | curr_data &= ~BIT(5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5862 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5863 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5864 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5865 | FPT_scwirod(p_port, BIT(5)); /*Wait for DB5 to be released. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5866 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5867 | curr_data &= ~(BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0)); /*Release data bits */ |
| 5868 | curr_data |= BIT(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5869 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5870 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5871 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5872 | curr_data &= ~BIT(6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5873 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5874 | WR_HARPOON(p_port + hp_scsidata_0, curr_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5875 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5876 | FPT_scwirod(p_port, BIT(6)); /*Wait for DB6 to be released. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5877 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5878 | return ret_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5879 | } |
| 5880 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5881 | /*--------------------------------------------------------------------- |
| 5882 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5883 | * Function: FPT_scsendi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5884 | * |
| 5885 | * Description: Transfer our Identification string to determine if we |
| 5886 | * will be the dominant master. |
| 5887 | * |
| 5888 | *---------------------------------------------------------------------*/ |
| 5889 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5890 | 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] | 5891 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5892 | unsigned char ret_data, byte_cnt, bit_cnt, defer; |
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 | defer = 0; |
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 | for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) { |
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 | for (bit_cnt = 0x80; bit_cnt != 0; bit_cnt >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5899 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5900 | if (defer) |
| 5901 | ret_data = FPT_scxferc(p_port, 00); |
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 | else if (p_id_string[byte_cnt] & bit_cnt) |
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 | ret_data = FPT_scxferc(p_port, 02); |
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 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5908 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5909 | ret_data = FPT_scxferc(p_port, 01); |
| 5910 | if (ret_data & 02) |
| 5911 | defer = 1; |
| 5912 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5913 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5914 | if ((ret_data & 0x1C) == 0x10) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5915 | return 0x00; /*End of isolation stage, we won! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5916 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5917 | if (ret_data & 0x1C) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5918 | return 0xFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5919 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5920 | if ((defer) && (!(ret_data & 0x1F))) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5921 | return 0x01; /*End of isolation stage, we lost. */ |
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 | } /*bit loop */ |
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 | } /*byte loop */ |
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 | if (defer) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5928 | return 0x01; /*We lost */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5929 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5930 | return 0; /*We WON! Yeeessss! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5931 | } |
| 5932 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5933 | /*--------------------------------------------------------------------- |
| 5934 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5935 | * Function: FPT_sciso |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5936 | * |
| 5937 | * Description: Transfer the Identification string. |
| 5938 | * |
| 5939 | *---------------------------------------------------------------------*/ |
| 5940 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5941 | 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] | 5942 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5943 | unsigned char ret_data, the_data, byte_cnt, bit_cnt; |
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 | the_data = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5946 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5947 | for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5948 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5949 | for (bit_cnt = 0; bit_cnt < 8; bit_cnt++) { |
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 | ret_data = FPT_scxferc(p_port, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5952 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5953 | if (ret_data & 0xFC) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5954 | return 0xFF; |
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 | else { |
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 | the_data <<= 1; |
| 5959 | if (ret_data & BIT(1)) { |
| 5960 | the_data |= 1; |
| 5961 | } |
| 5962 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5963 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5964 | if ((ret_data & 0x1F) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5965 | /* |
| 5966 | if(bit_cnt != 0 || bit_cnt != 8) |
| 5967 | { |
| 5968 | byte_cnt = 0; |
| 5969 | bit_cnt = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5970 | FPT_scxferc(p_port, SYNC_PTRN); |
| 5971 | FPT_scxferc(p_port, ASSIGN_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5972 | continue; |
| 5973 | } |
| 5974 | */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5975 | if (byte_cnt) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5976 | return 0x00; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5977 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5978 | return 0xFF; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5979 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5980 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5981 | } /*bit loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5982 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5983 | p_id_string[byte_cnt] = the_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5984 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 5985 | } /*byte loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5986 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 5987 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5988 | } |
| 5989 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5990 | /*--------------------------------------------------------------------- |
| 5991 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 5992 | * Function: FPT_scwirod |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5993 | * |
| 5994 | * Description: Sample the SCSI data bus making sure the signal has been |
| 5995 | * deasserted for the correct number of consecutive samples. |
| 5996 | * |
| 5997 | *---------------------------------------------------------------------*/ |
| 5998 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 5999 | static void FPT_scwirod(u32 p_port, unsigned char p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6000 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6001 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6002 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6003 | i = 0; |
| 6004 | while (i < MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6005 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6006 | if (RD_HARPOON(p_port + hp_scsidata_0) & p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6007 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6008 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6009 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6010 | else |
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 | i++; |
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 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6015 | } |
| 6016 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6017 | /*--------------------------------------------------------------------- |
| 6018 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6019 | * Function: FPT_scwiros |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6020 | * |
| 6021 | * Description: Sample the SCSI Signal lines making sure the signal has been |
| 6022 | * deasserted for the correct number of consecutive samples. |
| 6023 | * |
| 6024 | *---------------------------------------------------------------------*/ |
| 6025 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6026 | static void FPT_scwiros(u32 p_port, unsigned char p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6027 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6028 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6029 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6030 | i = 0; |
| 6031 | while (i < MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6032 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6033 | if (RD_HARPOON(p_port + hp_scsisig) & p_data_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6034 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6035 | i = 0; |
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 | else |
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++; |
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 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6042 | } |
| 6043 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6044 | /*--------------------------------------------------------------------- |
| 6045 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6046 | * Function: FPT_scvalq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6047 | * |
| 6048 | * Description: Make sure we received a valid data byte. |
| 6049 | * |
| 6050 | *---------------------------------------------------------------------*/ |
| 6051 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 6052 | static unsigned char FPT_scvalq(unsigned char p_quintet) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6053 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6054 | unsigned char count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6055 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6056 | for (count = 1; count < 0x08; count <<= 1) { |
| 6057 | if (!(p_quintet & count)) |
| 6058 | p_quintet -= 0x80; |
| 6059 | } |
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 | if (p_quintet & 0x18) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6062 | return 0; |
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 | else |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6065 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6066 | } |
| 6067 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6068 | /*--------------------------------------------------------------------- |
| 6069 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6070 | * Function: FPT_scsell |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6071 | * |
| 6072 | * Description: Select the specified device ID using a selection timeout |
| 6073 | * less than 4ms. If somebody responds then it is a legacy |
| 6074 | * drive and this ID must be marked as such. |
| 6075 | * |
| 6076 | *---------------------------------------------------------------------*/ |
| 6077 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6078 | static unsigned char FPT_scsell(u32 p_port, unsigned char targ_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6079 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6080 | unsigned long i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6081 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6082 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6083 | (RD_HARPOON(p_port + hp_page_ctrl) | G_INT_DISABLE)); |
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 | ARAM_ACCESS(p_port); |
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 | WR_HARPOON(p_port + hp_addstat, |
| 6088 | (RD_HARPOON(p_port + hp_addstat) | SCAM_TIMER)); |
| 6089 | WR_HARPOON(p_port + hp_seltimeout, TO_4ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6090 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6091 | for (i = p_port + CMD_STRT; i < p_port + CMD_STRT + 12; i += 2) { |
| 6092 | WRW_HARPOON(i, (MPM_OP + ACOMMAND)); |
| 6093 | } |
| 6094 | WRW_HARPOON(i, (BRH_OP + ALWAYS + NP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6095 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6096 | WRW_HARPOON((p_port + hp_intstat), |
| 6097 | (RESET | TIMEOUT | SEL | BUS_FREE | AUTO_INT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6098 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6099 | WR_HARPOON(p_port + hp_select_id, targ_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6100 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6101 | WR_HARPOON(p_port + hp_portctrl_0, SCSI_PORT); |
| 6102 | WR_HARPOON(p_port + hp_autostart_3, (SELECT | CMD_ONLY_STRT)); |
| 6103 | WR_HARPOON(p_port + hp_scsictrl_0, (SEL_TAR | ENA_RESEL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6104 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6105 | while (!(RDW_HARPOON((p_port + hp_intstat)) & |
| 6106 | (RESET | PROG_HLT | TIMEOUT | AUTO_INT))) { |
| 6107 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6108 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6109 | if (RDW_HARPOON((p_port + hp_intstat)) & RESET) |
| 6110 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6111 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6112 | DISABLE_AUTO(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6113 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6114 | WR_HARPOON(p_port + hp_addstat, |
| 6115 | (RD_HARPOON(p_port + hp_addstat) & ~SCAM_TIMER)); |
| 6116 | WR_HARPOON(p_port + hp_seltimeout, TO_290ms); |
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 | SGRAM_ACCESS(p_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6119 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6120 | if (RDW_HARPOON((p_port + hp_intstat)) & (RESET | TIMEOUT)) { |
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 | WRW_HARPOON((p_port + hp_intstat), |
| 6123 | (RESET | TIMEOUT | SEL | BUS_FREE | PHASE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6124 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6125 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6126 | (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6127 | ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6128 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6129 | return 0; /*No legacy device */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6130 | } |
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 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6133 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6134 | while (!(RDW_HARPOON((p_port + hp_intstat)) & BUS_FREE)) { |
| 6135 | if (RD_HARPOON(p_port + hp_scsisig) & SCSI_REQ) { |
| 6136 | WR_HARPOON(p_port + hp_scsisig, |
| 6137 | (SCSI_ACK + S_ILL_PH)); |
| 6138 | ACCEPT_MSG(p_port); |
| 6139 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6140 | } |
| 6141 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6142 | WRW_HARPOON((p_port + hp_intstat), CLR_ALL_INT_1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6143 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6144 | WR_HARPOON(p_port + hp_page_ctrl, |
| 6145 | (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6146 | ~G_INT_DISABLE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6147 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6148 | return 1; /*Found one of them oldies! */ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6149 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6150 | } |
| 6151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6152 | /*--------------------------------------------------------------------- |
| 6153 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6154 | * Function: FPT_scwtsel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6155 | * |
| 6156 | * Description: Wait to be selected by another SCAM initiator. |
| 6157 | * |
| 6158 | *---------------------------------------------------------------------*/ |
| 6159 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6160 | static void FPT_scwtsel(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6161 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6162 | while (!(RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) { |
| 6163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6164 | } |
| 6165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6166 | /*--------------------------------------------------------------------- |
| 6167 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6168 | * Function: FPT_inisci |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6169 | * |
| 6170 | * Description: Setup the data Structure with the info from the EEPROM. |
| 6171 | * |
| 6172 | *---------------------------------------------------------------------*/ |
| 6173 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6174 | 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] | 6175 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6176 | unsigned char i, k, max_id; |
| 6177 | unsigned short ee_data; |
| 6178 | struct nvram_info *pCurrNvRam; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6179 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6180 | pCurrNvRam = FPT_BL_Card[p_card].pNvRamInfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6181 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6182 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6183 | max_id = 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6184 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6185 | else |
| 6186 | max_id = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6187 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6188 | if (pCurrNvRam) { |
| 6189 | for (i = 0; i < max_id; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6190 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6191 | for (k = 0; k < 4; k++) |
| 6192 | FPT_scamInfo[i].id_string[k] = |
| 6193 | pCurrNvRam->niScamTbl[i][k]; |
| 6194 | for (k = 4; k < ID_STRING_LENGTH; k++) |
| 6195 | FPT_scamInfo[i].id_string[k] = |
| 6196 | (unsigned char)0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6197 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6198 | if (FPT_scamInfo[i].id_string[0] == 0x00) |
| 6199 | FPT_scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */ |
| 6200 | else |
| 6201 | FPT_scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6202 | |
| 6203 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6204 | } else { |
| 6205 | for (i = 0; i < max_id; i++) { |
| 6206 | for (k = 0; k < ID_STRING_LENGTH; k += 2) { |
| 6207 | ee_data = |
| 6208 | FPT_utilEERead(p_port, |
| 6209 | (unsigned |
| 6210 | short)((EE_SCAMBASE / 2) + |
| 6211 | (unsigned short)(i * |
| 6212 | ((unsigned short)ID_STRING_LENGTH / 2)) + (unsigned short)(k / 2))); |
| 6213 | FPT_scamInfo[i].id_string[k] = |
| 6214 | (unsigned char)ee_data; |
| 6215 | ee_data >>= 8; |
| 6216 | FPT_scamInfo[i].id_string[k + 1] = |
| 6217 | (unsigned char)ee_data; |
| 6218 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6219 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6220 | if ((FPT_scamInfo[i].id_string[0] == 0x00) || |
| 6221 | (FPT_scamInfo[i].id_string[0] == 0xFF)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6222 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6223 | FPT_scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6224 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6225 | else |
| 6226 | FPT_scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6227 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6228 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6229 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6230 | for (k = 0; k < ID_STRING_LENGTH; k++) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6231 | FPT_scamInfo[p_our_id].id_string[k] = FPT_scamHAString[k]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6232 | |
| 6233 | } |
| 6234 | |
| 6235 | /*--------------------------------------------------------------------- |
| 6236 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6237 | * Function: FPT_scmachid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6238 | * |
| 6239 | * Description: Match the Device ID string with our values stored in |
| 6240 | * the EEPROM. |
| 6241 | * |
| 6242 | *---------------------------------------------------------------------*/ |
| 6243 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6244 | static unsigned char FPT_scmachid(unsigned char p_card, |
| 6245 | unsigned char p_id_string[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6246 | { |
| 6247 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6248 | unsigned char i, k, match; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6249 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6250 | for (i = 0; i < MAX_SCSI_TAR; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6251 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6252 | match = 1; |
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 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6255 | if (p_id_string[k] != FPT_scamInfo[i].id_string[k]) |
| 6256 | match = 0; |
| 6257 | } |
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 | if (match) { |
| 6260 | FPT_scamInfo[i].state = ID_ASSIGNED; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6261 | return i; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6262 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6264 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6265 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6266 | if (p_id_string[0] & BIT(5)) |
| 6267 | i = 8; |
| 6268 | else |
| 6269 | i = MAX_SCSI_TAR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6270 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6271 | if (((p_id_string[0] & 0x06) == 0x02) |
| 6272 | || ((p_id_string[0] & 0x06) == 0x04)) |
| 6273 | match = p_id_string[1] & (unsigned char)0x1F; |
| 6274 | else |
| 6275 | match = 7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6276 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6277 | while (i > 0) { |
| 6278 | i--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6279 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6280 | if (FPT_scamInfo[match].state == ID_UNUSED) { |
| 6281 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6282 | FPT_scamInfo[match].id_string[k] = |
| 6283 | p_id_string[k]; |
| 6284 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6285 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6286 | FPT_scamInfo[match].state = ID_ASSIGNED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6287 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6288 | if (FPT_BL_Card[p_card].pNvRamInfo == NULL) |
| 6289 | FPT_BL_Card[p_card].globalFlags |= |
| 6290 | F_UPDATE_EEPROM; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6291 | return match; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6292 | |
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 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6295 | match--; |
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 (match == 0xFF) { |
| 6298 | if (p_id_string[0] & BIT(5)) |
| 6299 | match = 7; |
| 6300 | else |
| 6301 | match = MAX_SCSI_TAR - 1; |
| 6302 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6303 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6304 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6305 | if (p_id_string[0] & BIT(7)) { |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6306 | return CLR_PRIORITY; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6307 | } |
| 6308 | |
| 6309 | if (p_id_string[0] & BIT(5)) |
| 6310 | i = 8; |
| 6311 | else |
| 6312 | i = MAX_SCSI_TAR; |
| 6313 | |
| 6314 | if (((p_id_string[0] & 0x06) == 0x02) |
| 6315 | || ((p_id_string[0] & 0x06) == 0x04)) |
| 6316 | match = p_id_string[1] & (unsigned char)0x1F; |
| 6317 | else |
| 6318 | match = 7; |
| 6319 | |
| 6320 | while (i > 0) { |
| 6321 | |
| 6322 | i--; |
| 6323 | |
| 6324 | if (FPT_scamInfo[match].state == ID_UNASSIGNED) { |
| 6325 | for (k = 0; k < ID_STRING_LENGTH; k++) { |
| 6326 | FPT_scamInfo[match].id_string[k] = |
| 6327 | p_id_string[k]; |
| 6328 | } |
| 6329 | |
| 6330 | FPT_scamInfo[match].id_string[0] |= BIT(7); |
| 6331 | FPT_scamInfo[match].state = ID_ASSIGNED; |
| 6332 | if (FPT_BL_Card[p_card].pNvRamInfo == NULL) |
| 6333 | FPT_BL_Card[p_card].globalFlags |= |
| 6334 | F_UPDATE_EEPROM; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6335 | return match; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6336 | |
| 6337 | } |
| 6338 | |
| 6339 | match--; |
| 6340 | |
| 6341 | if (match == 0xFF) { |
| 6342 | if (p_id_string[0] & BIT(5)) |
| 6343 | match = 7; |
| 6344 | else |
| 6345 | match = MAX_SCSI_TAR - 1; |
| 6346 | } |
| 6347 | } |
| 6348 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 6349 | return NO_ID_AVAIL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6350 | } |
| 6351 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6352 | /*--------------------------------------------------------------------- |
| 6353 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6354 | * Function: FPT_scsavdi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6355 | * |
| 6356 | * Description: Save off the device SCAM ID strings. |
| 6357 | * |
| 6358 | *---------------------------------------------------------------------*/ |
| 6359 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6360 | static void FPT_scsavdi(unsigned char p_card, u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6361 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6362 | unsigned char i, k, max_id; |
| 6363 | unsigned short ee_data, sum_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6364 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6365 | sum_data = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6366 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6367 | for (i = 1; i < EE_SCAMBASE / 2; i++) { |
| 6368 | sum_data += FPT_utilEERead(p_port, i); |
| 6369 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6370 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6371 | FPT_utilEEWriteOnOff(p_port, 1); /* Enable write access to the EEPROM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6372 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6373 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6374 | max_id = 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6375 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6376 | else |
| 6377 | max_id = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6379 | for (i = 0; i < max_id; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6381 | for (k = 0; k < ID_STRING_LENGTH; k += 2) { |
| 6382 | ee_data = FPT_scamInfo[i].id_string[k + 1]; |
| 6383 | ee_data <<= 8; |
| 6384 | ee_data |= FPT_scamInfo[i].id_string[k]; |
| 6385 | sum_data += ee_data; |
| 6386 | FPT_utilEEWrite(p_port, ee_data, |
| 6387 | (unsigned short)((EE_SCAMBASE / 2) + |
| 6388 | (unsigned short)(i * |
| 6389 | ((unsigned short)ID_STRING_LENGTH / 2)) + (unsigned short)(k / 2))); |
| 6390 | } |
| 6391 | } |
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 | FPT_utilEEWrite(p_port, sum_data, EEPROM_CHECK_SUM / 2); |
| 6394 | FPT_utilEEWriteOnOff(p_port, 0); /* Turn off write access */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6395 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6396 | |
| 6397 | /*--------------------------------------------------------------------- |
| 6398 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6399 | * Function: FPT_XbowInit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6400 | * |
| 6401 | * Description: Setup the Xbow for normal operation. |
| 6402 | * |
| 6403 | *---------------------------------------------------------------------*/ |
| 6404 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6405 | static void FPT_XbowInit(u32 port, unsigned char ScamFlg) |
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 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6408 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6409 | i = RD_HARPOON(port + hp_page_ctrl); |
| 6410 | WR_HARPOON(port + hp_page_ctrl, (unsigned char)(i | G_INT_DISABLE)); |
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 | WR_HARPOON(port + hp_scsireset, 0x00); |
| 6413 | WR_HARPOON(port + hp_portctrl_1, HOST_MODE8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6414 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6415 | WR_HARPOON(port + hp_scsireset, (DMA_RESET | HPSCSI_RESET | PROG_RESET | |
| 6416 | FIFO_CLR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6417 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6418 | WR_HARPOON(port + hp_scsireset, SCSI_INI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6419 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6420 | WR_HARPOON(port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6421 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6422 | WR_HARPOON(port + hp_scsisig, 0x00); /* Clear any signals we might */ |
| 6423 | WR_HARPOON(port + hp_scsictrl_0, ENA_SCAM_SEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6424 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6425 | WRW_HARPOON((port + hp_intstat), CLR_ALL_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6426 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6427 | FPT_default_intena = RESET | RSEL | PROG_HLT | TIMEOUT | |
| 6428 | BUS_FREE | XFER_CNT_0 | AUTO_INT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6429 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6430 | if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2)) |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6431 | FPT_default_intena |= SCAM_SEL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6432 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6433 | WRW_HARPOON((port + hp_intena), FPT_default_intena); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6434 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6435 | WR_HARPOON(port + hp_seltimeout, TO_290ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6436 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6437 | /* Turn on SCSI_MODE8 for narrow cards to fix the |
| 6438 | strapping issue with the DUAL CHANNEL card */ |
| 6439 | if (RD_HARPOON(port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6440 | WR_HARPOON(port + hp_addstat, SCSI_MODE8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6442 | WR_HARPOON(port + hp_page_ctrl, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6443 | |
| 6444 | } |
| 6445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6446 | /*--------------------------------------------------------------------- |
| 6447 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6448 | * Function: FPT_BusMasterInit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6449 | * |
| 6450 | * Description: Initialize the BusMaster for normal operations. |
| 6451 | * |
| 6452 | *---------------------------------------------------------------------*/ |
| 6453 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6454 | static void FPT_BusMasterInit(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6455 | { |
| 6456 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6457 | WR_HARPOON(p_port + hp_sys_ctrl, DRVR_RST); |
| 6458 | WR_HARPOON(p_port + hp_sys_ctrl, 0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6459 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6460 | WR_HARPOON(p_port + hp_host_blk_cnt, XFER_BLK64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6461 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6462 | WR_HARPOON(p_port + hp_bm_ctrl, (BMCTRL_DEFAULT)); |
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 | WR_HARPOON(p_port + hp_ee_ctrl, (SCSI_TERM_ENA_H)); |
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 | RD_HARPOON(p_port + hp_int_status); /*Clear interrupts. */ |
| 6467 | WR_HARPOON(p_port + hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT)); |
| 6468 | WR_HARPOON(p_port + hp_page_ctrl, (RD_HARPOON(p_port + hp_page_ctrl) & |
| 6469 | ~SCATTER_EN)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6470 | } |
| 6471 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6472 | /*--------------------------------------------------------------------- |
| 6473 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6474 | * Function: FPT_DiagEEPROM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6475 | * |
| 6476 | * Description: Verfiy checksum and 'Key' and initialize the EEPROM if |
| 6477 | * necessary. |
| 6478 | * |
| 6479 | *---------------------------------------------------------------------*/ |
| 6480 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 6481 | static void FPT_DiagEEPROM(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6482 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6483 | unsigned short index, temp, max_wd_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6484 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6485 | if (RD_HARPOON(p_port + hp_page_ctrl) & NARROW_SCSI_CARD) |
| 6486 | max_wd_cnt = EEPROM_WD_CNT; |
| 6487 | else |
| 6488 | max_wd_cnt = EEPROM_WD_CNT * 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6489 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6490 | temp = FPT_utilEERead(p_port, FW_SIGNATURE / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6491 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6492 | if (temp == 0x4641) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6493 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6494 | for (index = 2; index < max_wd_cnt; index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6495 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6496 | temp += FPT_utilEERead(p_port, index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6497 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6498 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6499 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6500 | if (temp == FPT_utilEERead(p_port, EEPROM_CHECK_SUM / 2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6501 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6502 | return; /*EEPROM is Okay so return now! */ |
| 6503 | } |
| 6504 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6505 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6506 | FPT_utilEEWriteOnOff(p_port, (unsigned char)1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6507 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6508 | for (index = 0; index < max_wd_cnt; index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6509 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6510 | FPT_utilEEWrite(p_port, 0x0000, index); |
| 6511 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6512 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6513 | temp = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6514 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6515 | FPT_utilEEWrite(p_port, 0x4641, FW_SIGNATURE / 2); |
| 6516 | temp += 0x4641; |
| 6517 | FPT_utilEEWrite(p_port, 0x3920, MODEL_NUMB_0 / 2); |
| 6518 | temp += 0x3920; |
| 6519 | FPT_utilEEWrite(p_port, 0x3033, MODEL_NUMB_2 / 2); |
| 6520 | temp += 0x3033; |
| 6521 | FPT_utilEEWrite(p_port, 0x2020, MODEL_NUMB_4 / 2); |
| 6522 | temp += 0x2020; |
| 6523 | FPT_utilEEWrite(p_port, 0x70D3, SYSTEM_CONFIG / 2); |
| 6524 | temp += 0x70D3; |
| 6525 | FPT_utilEEWrite(p_port, 0x0010, BIOS_CONFIG / 2); |
| 6526 | temp += 0x0010; |
| 6527 | FPT_utilEEWrite(p_port, 0x0003, SCAM_CONFIG / 2); |
| 6528 | temp += 0x0003; |
| 6529 | FPT_utilEEWrite(p_port, 0x0007, ADAPTER_SCSI_ID / 2); |
| 6530 | temp += 0x0007; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6531 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6532 | FPT_utilEEWrite(p_port, 0x0000, IGNORE_B_SCAN / 2); |
| 6533 | temp += 0x0000; |
| 6534 | FPT_utilEEWrite(p_port, 0x0000, SEND_START_ENA / 2); |
| 6535 | temp += 0x0000; |
| 6536 | FPT_utilEEWrite(p_port, 0x0000, DEVICE_ENABLE / 2); |
| 6537 | temp += 0x0000; |
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 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL01 / 2); |
| 6540 | temp += 0x4242; |
| 6541 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL23 / 2); |
| 6542 | temp += 0x4242; |
| 6543 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL45 / 2); |
| 6544 | temp += 0x4242; |
| 6545 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL67 / 2); |
| 6546 | temp += 0x4242; |
| 6547 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL89 / 2); |
| 6548 | temp += 0x4242; |
| 6549 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLab / 2); |
| 6550 | temp += 0x4242; |
| 6551 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLcd / 2); |
| 6552 | temp += 0x4242; |
| 6553 | FPT_utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLef / 2); |
| 6554 | temp += 0x4242; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6555 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6556 | FPT_utilEEWrite(p_port, 0x6C46, 64 / 2); /*PRODUCT ID */ |
| 6557 | temp += 0x6C46; |
| 6558 | FPT_utilEEWrite(p_port, 0x7361, 66 / 2); /* FlashPoint LT */ |
| 6559 | temp += 0x7361; |
| 6560 | FPT_utilEEWrite(p_port, 0x5068, 68 / 2); |
| 6561 | temp += 0x5068; |
| 6562 | FPT_utilEEWrite(p_port, 0x696F, 70 / 2); |
| 6563 | temp += 0x696F; |
| 6564 | FPT_utilEEWrite(p_port, 0x746E, 72 / 2); |
| 6565 | temp += 0x746E; |
| 6566 | FPT_utilEEWrite(p_port, 0x4C20, 74 / 2); |
| 6567 | temp += 0x4C20; |
| 6568 | FPT_utilEEWrite(p_port, 0x2054, 76 / 2); |
| 6569 | temp += 0x2054; |
| 6570 | FPT_utilEEWrite(p_port, 0x2020, 78 / 2); |
| 6571 | temp += 0x2020; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6572 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6573 | index = ((EE_SCAMBASE / 2) + (7 * 16)); |
| 6574 | FPT_utilEEWrite(p_port, (0x0700 + TYPE_CODE0), index); |
| 6575 | temp += (0x0700 + TYPE_CODE0); |
| 6576 | index++; |
| 6577 | FPT_utilEEWrite(p_port, 0x5542, index); /*Vendor ID code */ |
| 6578 | temp += 0x5542; /* BUSLOGIC */ |
| 6579 | index++; |
| 6580 | FPT_utilEEWrite(p_port, 0x4C53, index); |
| 6581 | temp += 0x4C53; |
| 6582 | index++; |
| 6583 | FPT_utilEEWrite(p_port, 0x474F, index); |
| 6584 | temp += 0x474F; |
| 6585 | index++; |
| 6586 | FPT_utilEEWrite(p_port, 0x4349, index); |
| 6587 | temp += 0x4349; |
| 6588 | index++; |
| 6589 | FPT_utilEEWrite(p_port, 0x5442, index); /*Vendor unique code */ |
| 6590 | temp += 0x5442; /* BT- 930 */ |
| 6591 | index++; |
| 6592 | FPT_utilEEWrite(p_port, 0x202D, index); |
| 6593 | temp += 0x202D; |
| 6594 | index++; |
| 6595 | FPT_utilEEWrite(p_port, 0x3339, index); |
| 6596 | temp += 0x3339; |
| 6597 | index++; /*Serial # */ |
| 6598 | FPT_utilEEWrite(p_port, 0x2030, index); /* 01234567 */ |
| 6599 | temp += 0x2030; |
| 6600 | index++; |
| 6601 | FPT_utilEEWrite(p_port, 0x5453, index); |
| 6602 | temp += 0x5453; |
| 6603 | index++; |
| 6604 | FPT_utilEEWrite(p_port, 0x5645, index); |
| 6605 | temp += 0x5645; |
| 6606 | index++; |
| 6607 | FPT_utilEEWrite(p_port, 0x2045, index); |
| 6608 | temp += 0x2045; |
| 6609 | index++; |
| 6610 | FPT_utilEEWrite(p_port, 0x202F, index); |
| 6611 | temp += 0x202F; |
| 6612 | index++; |
| 6613 | FPT_utilEEWrite(p_port, 0x4F4A, index); |
| 6614 | temp += 0x4F4A; |
| 6615 | index++; |
| 6616 | FPT_utilEEWrite(p_port, 0x204E, index); |
| 6617 | temp += 0x204E; |
| 6618 | index++; |
| 6619 | FPT_utilEEWrite(p_port, 0x3539, index); |
| 6620 | temp += 0x3539; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6621 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6622 | FPT_utilEEWrite(p_port, temp, EEPROM_CHECK_SUM / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6623 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6624 | FPT_utilEEWriteOnOff(p_port, (unsigned char)0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6625 | |
| 6626 | } |
| 6627 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6628 | /*--------------------------------------------------------------------- |
| 6629 | * |
| 6630 | * Function: Queue Search Select |
| 6631 | * |
| 6632 | * Description: Try to find a new command to execute. |
| 6633 | * |
| 6634 | *---------------------------------------------------------------------*/ |
| 6635 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6636 | static void FPT_queueSearchSelect(struct sccb_card *pCurrCard, |
| 6637 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6638 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6639 | unsigned char scan_ptr, lun; |
| 6640 | struct sccb_mgr_tar_info *currTar_Info; |
| 6641 | struct sccb *pOldSccb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6642 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6643 | scan_ptr = pCurrCard->scanIndex; |
| 6644 | do { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6645 | currTar_Info = &FPT_sccbMgrTbl[p_card][scan_ptr]; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6646 | if ((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 6647 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 6648 | TAG_Q_TRYING)) { |
| 6649 | if (currTar_Info->TarSelQ_Cnt != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6650 | |
| 6651 | scan_ptr++; |
| 6652 | if (scan_ptr == MAX_SCSI_TAR) |
| 6653 | scan_ptr = 0; |
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 | for (lun = 0; lun < MAX_LUN; lun++) { |
| 6656 | if (currTar_Info->TarLUNBusy[lun] == 0) { |
| 6657 | |
| 6658 | pCurrCard->currentSCCB = |
| 6659 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6660 | pOldSccb = NULL; |
| 6661 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6662 | while ((pCurrCard-> |
| 6663 | currentSCCB != NULL) |
| 6664 | && (lun != |
| 6665 | pCurrCard-> |
| 6666 | currentSCCB->Lun)) { |
| 6667 | pOldSccb = |
| 6668 | pCurrCard-> |
| 6669 | currentSCCB; |
| 6670 | pCurrCard->currentSCCB = |
| 6671 | (struct sccb |
| 6672 | *)(pCurrCard-> |
| 6673 | currentSCCB)-> |
| 6674 | Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6675 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6676 | if (pCurrCard->currentSCCB == |
| 6677 | NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6678 | continue; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6679 | if (pOldSccb != NULL) { |
| 6680 | pOldSccb-> |
| 6681 | Sccb_forwardlink = |
| 6682 | (struct sccb |
| 6683 | *)(pCurrCard-> |
| 6684 | currentSCCB)-> |
| 6685 | Sccb_forwardlink; |
| 6686 | pOldSccb-> |
| 6687 | Sccb_backlink = |
| 6688 | (struct sccb |
| 6689 | *)(pCurrCard-> |
| 6690 | currentSCCB)-> |
| 6691 | Sccb_backlink; |
| 6692 | currTar_Info-> |
| 6693 | TarSelQ_Cnt--; |
| 6694 | } else { |
| 6695 | currTar_Info-> |
| 6696 | TarSelQ_Head = |
| 6697 | (struct sccb |
| 6698 | *)(pCurrCard-> |
| 6699 | currentSCCB)-> |
| 6700 | Sccb_forwardlink; |
| 6701 | |
| 6702 | if (currTar_Info-> |
| 6703 | TarSelQ_Head == |
| 6704 | NULL) { |
| 6705 | currTar_Info-> |
| 6706 | TarSelQ_Tail |
| 6707 | = NULL; |
| 6708 | currTar_Info-> |
| 6709 | TarSelQ_Cnt |
| 6710 | = 0; |
| 6711 | } else { |
| 6712 | currTar_Info-> |
| 6713 | TarSelQ_Cnt--; |
| 6714 | currTar_Info-> |
| 6715 | TarSelQ_Head-> |
| 6716 | Sccb_backlink |
| 6717 | = |
| 6718 | (struct sccb |
| 6719 | *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6720 | } |
| 6721 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6722 | pCurrCard->scanIndex = scan_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6723 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6724 | pCurrCard->globalFlags |= |
| 6725 | F_NEW_SCCB_CMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6726 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6727 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6728 | } |
| 6729 | } |
| 6730 | } |
| 6731 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6732 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6733 | scan_ptr++; |
| 6734 | if (scan_ptr == MAX_SCSI_TAR) { |
| 6735 | scan_ptr = 0; |
| 6736 | } |
| 6737 | } |
| 6738 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6739 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6740 | if ((currTar_Info->TarSelQ_Cnt != 0) && |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6741 | (currTar_Info->TarLUNBusy[0] == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6742 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6743 | pCurrCard->currentSCCB = |
| 6744 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6745 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6746 | currTar_Info->TarSelQ_Head = |
| 6747 | (struct sccb *)(pCurrCard->currentSCCB)-> |
| 6748 | Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6749 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6750 | if (currTar_Info->TarSelQ_Head == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6751 | currTar_Info->TarSelQ_Tail = NULL; |
| 6752 | currTar_Info->TarSelQ_Cnt = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6753 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6754 | currTar_Info->TarSelQ_Cnt--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6755 | currTar_Info->TarSelQ_Head-> |
| 6756 | Sccb_backlink = (struct sccb *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6757 | } |
| 6758 | |
| 6759 | scan_ptr++; |
| 6760 | if (scan_ptr == MAX_SCSI_TAR) |
| 6761 | scan_ptr = 0; |
| 6762 | |
| 6763 | pCurrCard->scanIndex = scan_ptr; |
| 6764 | |
| 6765 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 6766 | |
| 6767 | break; |
| 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 | scan_ptr++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6772 | if (scan_ptr == MAX_SCSI_TAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6773 | scan_ptr = 0; |
| 6774 | } |
| 6775 | } |
| 6776 | } |
| 6777 | } while (scan_ptr != pCurrCard->scanIndex); |
| 6778 | } |
| 6779 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6780 | /*--------------------------------------------------------------------- |
| 6781 | * |
| 6782 | * Function: Queue Select Fail |
| 6783 | * |
| 6784 | * Description: Add the current SCCB to the head of the Queue. |
| 6785 | * |
| 6786 | *---------------------------------------------------------------------*/ |
| 6787 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6788 | static void FPT_queueSelectFail(struct sccb_card *pCurrCard, |
| 6789 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6790 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6791 | unsigned char thisTarg; |
| 6792 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6793 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6794 | if (pCurrCard->currentSCCB != NULL) { |
| 6795 | thisTarg = |
| 6796 | (unsigned char)(((struct sccb *)(pCurrCard->currentSCCB))-> |
| 6797 | TargID); |
| 6798 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6799 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6800 | pCurrCard->currentSCCB->Sccb_backlink = (struct sccb *)NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6801 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6802 | pCurrCard->currentSCCB->Sccb_forwardlink = |
| 6803 | currTar_Info->TarSelQ_Head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6804 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6805 | if (currTar_Info->TarSelQ_Cnt == 0) { |
| 6806 | currTar_Info->TarSelQ_Tail = pCurrCard->currentSCCB; |
| 6807 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6808 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6809 | else { |
| 6810 | currTar_Info->TarSelQ_Head->Sccb_backlink = |
| 6811 | pCurrCard->currentSCCB; |
| 6812 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6813 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6814 | currTar_Info->TarSelQ_Head = pCurrCard->currentSCCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6815 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6816 | pCurrCard->currentSCCB = NULL; |
| 6817 | currTar_Info->TarSelQ_Cnt++; |
| 6818 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6819 | } |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6820 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6821 | /*--------------------------------------------------------------------- |
| 6822 | * |
| 6823 | * Function: Queue Command Complete |
| 6824 | * |
| 6825 | * Description: Call the callback function with the current SCCB. |
| 6826 | * |
| 6827 | *---------------------------------------------------------------------*/ |
| 6828 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6829 | static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, |
| 6830 | struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6831 | { |
| 6832 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6833 | unsigned char i, SCSIcmd; |
| 6834 | CALL_BK_FN callback; |
| 6835 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6836 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6837 | SCSIcmd = p_sccb->Cdb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6838 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6839 | if (!(p_sccb->Sccb_XferState & F_ALL_XFERRED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6840 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6841 | if ((p_sccb-> |
| 6842 | ControlByte & (SCCB_DATA_XFER_OUT | SCCB_DATA_XFER_IN)) |
| 6843 | && (p_sccb->HostStatus == SCCB_COMPLETE) |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 6844 | && (p_sccb->TargetStatus != SAM_STAT_CHECK_CONDITION)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6845 | |
Hannes Reinecke | a87afe2 | 2021-04-27 10:30:40 +0200 | [diff] [blame] | 6846 | if ((SCSIcmd == READ_6) || |
| 6847 | (SCSIcmd == WRITE_6) || |
| 6848 | (SCSIcmd == READ_10) || |
| 6849 | (SCSIcmd == WRITE_10) || |
| 6850 | (SCSIcmd == WRITE_VERIFY) || |
| 6851 | (SCSIcmd == START_STOP) || |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6852 | (pCurrCard->globalFlags & F_NO_FILTER) |
| 6853 | ) |
| 6854 | p_sccb->HostStatus = SCCB_DATA_UNDER_RUN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6855 | } |
| 6856 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6857 | if (p_sccb->SccbStatus == SCCB_IN_PROCESS) { |
| 6858 | if (p_sccb->HostStatus || p_sccb->TargetStatus) |
| 6859 | p_sccb->SccbStatus = SCCB_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6860 | else |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6861 | p_sccb->SccbStatus = SCCB_SUCCESS; |
| 6862 | } |
| 6863 | |
| 6864 | if (p_sccb->Sccb_XferState & F_AUTO_SENSE) { |
| 6865 | |
| 6866 | p_sccb->CdbLength = p_sccb->Save_CdbLen; |
| 6867 | for (i = 0; i < 6; i++) { |
| 6868 | p_sccb->Cdb[i] = p_sccb->Save_Cdb[i]; |
| 6869 | } |
| 6870 | } |
| 6871 | |
| 6872 | if ((p_sccb->OperationCode == RESIDUAL_SG_COMMAND) || |
| 6873 | (p_sccb->OperationCode == RESIDUAL_COMMAND)) { |
| 6874 | |
| 6875 | FPT_utilUpdateResidual(p_sccb); |
| 6876 | } |
| 6877 | |
| 6878 | pCurrCard->cmdCounter--; |
| 6879 | if (!pCurrCard->cmdCounter) { |
| 6880 | |
| 6881 | if (pCurrCard->globalFlags & F_GREEN_PC) { |
| 6882 | WR_HARPOON(pCurrCard->ioPort + hp_clkctrl_0, |
| 6883 | (PWR_DWN | CLKCTRL_DEFAULT)); |
| 6884 | WR_HARPOON(pCurrCard->ioPort + hp_sys_ctrl, STOP_CLK); |
| 6885 | } |
| 6886 | |
| 6887 | WR_HARPOON(pCurrCard->ioPort + hp_semaphore, |
| 6888 | (RD_HARPOON(pCurrCard->ioPort + hp_semaphore) & |
| 6889 | ~SCCB_MGR_ACTIVE)); |
| 6890 | |
| 6891 | } |
| 6892 | |
| 6893 | if (pCurrCard->discQCount != 0) { |
| 6894 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
| 6895 | if (((pCurrCard->globalFlags & F_CONLUN_IO) && |
| 6896 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != |
| 6897 | TAG_Q_TRYING))) { |
| 6898 | pCurrCard->discQCount--; |
| 6899 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 6900 | LunDiscQ_Idx[p_sccb->Lun]] = NULL; |
| 6901 | } else { |
| 6902 | if (p_sccb->Sccb_tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6903 | pCurrCard->discQCount--; |
| 6904 | pCurrCard->discQ_Tbl[p_sccb->Sccb_tag] = NULL; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6905 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6906 | pCurrCard->discQCount--; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6907 | pCurrCard->discQ_Tbl[currTar_Info-> |
| 6908 | LunDiscQ_Idx[0]] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6909 | } |
| 6910 | } |
| 6911 | |
| 6912 | } |
| 6913 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6914 | callback = (CALL_BK_FN) p_sccb->SccbCallback; |
| 6915 | callback(p_sccb); |
| 6916 | pCurrCard->globalFlags |= F_NEW_SCCB_CMD; |
| 6917 | pCurrCard->currentSCCB = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6918 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6919 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6920 | /*--------------------------------------------------------------------- |
| 6921 | * |
| 6922 | * Function: Queue Disconnect |
| 6923 | * |
| 6924 | * Description: Add SCCB to our disconnect array. |
| 6925 | * |
| 6926 | *---------------------------------------------------------------------*/ |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6927 | static void FPT_queueDisconnect(struct sccb *p_sccb, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6928 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6929 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6930 | |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6931 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6932 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6933 | if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && |
| 6934 | ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))) { |
| 6935 | FPT_BL_Card[p_card].discQ_Tbl[currTar_Info-> |
| 6936 | LunDiscQ_Idx[p_sccb->Lun]] = |
| 6937 | p_sccb; |
| 6938 | } else { |
| 6939 | if (p_sccb->Sccb_tag) { |
| 6940 | FPT_BL_Card[p_card].discQ_Tbl[p_sccb->Sccb_tag] = |
| 6941 | p_sccb; |
| 6942 | FPT_sccbMgrTbl[p_card][p_sccb->TargID].TarLUNBusy[0] = |
| 6943 | 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6944 | FPT_sccbMgrTbl[p_card][p_sccb->TargID].TarTagQ_Cnt++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6945 | } else { |
| 6946 | FPT_BL_Card[p_card].discQ_Tbl[currTar_Info-> |
| 6947 | LunDiscQ_Idx[0]] = p_sccb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6948 | } |
| 6949 | } |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 6950 | FPT_BL_Card[p_card].currentSCCB = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6951 | } |
| 6952 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6953 | /*--------------------------------------------------------------------- |
| 6954 | * |
| 6955 | * Function: Queue Flush SCCB |
| 6956 | * |
| 6957 | * Description: Flush all SCCB's back to the host driver for this target. |
| 6958 | * |
| 6959 | *---------------------------------------------------------------------*/ |
| 6960 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6961 | static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6962 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6963 | unsigned char qtag, thisTarg; |
| 6964 | struct sccb *currSCCB; |
| 6965 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6966 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6967 | currSCCB = FPT_BL_Card[p_card].currentSCCB; |
| 6968 | if (currSCCB != NULL) { |
| 6969 | thisTarg = (unsigned char)currSCCB->TargID; |
| 6970 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6971 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6972 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6973 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6974 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] && |
| 6975 | (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == |
| 6976 | thisTarg)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6977 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6978 | FPT_BL_Card[p_card].discQ_Tbl[qtag]-> |
| 6979 | HostStatus = (unsigned char)error_code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6980 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6981 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 6982 | FPT_BL_Card[p_card]. |
| 6983 | discQ_Tbl[qtag], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6984 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 6985 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 6986 | currTar_Info->TarTagQ_Cnt--; |
| 6987 | |
| 6988 | } |
| 6989 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6990 | } |
| 6991 | |
| 6992 | } |
| 6993 | |
| 6994 | /*--------------------------------------------------------------------- |
| 6995 | * |
| 6996 | * Function: Queue Flush Target SCCB |
| 6997 | * |
| 6998 | * Description: Flush all SCCB's back to the host driver for this target. |
| 6999 | * |
| 7000 | *---------------------------------------------------------------------*/ |
| 7001 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7002 | static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg, |
| 7003 | unsigned char error_code) |
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 | unsigned char qtag; |
| 7006 | struct sccb_mgr_tar_info *currTar_Info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7007 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7008 | currTar_Info = &FPT_sccbMgrTbl[p_card][thisTarg]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7009 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7010 | for (qtag = 0; qtag < QUEUE_DEPTH; qtag++) { |
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 | if (FPT_BL_Card[p_card].discQ_Tbl[qtag] && |
| 7013 | (FPT_BL_Card[p_card].discQ_Tbl[qtag]->TargID == thisTarg)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7014 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7015 | FPT_BL_Card[p_card].discQ_Tbl[qtag]->HostStatus = |
| 7016 | (unsigned char)error_code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7017 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7018 | FPT_queueCmdComplete(&FPT_BL_Card[p_card], |
| 7019 | FPT_BL_Card[p_card]. |
| 7020 | discQ_Tbl[qtag], p_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7021 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7022 | FPT_BL_Card[p_card].discQ_Tbl[qtag] = NULL; |
| 7023 | currTar_Info->TarTagQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7024 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7025 | } |
| 7026 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7027 | |
| 7028 | } |
| 7029 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7030 | static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7031 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7032 | struct sccb_mgr_tar_info *currTar_Info; |
| 7033 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_SCCB->TargID]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7034 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7035 | p_SCCB->Sccb_forwardlink = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7036 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7037 | p_SCCB->Sccb_backlink = currTar_Info->TarSelQ_Tail; |
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 | if (currTar_Info->TarSelQ_Cnt == 0) { |
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 | currTar_Info->TarSelQ_Head = p_SCCB; |
| 7042 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7043 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7044 | else { |
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 | currTar_Info->TarSelQ_Tail->Sccb_forwardlink = p_SCCB; |
| 7047 | } |
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 | currTar_Info->TarSelQ_Tail = p_SCCB; |
| 7050 | currTar_Info->TarSelQ_Cnt++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7051 | } |
| 7052 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7053 | /*--------------------------------------------------------------------- |
| 7054 | * |
| 7055 | * Function: Queue Find SCCB |
| 7056 | * |
| 7057 | * Description: Search the target select Queue for this SCCB, and |
| 7058 | * remove it if found. |
| 7059 | * |
| 7060 | *---------------------------------------------------------------------*/ |
| 7061 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7062 | static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB, |
| 7063 | unsigned char p_card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7064 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7065 | struct sccb *q_ptr; |
| 7066 | struct sccb_mgr_tar_info *currTar_Info; |
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 | currTar_Info = &FPT_sccbMgrTbl[p_card][p_SCCB->TargID]; |
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 | q_ptr = currTar_Info->TarSelQ_Head; |
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 | while (q_ptr != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7073 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7074 | if (q_ptr == p_SCCB) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7075 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7076 | if (currTar_Info->TarSelQ_Head == q_ptr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7077 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7078 | currTar_Info->TarSelQ_Head = |
| 7079 | q_ptr->Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7080 | } |
| 7081 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7082 | if (currTar_Info->TarSelQ_Tail == q_ptr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7083 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7084 | currTar_Info->TarSelQ_Tail = |
| 7085 | q_ptr->Sccb_backlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7086 | } |
| 7087 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7088 | if (q_ptr->Sccb_forwardlink != NULL) { |
| 7089 | q_ptr->Sccb_forwardlink->Sccb_backlink = |
| 7090 | q_ptr->Sccb_backlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7091 | } |
| 7092 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7093 | if (q_ptr->Sccb_backlink != NULL) { |
| 7094 | q_ptr->Sccb_backlink->Sccb_forwardlink = |
| 7095 | q_ptr->Sccb_forwardlink; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7096 | } |
| 7097 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7098 | currTar_Info->TarSelQ_Cnt--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7099 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7100 | return 1; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7101 | } |
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 | else { |
| 7104 | q_ptr = q_ptr->Sccb_forwardlink; |
| 7105 | } |
| 7106 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7107 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7108 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7109 | |
| 7110 | } |
| 7111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7112 | /*--------------------------------------------------------------------- |
| 7113 | * |
| 7114 | * Function: Utility Update Residual Count |
| 7115 | * |
| 7116 | * Description: Update the XferCnt to the remaining byte count. |
| 7117 | * If we transferred all the data then just write zero. |
| 7118 | * If Non-SG transfer then report Total Cnt - Actual Transfer |
| 7119 | * Cnt. For SG transfers add the count fields of all |
| 7120 | * remaining SG elements, as well as any partial remaining |
| 7121 | * element. |
| 7122 | * |
| 7123 | *---------------------------------------------------------------------*/ |
| 7124 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7125 | static void FPT_utilUpdateResidual(struct sccb *p_SCCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7126 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7127 | unsigned long partial_cnt; |
| 7128 | unsigned int sg_index; |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7129 | struct blogic_sg_seg *segp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7130 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7131 | if (p_SCCB->Sccb_XferState & F_ALL_XFERRED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7132 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7133 | p_SCCB->DataLength = 0x0000; |
| 7134 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7135 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7136 | else if (p_SCCB->Sccb_XferState & F_SG_XFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7137 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7138 | partial_cnt = 0x0000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7139 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7140 | sg_index = p_SCCB->Sccb_sgseg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7142 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7143 | if (p_SCCB->Sccb_SGoffset) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7144 | |
| 7145 | partial_cnt = p_SCCB->Sccb_SGoffset; |
| 7146 | sg_index++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7147 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7148 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7149 | while (((unsigned long)sg_index * |
| 7150 | (unsigned long)SG_ELEMENT_SIZE) < p_SCCB->DataLength) { |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7151 | segp = (struct blogic_sg_seg *)(p_SCCB->DataPointer) + |
| 7152 | (sg_index * 2); |
| 7153 | partial_cnt += segp->segbytes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7154 | sg_index++; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7155 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7156 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7157 | p_SCCB->DataLength = partial_cnt; |
| 7158 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7159 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7160 | else { |
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 | p_SCCB->DataLength -= p_SCCB->Sccb_ATC; |
| 7163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7164 | } |
| 7165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7166 | /*--------------------------------------------------------------------- |
| 7167 | * |
| 7168 | * Function: Wait 1 Second |
| 7169 | * |
| 7170 | * Description: Wait for 1 second. |
| 7171 | * |
| 7172 | *---------------------------------------------------------------------*/ |
| 7173 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7174 | static void FPT_Wait1Second(u32 p_port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7175 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7176 | unsigned char i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7177 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7178 | for (i = 0; i < 4; i++) { |
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 | FPT_Wait(p_port, TO_250ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7181 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7182 | if ((RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST)) |
| 7183 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7184 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7185 | if ((RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) |
| 7186 | break; |
| 7187 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7188 | } |
| 7189 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7190 | /*--------------------------------------------------------------------- |
| 7191 | * |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7192 | * Function: FPT_Wait |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7193 | * |
| 7194 | * Description: Wait the desired delay. |
| 7195 | * |
| 7196 | *---------------------------------------------------------------------*/ |
| 7197 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7198 | static void FPT_Wait(u32 p_port, unsigned char p_delay) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7199 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7200 | unsigned char old_timer; |
| 7201 | unsigned char green_flag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7202 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7203 | old_timer = RD_HARPOON(p_port + hp_seltimeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7204 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7205 | green_flag = RD_HARPOON(p_port + hp_clkctrl_0); |
| 7206 | WR_HARPOON(p_port + hp_clkctrl_0, CLKCTRL_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7207 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7208 | WR_HARPOON(p_port + hp_seltimeout, p_delay); |
| 7209 | WRW_HARPOON((p_port + hp_intstat), TIMEOUT); |
| 7210 | WRW_HARPOON((p_port + hp_intena), (FPT_default_intena & ~TIMEOUT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7211 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7212 | WR_HARPOON(p_port + hp_portctrl_0, |
| 7213 | (RD_HARPOON(p_port + hp_portctrl_0) | START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7214 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7215 | while (!(RDW_HARPOON((p_port + hp_intstat)) & TIMEOUT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7216 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7217 | if ((RD_HARPOON(p_port + hp_scsictrl_0) & SCSI_RST)) |
| 7218 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7219 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7220 | if ((RDW_HARPOON((p_port + hp_intstat)) & SCAM_SEL)) |
| 7221 | break; |
| 7222 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7223 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7224 | WR_HARPOON(p_port + hp_portctrl_0, |
| 7225 | (RD_HARPOON(p_port + hp_portctrl_0) & ~START_TO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7226 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7227 | WRW_HARPOON((p_port + hp_intstat), TIMEOUT); |
| 7228 | WRW_HARPOON((p_port + hp_intena), FPT_default_intena); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7229 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7230 | WR_HARPOON(p_port + hp_clkctrl_0, green_flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7231 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7232 | WR_HARPOON(p_port + hp_seltimeout, old_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7233 | } |
| 7234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7235 | /*--------------------------------------------------------------------- |
| 7236 | * |
| 7237 | * Function: Enable/Disable Write to EEPROM |
| 7238 | * |
| 7239 | * Description: The EEPROM must first be enabled for writes |
| 7240 | * A total of 9 clocks are needed. |
| 7241 | * |
| 7242 | *---------------------------------------------------------------------*/ |
| 7243 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7244 | static void FPT_utilEEWriteOnOff(u32 p_port, unsigned char p_mode) |
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 | unsigned char ee_value; |
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 | ee_value = |
| 7249 | (unsigned char)(RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7250 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7251 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7252 | if (p_mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7253 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7254 | FPT_utilEESendCmdAddr(p_port, EWEN, EWEN_ADDR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7255 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7256 | else |
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 | FPT_utilEESendCmdAddr(p_port, EWDS, EWDS_ADDR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7259 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7260 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */ |
| 7261 | 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] | 7262 | } |
| 7263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7264 | /*--------------------------------------------------------------------- |
| 7265 | * |
| 7266 | * Function: Write EEPROM |
| 7267 | * |
| 7268 | * Description: Write a word to the EEPROM at the specified |
| 7269 | * address. |
| 7270 | * |
| 7271 | *---------------------------------------------------------------------*/ |
| 7272 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7273 | static void FPT_utilEEWrite(u32 p_port, unsigned short ee_data, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7274 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7275 | { |
| 7276 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7277 | unsigned char ee_value; |
| 7278 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7279 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7280 | ee_value = |
| 7281 | (unsigned |
| 7282 | char)((RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7283 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)) | (SEE_MS | SEE_CS)); |
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, EE_WRITE, ee_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 | ee_value |= (SEE_MS + SEE_CS); |
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 | for (i = 0x8000; i != 0; i >>= 1) { |
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 | if (i & ee_data) |
| 7292 | ee_value |= SEE_DO; |
| 7293 | else |
| 7294 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7295 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7296 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7297 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7298 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7299 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7300 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7301 | ee_value &= ~SEE_CLK; |
| 7302 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7303 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7304 | } |
| 7305 | ee_value &= (EXT_ARB_ACK | SCSI_TERM_ENA_H); |
| 7306 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7307 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7308 | FPT_Wait(p_port, TO_10ms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7309 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7310 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS | SEE_CS)); /* Set CS to EEPROM */ |
| 7311 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /* Turn off CS */ |
| 7312 | 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] | 7313 | } |
| 7314 | |
| 7315 | /*--------------------------------------------------------------------- |
| 7316 | * |
| 7317 | * Function: Read EEPROM |
| 7318 | * |
| 7319 | * Description: Read a word from the EEPROM at the desired |
| 7320 | * address. |
| 7321 | * |
| 7322 | *---------------------------------------------------------------------*/ |
| 7323 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7324 | static unsigned short FPT_utilEERead(u32 p_port, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7325 | unsigned short ee_addr) |
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 | unsigned short i, ee_data1, ee_data2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7328 | |
| 7329 | i = 0; |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7330 | ee_data1 = FPT_utilEEReadOrg(p_port, ee_addr); |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7331 | do { |
James Bottomley | 47b5d69 | 2005-04-24 02:38:05 -0500 | [diff] [blame] | 7332 | ee_data2 = FPT_utilEEReadOrg(p_port, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7333 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7334 | if (ee_data1 == ee_data2) |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7335 | return ee_data1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7336 | |
| 7337 | ee_data1 = ee_data2; |
| 7338 | i++; |
| 7339 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7340 | } while (i < 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7341 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7342 | return ee_data1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7343 | } |
| 7344 | |
| 7345 | /*--------------------------------------------------------------------- |
| 7346 | * |
| 7347 | * Function: Read EEPROM Original |
| 7348 | * |
| 7349 | * Description: Read a word from the EEPROM at the desired |
| 7350 | * address. |
| 7351 | * |
| 7352 | *---------------------------------------------------------------------*/ |
| 7353 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7354 | static unsigned short FPT_utilEEReadOrg(u32 p_port, unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7355 | { |
| 7356 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7357 | unsigned char ee_value; |
| 7358 | unsigned short i, ee_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7359 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7360 | ee_value = |
| 7361 | (unsigned |
| 7362 | char)((RD_HARPOON(p_port + hp_ee_ctrl) & |
| 7363 | (EXT_ARB_ACK | SCSI_TERM_ENA_H)) | (SEE_MS | SEE_CS)); |
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 | FPT_utilEESendCmdAddr(p_port, EE_READ, ee_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7366 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7367 | ee_value |= (SEE_MS + SEE_CS); |
| 7368 | ee_data = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7369 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7370 | for (i = 1; i <= 16; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7371 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7372 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7373 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7374 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7375 | ee_value &= ~SEE_CLK; |
| 7376 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7377 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7378 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7379 | ee_data <<= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7380 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7381 | if (RD_HARPOON(p_port + hp_ee_ctrl) & SEE_DI) |
| 7382 | ee_data |= 1; |
| 7383 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7384 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7385 | ee_value &= ~(SEE_MS + SEE_CS); |
| 7386 | WR_HARPOON(p_port + hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */ |
| 7387 | 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] | 7388 | |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7389 | return ee_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7390 | } |
| 7391 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7392 | /*--------------------------------------------------------------------- |
| 7393 | * |
| 7394 | * Function: Send EE command and Address to the EEPROM |
| 7395 | * |
| 7396 | * Description: Transfers the correct command and sends the address |
| 7397 | * to the eeprom. |
| 7398 | * |
| 7399 | *---------------------------------------------------------------------*/ |
| 7400 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7401 | static void FPT_utilEESendCmdAddr(u32 p_port, unsigned char ee_cmd, |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7402 | unsigned short ee_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7403 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7404 | unsigned char ee_value; |
| 7405 | unsigned char narrow_flg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7406 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7407 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7408 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7409 | narrow_flg = |
| 7410 | (unsigned char)(RD_HARPOON(p_port + hp_page_ctrl) & |
| 7411 | NARROW_SCSI_CARD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7412 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7413 | ee_value = SEE_MS; |
| 7414 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
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_CS; /* Set CS to EEPROM */ |
| 7417 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7418 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7419 | for (i = 0x04; i != 0; i >>= 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7420 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7421 | if (i & ee_cmd) |
| 7422 | ee_value |= SEE_DO; |
| 7423 | else |
| 7424 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7425 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7426 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7427 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7428 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7429 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7430 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7431 | ee_value &= ~SEE_CLK; |
| 7432 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7433 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7434 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7435 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7436 | if (narrow_flg) |
| 7437 | i = 0x0080; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7438 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7439 | else |
| 7440 | i = 0x0200; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7441 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7442 | while (i != 0) { |
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 | if (i & ee_addr) |
| 7445 | ee_value |= SEE_DO; |
| 7446 | else |
| 7447 | ee_value &= ~SEE_DO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7448 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7449 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7450 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7451 | ee_value |= SEE_CLK; /* Clock data! */ |
| 7452 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7453 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7454 | ee_value &= ~SEE_CLK; |
| 7455 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
| 7456 | WR_HARPOON(p_port + hp_ee_ctrl, ee_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7457 | |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7458 | i >>= 1; |
| 7459 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7460 | } |
| 7461 | |
Alexey Dobriyan | c823fee | 2006-03-08 00:14:25 -0800 | [diff] [blame] | 7462 | static unsigned short FPT_CalcCrc16(unsigned char buffer[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7463 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7464 | unsigned short crc = 0; |
| 7465 | int i, j; |
| 7466 | unsigned short ch; |
| 7467 | for (i = 0; i < ID_STRING_LENGTH; i++) { |
| 7468 | ch = (unsigned short)buffer[i]; |
| 7469 | for (j = 0; j < 8; j++) { |
| 7470 | if ((crc ^ ch) & 1) |
| 7471 | crc = (crc >> 1) ^ CRCMASK; |
| 7472 | else |
| 7473 | crc >>= 1; |
| 7474 | ch >>= 1; |
| 7475 | } |
| 7476 | } |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7477 | return crc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7478 | } |
| 7479 | |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 7480 | static unsigned char FPT_CalcLrc(unsigned char buffer[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7481 | { |
| 7482 | int i; |
Alexey Dobriyan | db038cf8 | 2006-03-08 00:14:24 -0800 | [diff] [blame] | 7483 | unsigned char lrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7484 | lrc = 0; |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7485 | for (i = 0; i < ID_STRING_LENGTH; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7486 | lrc ^= buffer[i]; |
Alexey Dobriyan | 5c1b85e | 2006-03-08 00:14:37 -0800 | [diff] [blame] | 7487 | return lrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7488 | } |
| 7489 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7490 | /* |
| 7491 | The following inline definitions avoid type conflicts. |
| 7492 | */ |
| 7493 | |
| 7494 | static inline unsigned char |
Khalid Aziz | 839cb99 | 2013-05-16 19:44:13 -0600 | [diff] [blame] | 7495 | FlashPoint__ProbeHostAdapter(struct fpoint_info *FlashPointInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7496 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7497 | return FlashPoint_ProbeHostAdapter((struct sccb_mgr_info *) |
| 7498 | FlashPointInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7499 | } |
| 7500 | |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7501 | static inline void * |
Khalid Aziz | 839cb99 | 2013-05-16 19:44:13 -0600 | [diff] [blame] | 7502 | FlashPoint__HardwareResetHostAdapter(struct fpoint_info *FlashPointInfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7503 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7504 | return FlashPoint_HardwareResetHostAdapter((struct sccb_mgr_info *) |
| 7505 | FlashPointInfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7506 | } |
| 7507 | |
| 7508 | static inline void |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7509 | FlashPoint__ReleaseHostAdapter(void *CardHandle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7510 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7511 | FlashPoint_ReleaseHostAdapter(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7512 | } |
| 7513 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7514 | static inline void |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7515 | FlashPoint__StartCCB(void *CardHandle, struct blogic_ccb *CCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7516 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7517 | FlashPoint_StartCCB(CardHandle, (struct sccb *)CCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7518 | } |
| 7519 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7520 | static inline void |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7521 | FlashPoint__AbortCCB(void *CardHandle, struct blogic_ccb *CCB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7522 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7523 | FlashPoint_AbortCCB(CardHandle, (struct sccb *)CCB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7524 | } |
| 7525 | |
Richard Knutsson | 2065e31 | 2007-02-05 16:39:01 -0800 | [diff] [blame] | 7526 | static inline bool |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7527 | FlashPoint__InterruptPending(void *CardHandle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7528 | { |
Alexey Dobriyan | 5c04a7b | 2006-03-08 00:14:35 -0800 | [diff] [blame] | 7529 | return FlashPoint_InterruptPending(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7530 | } |
| 7531 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7532 | static inline int |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7533 | FlashPoint__HandleInterrupt(void *CardHandle) |
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_HandleInterrupt(CardHandle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7536 | } |
| 7537 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7538 | #define FlashPoint_ProbeHostAdapter FlashPoint__ProbeHostAdapter |
| 7539 | #define FlashPoint_HardwareResetHostAdapter FlashPoint__HardwareResetHostAdapter |
| 7540 | #define FlashPoint_ReleaseHostAdapter FlashPoint__ReleaseHostAdapter |
| 7541 | #define FlashPoint_StartCCB FlashPoint__StartCCB |
| 7542 | #define FlashPoint_AbortCCB FlashPoint__AbortCCB |
| 7543 | #define FlashPoint_InterruptPending FlashPoint__InterruptPending |
| 7544 | #define FlashPoint_HandleInterrupt FlashPoint__HandleInterrupt |
| 7545 | |
Matthew Wilcox | 78b4b05 | 2008-03-13 06:55:08 -0600 | [diff] [blame] | 7546 | #else /* !CONFIG_SCSI_FLASHPOINT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7547 | |
| 7548 | /* |
| 7549 | Define prototypes for the FlashPoint SCCB Manager Functions. |
| 7550 | */ |
| 7551 | |
Khalid Aziz | 839cb99 | 2013-05-16 19:44:13 -0600 | [diff] [blame] | 7552 | extern unsigned char FlashPoint_ProbeHostAdapter(struct fpoint_info *); |
Khalid Aziz | 391e2f2 | 2013-05-16 19:44:14 -0600 | [diff] [blame] | 7553 | extern void *FlashPoint_HardwareResetHostAdapter(struct fpoint_info *); |
| 7554 | extern void FlashPoint_StartCCB(void *, struct blogic_ccb *); |
| 7555 | extern int FlashPoint_AbortCCB(void *, struct blogic_ccb *); |
| 7556 | extern bool FlashPoint_InterruptPending(void *); |
| 7557 | extern int FlashPoint_HandleInterrupt(void *); |
| 7558 | extern void FlashPoint_ReleaseHostAdapter(void *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7559 | |
Matthew Wilcox | 78b4b05 | 2008-03-13 06:55:08 -0600 | [diff] [blame] | 7560 | #endif /* CONFIG_SCSI_FLASHPOINT */ |