Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | ******************************************************************************* |
| 3 | ** O.S : Linux |
| 4 | ** FILE NAME : arcmsr.h |
NickCheng | 97b9912 | 2011-01-06 17:32:41 +0800 | [diff] [blame] | 5 | ** BY : Nick Cheng |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 6 | ** Description: SCSI RAID Device Driver for |
| 7 | ** ARECA RAID Host adapter |
| 8 | ******************************************************************************* |
| 9 | ** Copyright (C) 2002 - 2005, Areca Technology Corporation All rights reserved. |
| 10 | ** |
| 11 | ** Web site: www.areca.com.tw |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 12 | ** E-mail: support@areca.com.tw |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 13 | ** |
| 14 | ** This program is free software; you can redistribute it and/or modify |
| 15 | ** it under the terms of the GNU General Public License version 2 as |
| 16 | ** published by the Free Software Foundation. |
| 17 | ** This program is distributed in the hope that it will be useful, |
| 18 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | ** GNU General Public License for more details. |
| 21 | ******************************************************************************* |
| 22 | ** Redistribution and use in source and binary forms, with or without |
| 23 | ** modification, are permitted provided that the following conditions |
| 24 | ** are met: |
| 25 | ** 1. Redistributions of source code must retain the above copyright |
| 26 | ** notice, this list of conditions and the following disclaimer. |
| 27 | ** 2. Redistributions in binary form must reproduce the above copyright |
| 28 | ** notice, this list of conditions and the following disclaimer in the |
| 29 | ** documentation and/or other materials provided with the distribution. |
| 30 | ** 3. The name of the author may not be used to endorse or promote products |
| 31 | ** derived from this software without specific prior written permission. |
| 32 | ** |
| 33 | ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 34 | ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 35 | ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 36 | ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 37 | ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT |
| 38 | ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 39 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANY |
| 40 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 41 | **(INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF |
| 42 | ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 43 | ******************************************************************************* |
| 44 | */ |
| 45 | #include <linux/interrupt.h> |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 46 | struct device_attribute; |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 47 | /*The limit of outstanding scsi command that firmware can handle*/ |
NickCheng | 97b9912 | 2011-01-06 17:32:41 +0800 | [diff] [blame] | 48 | #ifdef CONFIG_XEN |
| 49 | #define ARCMSR_MAX_FREECCB_NUM 160 |
Ching Huang | 3df824a | 2014-08-19 14:29:41 +0800 | [diff] [blame] | 50 | #define ARCMSR_MAX_OUTSTANDING_CMD 155 |
NickCheng | 97b9912 | 2011-01-06 17:32:41 +0800 | [diff] [blame] | 51 | #else |
| 52 | #define ARCMSR_MAX_FREECCB_NUM 320 |
Ching Huang | 3df824a | 2014-08-19 14:29:41 +0800 | [diff] [blame] | 53 | #define ARCMSR_MAX_OUTSTANDING_CMD 255 |
NickCheng | 97b9912 | 2011-01-06 17:32:41 +0800 | [diff] [blame] | 54 | #endif |
Ching Huang | 6b39372 | 2014-08-19 14:18:24 +0800 | [diff] [blame] | 55 | #define ARCMSR_DRIVER_VERSION "v1.30.00.04-20140428" |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 56 | #define ARCMSR_SCSI_INITIATOR_ID 255 |
| 57 | #define ARCMSR_MAX_XFER_SECTORS 512 |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 58 | #define ARCMSR_MAX_XFER_SECTORS_B 4096 |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 59 | #define ARCMSR_MAX_XFER_SECTORS_C 304 |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 60 | #define ARCMSR_MAX_TARGETID 17 |
| 61 | #define ARCMSR_MAX_TARGETLUN 8 |
| 62 | #define ARCMSR_MAX_CMD_PERLUN ARCMSR_MAX_OUTSTANDING_CMD |
| 63 | #define ARCMSR_MAX_QBUFFER 4096 |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 64 | #define ARCMSR_DEFAULT_SG_ENTRIES 38 |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 65 | #define ARCMSR_MAX_HBB_POSTQUEUE 264 |
Ching Huang | 5b37479 | 2014-08-19 15:25:22 +0800 | [diff] [blame^] | 66 | #define ARCMSR_MAX_ARC1214_POSTQUEUE 256 |
| 67 | #define ARCMSR_MAX_ARC1214_DONEQUEUE 257 |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 68 | #define ARCMSR_MAX_XFER_LEN 0x26000 /* 152K */ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 69 | #define ARCMSR_CDB_SG_PAGE_LENGTH 256 |
Ching Huang | 1d1166e | 2014-08-19 14:23:31 +0800 | [diff] [blame] | 70 | #define ARCMST_NUM_MSIX_VECTORS 4 |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 71 | #ifndef PCI_DEVICE_ID_ARECA_1880 |
| 72 | #define PCI_DEVICE_ID_ARECA_1880 0x1880 |
| 73 | #endif |
Ching Huang | 5b37479 | 2014-08-19 15:25:22 +0800 | [diff] [blame^] | 74 | #ifndef PCI_DEVICE_ID_ARECA_1214 |
| 75 | #define PCI_DEVICE_ID_ARECA_1214 0x1214 |
| 76 | #endif |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 77 | /* |
| 78 | ********************************************************************************** |
| 79 | ** |
| 80 | ********************************************************************************** |
| 81 | */ |
| 82 | #define ARC_SUCCESS 0 |
| 83 | #define ARC_FAILURE 1 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 84 | /* |
| 85 | ******************************************************************************* |
| 86 | ** split 64bits dma addressing |
| 87 | ******************************************************************************* |
| 88 | */ |
| 89 | #define dma_addr_hi32(addr) (uint32_t) ((addr>>16)>>16) |
| 90 | #define dma_addr_lo32(addr) (uint32_t) (addr & 0xffffffff) |
| 91 | /* |
| 92 | ******************************************************************************* |
| 93 | ** MESSAGE CONTROL CODE |
| 94 | ******************************************************************************* |
| 95 | */ |
| 96 | struct CMD_MESSAGE |
| 97 | { |
| 98 | uint32_t HeaderLength; |
| 99 | uint8_t Signature[8]; |
| 100 | uint32_t Timeout; |
| 101 | uint32_t ControlCode; |
| 102 | uint32_t ReturnCode; |
| 103 | uint32_t Length; |
| 104 | }; |
| 105 | /* |
| 106 | ******************************************************************************* |
| 107 | ** IOP Message Transfer Data for user space |
| 108 | ******************************************************************************* |
| 109 | */ |
| 110 | struct CMD_MESSAGE_FIELD |
| 111 | { |
| 112 | struct CMD_MESSAGE cmdmessage; |
| 113 | uint8_t messagedatabuffer[1032]; |
| 114 | }; |
| 115 | /* IOP message transfer */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 116 | #define ARCMSR_MESSAGE_FAIL 0x0001 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 117 | /* DeviceType */ |
| 118 | #define ARECA_SATA_RAID 0x90000000 |
| 119 | /* FunctionCode */ |
| 120 | #define FUNCTION_READ_RQBUFFER 0x0801 |
| 121 | #define FUNCTION_WRITE_WQBUFFER 0x0802 |
| 122 | #define FUNCTION_CLEAR_RQBUFFER 0x0803 |
| 123 | #define FUNCTION_CLEAR_WQBUFFER 0x0804 |
| 124 | #define FUNCTION_CLEAR_ALLQBUFFER 0x0805 |
| 125 | #define FUNCTION_RETURN_CODE_3F 0x0806 |
| 126 | #define FUNCTION_SAY_HELLO 0x0807 |
| 127 | #define FUNCTION_SAY_GOODBYE 0x0808 |
| 128 | #define FUNCTION_FLUSH_ADAPTER_CACHE 0x0809 |
Nick Cheng | 36b83de | 2010-05-17 11:22:42 +0800 | [diff] [blame] | 129 | #define FUNCTION_GET_FIRMWARE_STATUS 0x080A |
| 130 | #define FUNCTION_HARDWARE_RESET 0x080B |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 131 | /* ARECA IO CONTROL CODE*/ |
| 132 | #define ARCMSR_MESSAGE_READ_RQBUFFER \ |
| 133 | ARECA_SATA_RAID | FUNCTION_READ_RQBUFFER |
| 134 | #define ARCMSR_MESSAGE_WRITE_WQBUFFER \ |
| 135 | ARECA_SATA_RAID | FUNCTION_WRITE_WQBUFFER |
| 136 | #define ARCMSR_MESSAGE_CLEAR_RQBUFFER \ |
| 137 | ARECA_SATA_RAID | FUNCTION_CLEAR_RQBUFFER |
| 138 | #define ARCMSR_MESSAGE_CLEAR_WQBUFFER \ |
| 139 | ARECA_SATA_RAID | FUNCTION_CLEAR_WQBUFFER |
| 140 | #define ARCMSR_MESSAGE_CLEAR_ALLQBUFFER \ |
| 141 | ARECA_SATA_RAID | FUNCTION_CLEAR_ALLQBUFFER |
| 142 | #define ARCMSR_MESSAGE_RETURN_CODE_3F \ |
| 143 | ARECA_SATA_RAID | FUNCTION_RETURN_CODE_3F |
| 144 | #define ARCMSR_MESSAGE_SAY_HELLO \ |
| 145 | ARECA_SATA_RAID | FUNCTION_SAY_HELLO |
| 146 | #define ARCMSR_MESSAGE_SAY_GOODBYE \ |
| 147 | ARECA_SATA_RAID | FUNCTION_SAY_GOODBYE |
| 148 | #define ARCMSR_MESSAGE_FLUSH_ADAPTER_CACHE \ |
| 149 | ARECA_SATA_RAID | FUNCTION_FLUSH_ADAPTER_CACHE |
| 150 | /* ARECA IOCTL ReturnCode */ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 151 | #define ARCMSR_MESSAGE_RETURNCODE_OK 0x00000001 |
| 152 | #define ARCMSR_MESSAGE_RETURNCODE_ERROR 0x00000006 |
| 153 | #define ARCMSR_MESSAGE_RETURNCODE_3F 0x0000003F |
Nick Cheng | 36b83de | 2010-05-17 11:22:42 +0800 | [diff] [blame] | 154 | #define ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON 0x00000088 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 155 | /* |
| 156 | ************************************************************* |
| 157 | ** structure for holding DMA address data |
| 158 | ************************************************************* |
| 159 | */ |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 160 | #define IS_DMA64 (sizeof(dma_addr_t) == 8) |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 161 | #define IS_SG64_ADDR 0x01000000 /* bit24 */ |
| 162 | struct SG32ENTRY |
| 163 | { |
Al Viro | 80da1ad | 2007-10-29 05:08:28 +0000 | [diff] [blame] | 164 | __le32 length; |
| 165 | __le32 address; |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 166 | }__attribute__ ((packed)); |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 167 | struct SG64ENTRY |
| 168 | { |
Al Viro | 80da1ad | 2007-10-29 05:08:28 +0000 | [diff] [blame] | 169 | __le32 length; |
| 170 | __le32 address; |
| 171 | __le32 addresshigh; |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 172 | }__attribute__ ((packed)); |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 173 | /* |
| 174 | ******************************************************************** |
| 175 | ** Q Buffer of IOP Message Transfer |
| 176 | ******************************************************************** |
| 177 | */ |
| 178 | struct QBUFFER |
| 179 | { |
| 180 | uint32_t data_len; |
| 181 | uint8_t data[124]; |
| 182 | }; |
| 183 | /* |
| 184 | ******************************************************************************* |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 185 | ** FIRMWARE INFO for Intel IOP R 80331 processor (Type A) |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 186 | ******************************************************************************* |
| 187 | */ |
| 188 | struct FIRMWARE_INFO |
| 189 | { |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 190 | uint32_t signature; /*0, 00-03*/ |
| 191 | uint32_t request_len; /*1, 04-07*/ |
| 192 | uint32_t numbers_queue; /*2, 08-11*/ |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 193 | uint32_t sdram_size; /*3, 12-15*/ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 194 | uint32_t ide_channels; /*4, 16-19*/ |
| 195 | char vendor[40]; /*5, 20-59*/ |
| 196 | char model[8]; /*15, 60-67*/ |
| 197 | char firmware_ver[16]; /*17, 68-83*/ |
| 198 | char device_map[16]; /*21, 84-99*/ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 199 | uint32_t cfgVersion; /*25,100-103 Added for checking of new firmware capability*/ |
| 200 | uint8_t cfgSerial[16]; /*26,104-119*/ |
| 201 | uint32_t cfgPicStatus; /*30,120-123*/ |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 202 | }; |
| 203 | /* signature of set and get firmware config */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 204 | #define ARCMSR_SIGNATURE_GET_CONFIG 0x87974060 |
| 205 | #define ARCMSR_SIGNATURE_SET_CONFIG 0x87974063 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 206 | /* message code of inbound message register */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 207 | #define ARCMSR_INBOUND_MESG0_NOP 0x00000000 |
| 208 | #define ARCMSR_INBOUND_MESG0_GET_CONFIG 0x00000001 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 209 | #define ARCMSR_INBOUND_MESG0_SET_CONFIG 0x00000002 |
| 210 | #define ARCMSR_INBOUND_MESG0_ABORT_CMD 0x00000003 |
| 211 | #define ARCMSR_INBOUND_MESG0_STOP_BGRB 0x00000004 |
| 212 | #define ARCMSR_INBOUND_MESG0_FLUSH_CACHE 0x00000005 |
| 213 | #define ARCMSR_INBOUND_MESG0_START_BGRB 0x00000006 |
| 214 | #define ARCMSR_INBOUND_MESG0_CHK331PENDING 0x00000007 |
| 215 | #define ARCMSR_INBOUND_MESG0_SYNC_TIMER 0x00000008 |
| 216 | /* doorbell interrupt generator */ |
| 217 | #define ARCMSR_INBOUND_DRIVER_DATA_WRITE_OK 0x00000001 |
| 218 | #define ARCMSR_INBOUND_DRIVER_DATA_READ_OK 0x00000002 |
| 219 | #define ARCMSR_OUTBOUND_IOP331_DATA_WRITE_OK 0x00000001 |
| 220 | #define ARCMSR_OUTBOUND_IOP331_DATA_READ_OK 0x00000002 |
| 221 | /* ccb areca cdb flag */ |
| 222 | #define ARCMSR_CCBPOST_FLAG_SGL_BSIZE 0x80000000 |
| 223 | #define ARCMSR_CCBPOST_FLAG_IAM_BIOS 0x40000000 |
| 224 | #define ARCMSR_CCBREPLY_FLAG_IAM_BIOS 0x40000000 |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 225 | #define ARCMSR_CCBREPLY_FLAG_ERROR_MODE0 0x10000000 |
| 226 | #define ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 0x00000001 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 227 | /* outbound firmware ok */ |
| 228 | #define ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK 0x80000000 |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 229 | /* ARC-1680 Bus Reset*/ |
| 230 | #define ARCMSR_ARC1680_BUS_RESET 0x00000003 |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 231 | /* ARC-1880 Bus Reset*/ |
| 232 | #define ARCMSR_ARC1880_RESET_ADAPTER 0x00000024 |
| 233 | #define ARCMSR_ARC1880_DiagWrite_ENABLE 0x00000080 |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 234 | |
| 235 | /* |
| 236 | ************************************************************************ |
| 237 | ** SPEC. for Areca Type B adapter |
| 238 | ************************************************************************ |
| 239 | */ |
| 240 | /* ARECA HBB COMMAND for its FIRMWARE */ |
| 241 | /* window of "instruction flags" from driver to iop */ |
| 242 | #define ARCMSR_DRV2IOP_DOORBELL 0x00020400 |
| 243 | #define ARCMSR_DRV2IOP_DOORBELL_MASK 0x00020404 |
| 244 | /* window of "instruction flags" from iop to driver */ |
| 245 | #define ARCMSR_IOP2DRV_DOORBELL 0x00020408 |
| 246 | #define ARCMSR_IOP2DRV_DOORBELL_MASK 0x0002040C |
| 247 | /* ARECA FLAG LANGUAGE */ |
| 248 | /* ioctl transfer */ |
| 249 | #define ARCMSR_IOP2DRV_DATA_WRITE_OK 0x00000001 |
| 250 | /* ioctl transfer */ |
| 251 | #define ARCMSR_IOP2DRV_DATA_READ_OK 0x00000002 |
| 252 | #define ARCMSR_IOP2DRV_CDB_DONE 0x00000004 |
| 253 | #define ARCMSR_IOP2DRV_MESSAGE_CMD_DONE 0x00000008 |
| 254 | |
| 255 | #define ARCMSR_DOORBELL_HANDLE_INT 0x0000000F |
| 256 | #define ARCMSR_DOORBELL_INT_CLEAR_PATTERN 0xFF00FFF0 |
| 257 | #define ARCMSR_MESSAGE_INT_CLEAR_PATTERN 0xFF00FFF7 |
| 258 | /* (ARCMSR_INBOUND_MESG0_GET_CONFIG<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */ |
| 259 | #define ARCMSR_MESSAGE_GET_CONFIG 0x00010008 |
| 260 | /* (ARCMSR_INBOUND_MESG0_SET_CONFIG<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */ |
| 261 | #define ARCMSR_MESSAGE_SET_CONFIG 0x00020008 |
| 262 | /* (ARCMSR_INBOUND_MESG0_ABORT_CMD<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */ |
| 263 | #define ARCMSR_MESSAGE_ABORT_CMD 0x00030008 |
| 264 | /* (ARCMSR_INBOUND_MESG0_STOP_BGRB<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */ |
| 265 | #define ARCMSR_MESSAGE_STOP_BGRB 0x00040008 |
| 266 | /* (ARCMSR_INBOUND_MESG0_FLUSH_CACHE<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */ |
| 267 | #define ARCMSR_MESSAGE_FLUSH_CACHE 0x00050008 |
| 268 | /* (ARCMSR_INBOUND_MESG0_START_BGRB<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */ |
| 269 | #define ARCMSR_MESSAGE_START_BGRB 0x00060008 |
| 270 | #define ARCMSR_MESSAGE_START_DRIVER_MODE 0x000E0008 |
| 271 | #define ARCMSR_MESSAGE_SET_POST_WINDOW 0x000F0008 |
Nick Cheng | 76d7830 | 2008-02-04 23:53:24 -0800 | [diff] [blame] | 272 | #define ARCMSR_MESSAGE_ACTIVE_EOI_MODE 0x00100008 |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 273 | /* ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK */ |
| 274 | #define ARCMSR_MESSAGE_FIRMWARE_OK 0x80000000 |
| 275 | /* ioctl transfer */ |
| 276 | #define ARCMSR_DRV2IOP_DATA_WRITE_OK 0x00000001 |
| 277 | /* ioctl transfer */ |
| 278 | #define ARCMSR_DRV2IOP_DATA_READ_OK 0x00000002 |
| 279 | #define ARCMSR_DRV2IOP_CDB_POSTED 0x00000004 |
| 280 | #define ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED 0x00000008 |
Nick Cheng | 76d7830 | 2008-02-04 23:53:24 -0800 | [diff] [blame] | 281 | #define ARCMSR_DRV2IOP_END_OF_INTERRUPT 0x00000010 |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 282 | |
| 283 | /* data tunnel buffer between user space program and its firmware */ |
| 284 | /* user space data to iop 128bytes */ |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 285 | #define ARCMSR_MESSAGE_WBUFFER 0x0000fe00 |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 286 | /* iop data to user space 128bytes */ |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 287 | #define ARCMSR_MESSAGE_RBUFFER 0x0000ff00 |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 288 | /* iop message_rwbuffer for message command */ |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 289 | #define ARCMSR_MESSAGE_RWBUFFER 0x0000fa00 |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 290 | /* |
| 291 | ************************************************************************ |
| 292 | ** SPEC. for Areca HBC adapter |
| 293 | ************************************************************************ |
| 294 | */ |
| 295 | #define ARCMSR_HBC_ISR_THROTTLING_LEVEL 12 |
| 296 | #define ARCMSR_HBC_ISR_MAX_DONE_QUEUE 20 |
| 297 | /* Host Interrupt Mask */ |
| 298 | #define ARCMSR_HBCMU_UTILITY_A_ISR_MASK 0x00000001 /* When clear, the Utility_A interrupt routes to the host.*/ |
| 299 | #define ARCMSR_HBCMU_OUTBOUND_DOORBELL_ISR_MASK 0x00000004 /* When clear, the General Outbound Doorbell interrupt routes to the host.*/ |
| 300 | #define ARCMSR_HBCMU_OUTBOUND_POSTQUEUE_ISR_MASK 0x00000008 /* When clear, the Outbound Post List FIFO Not Empty interrupt routes to the host.*/ |
| 301 | #define ARCMSR_HBCMU_ALL_INTMASKENABLE 0x0000000D /* disable all ISR */ |
| 302 | /* Host Interrupt Status */ |
| 303 | #define ARCMSR_HBCMU_UTILITY_A_ISR 0x00000001 |
| 304 | /* |
| 305 | ** Set when the Utility_A Interrupt bit is set in the Outbound Doorbell Register. |
| 306 | ** It clears by writing a 1 to the Utility_A bit in the Outbound Doorbell Clear Register or through automatic clearing (if enabled). |
| 307 | */ |
| 308 | #define ARCMSR_HBCMU_OUTBOUND_DOORBELL_ISR 0x00000004 |
| 309 | /* |
| 310 | ** Set if Outbound Doorbell register bits 30:1 have a non-zero |
| 311 | ** value. This bit clears only when Outbound Doorbell bits |
| 312 | ** 30:1 are ALL clear. Only a write to the Outbound Doorbell |
| 313 | ** Clear register clears bits in the Outbound Doorbell register. |
| 314 | */ |
| 315 | #define ARCMSR_HBCMU_OUTBOUND_POSTQUEUE_ISR 0x00000008 |
| 316 | /* |
| 317 | ** Set whenever the Outbound Post List Producer/Consumer |
| 318 | ** Register (FIFO) is not empty. It clears when the Outbound |
| 319 | ** Post List FIFO is empty. |
| 320 | */ |
| 321 | #define ARCMSR_HBCMU_SAS_ALL_INT 0x00000010 |
| 322 | /* |
| 323 | ** This bit indicates a SAS interrupt from a source external to |
| 324 | ** the PCIe core. This bit is not maskable. |
| 325 | */ |
| 326 | /* DoorBell*/ |
| 327 | #define ARCMSR_HBCMU_DRV2IOP_DATA_WRITE_OK 0x00000002 |
| 328 | #define ARCMSR_HBCMU_DRV2IOP_DATA_READ_OK 0x00000004 |
| 329 | /*inbound message 0 ready*/ |
| 330 | #define ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE 0x00000008 |
| 331 | /*more than 12 request completed in a time*/ |
| 332 | #define ARCMSR_HBCMU_DRV2IOP_POSTQUEUE_THROTTLING 0x00000010 |
| 333 | #define ARCMSR_HBCMU_IOP2DRV_DATA_WRITE_OK 0x00000002 |
| 334 | /*outbound DATA WRITE isr door bell clear*/ |
| 335 | #define ARCMSR_HBCMU_IOP2DRV_DATA_WRITE_DOORBELL_CLEAR 0x00000002 |
| 336 | #define ARCMSR_HBCMU_IOP2DRV_DATA_READ_OK 0x00000004 |
| 337 | /*outbound DATA READ isr door bell clear*/ |
| 338 | #define ARCMSR_HBCMU_IOP2DRV_DATA_READ_DOORBELL_CLEAR 0x00000004 |
| 339 | /*outbound message 0 ready*/ |
| 340 | #define ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE 0x00000008 |
| 341 | /*outbound message cmd isr door bell clear*/ |
| 342 | #define ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE_DOORBELL_CLEAR 0x00000008 |
| 343 | /*ARCMSR_HBAMU_MESSAGE_FIRMWARE_OK*/ |
| 344 | #define ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK 0x80000000 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 345 | /* |
| 346 | ******************************************************************************* |
Ching Huang | 5b37479 | 2014-08-19 15:25:22 +0800 | [diff] [blame^] | 347 | ** SPEC. for Areca Type D adapter |
| 348 | ******************************************************************************* |
| 349 | */ |
| 350 | #define ARCMSR_ARC1214_CHIP_ID 0x00004 |
| 351 | #define ARCMSR_ARC1214_CPU_MEMORY_CONFIGURATION 0x00008 |
| 352 | #define ARCMSR_ARC1214_I2_HOST_INTERRUPT_MASK 0x00034 |
| 353 | #define ARCMSR_ARC1214_SAMPLE_RESET 0x00100 |
| 354 | #define ARCMSR_ARC1214_RESET_REQUEST 0x00108 |
| 355 | #define ARCMSR_ARC1214_MAIN_INTERRUPT_STATUS 0x00200 |
| 356 | #define ARCMSR_ARC1214_PCIE_F0_INTERRUPT_ENABLE 0x0020C |
| 357 | #define ARCMSR_ARC1214_INBOUND_MESSAGE0 0x00400 |
| 358 | #define ARCMSR_ARC1214_INBOUND_MESSAGE1 0x00404 |
| 359 | #define ARCMSR_ARC1214_OUTBOUND_MESSAGE0 0x00420 |
| 360 | #define ARCMSR_ARC1214_OUTBOUND_MESSAGE1 0x00424 |
| 361 | #define ARCMSR_ARC1214_INBOUND_DOORBELL 0x00460 |
| 362 | #define ARCMSR_ARC1214_OUTBOUND_DOORBELL 0x00480 |
| 363 | #define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ENABLE 0x00484 |
| 364 | #define ARCMSR_ARC1214_INBOUND_LIST_BASE_LOW 0x01000 |
| 365 | #define ARCMSR_ARC1214_INBOUND_LIST_BASE_HIGH 0x01004 |
| 366 | #define ARCMSR_ARC1214_INBOUND_LIST_WRITE_POINTER 0x01018 |
| 367 | #define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_LOW 0x01060 |
| 368 | #define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_HIGH 0x01064 |
| 369 | #define ARCMSR_ARC1214_OUTBOUND_LIST_COPY_POINTER 0x0106C |
| 370 | #define ARCMSR_ARC1214_OUTBOUND_LIST_READ_POINTER 0x01070 |
| 371 | #define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_CAUSE 0x01088 |
| 372 | #define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_ENABLE 0x0108C |
| 373 | #define ARCMSR_ARC1214_MESSAGE_WBUFFER 0x02000 |
| 374 | #define ARCMSR_ARC1214_MESSAGE_RBUFFER 0x02100 |
| 375 | #define ARCMSR_ARC1214_MESSAGE_RWBUFFER 0x02200 |
| 376 | /* Host Interrupt Mask */ |
| 377 | #define ARCMSR_ARC1214_ALL_INT_ENABLE 0x00001010 |
| 378 | #define ARCMSR_ARC1214_ALL_INT_DISABLE 0x00000000 |
| 379 | /* Host Interrupt Status */ |
| 380 | #define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ISR 0x00001000 |
| 381 | #define ARCMSR_ARC1214_OUTBOUND_POSTQUEUE_ISR 0x00000010 |
| 382 | /* DoorBell*/ |
| 383 | #define ARCMSR_ARC1214_DRV2IOP_DATA_IN_READY 0x00000001 |
| 384 | #define ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ 0x00000002 |
| 385 | /*inbound message 0 ready*/ |
| 386 | #define ARCMSR_ARC1214_IOP2DRV_DATA_WRITE_OK 0x00000001 |
| 387 | /*outbound DATA WRITE isr door bell clear*/ |
| 388 | #define ARCMSR_ARC1214_IOP2DRV_DATA_READ_OK 0x00000002 |
| 389 | /*outbound message 0 ready*/ |
| 390 | #define ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE 0x02000000 |
| 391 | /*outbound message cmd isr door bell clear*/ |
| 392 | /*ARCMSR_HBAMU_MESSAGE_FIRMWARE_OK*/ |
| 393 | #define ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK 0x80000000 |
| 394 | #define ARCMSR_ARC1214_OUTBOUND_LIST_INTERRUPT_CLEAR 0x00000001 |
| 395 | /* |
| 396 | ******************************************************************************* |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 397 | ** ARECA SCSI COMMAND DESCRIPTOR BLOCK size 0x1F8 (504) |
| 398 | ******************************************************************************* |
| 399 | */ |
| 400 | struct ARCMSR_CDB |
| 401 | { |
| 402 | uint8_t Bus; |
| 403 | uint8_t TargetID; |
| 404 | uint8_t LUN; |
| 405 | uint8_t Function; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 406 | uint8_t CdbLength; |
| 407 | uint8_t sgcount; |
| 408 | uint8_t Flags; |
| 409 | #define ARCMSR_CDB_FLAG_SGL_BSIZE 0x01 |
| 410 | #define ARCMSR_CDB_FLAG_BIOS 0x02 |
| 411 | #define ARCMSR_CDB_FLAG_WRITE 0x04 |
| 412 | #define ARCMSR_CDB_FLAG_SIMPLEQ 0x00 |
| 413 | #define ARCMSR_CDB_FLAG_HEADQ 0x08 |
| 414 | #define ARCMSR_CDB_FLAG_ORDEREDQ 0x10 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 415 | |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 416 | uint8_t msgPages; |
Ching Huang | 626fa32 | 2014-08-19 15:10:12 +0800 | [diff] [blame] | 417 | uint32_t msgContext; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 418 | uint32_t DataLength; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 419 | uint8_t Cdb[16]; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 420 | uint8_t DeviceStatus; |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 421 | #define ARCMSR_DEV_CHECK_CONDITION 0x02 |
| 422 | #define ARCMSR_DEV_SELECT_TIMEOUT 0xF0 |
| 423 | #define ARCMSR_DEV_ABORTED 0xF1 |
| 424 | #define ARCMSR_DEV_INIT_FAIL 0xF2 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 425 | |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 426 | uint8_t SenseData[15]; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 427 | union |
| 428 | { |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 429 | struct SG32ENTRY sg32entry[1]; |
| 430 | struct SG64ENTRY sg64entry[1]; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 431 | } u; |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 432 | }; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 433 | /* |
| 434 | ******************************************************************************* |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 435 | ** Messaging Unit (MU) of the Intel R 80331 I/O processor(Type A) and Type B processor |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 436 | ******************************************************************************* |
| 437 | */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 438 | struct MessageUnit_A |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 439 | { |
| 440 | uint32_t resrved0[4]; /*0000 000F*/ |
| 441 | uint32_t inbound_msgaddr0; /*0010 0013*/ |
| 442 | uint32_t inbound_msgaddr1; /*0014 0017*/ |
| 443 | uint32_t outbound_msgaddr0; /*0018 001B*/ |
| 444 | uint32_t outbound_msgaddr1; /*001C 001F*/ |
| 445 | uint32_t inbound_doorbell; /*0020 0023*/ |
| 446 | uint32_t inbound_intstatus; /*0024 0027*/ |
| 447 | uint32_t inbound_intmask; /*0028 002B*/ |
| 448 | uint32_t outbound_doorbell; /*002C 002F*/ |
| 449 | uint32_t outbound_intstatus; /*0030 0033*/ |
| 450 | uint32_t outbound_intmask; /*0034 0037*/ |
| 451 | uint32_t reserved1[2]; /*0038 003F*/ |
| 452 | uint32_t inbound_queueport; /*0040 0043*/ |
| 453 | uint32_t outbound_queueport; /*0044 0047*/ |
| 454 | uint32_t reserved2[2]; /*0048 004F*/ |
| 455 | uint32_t reserved3[492]; /*0050 07FF 492*/ |
| 456 | uint32_t reserved4[128]; /*0800 09FF 128*/ |
| 457 | uint32_t message_rwbuffer[256]; /*0a00 0DFF 256*/ |
| 458 | uint32_t message_wbuffer[32]; /*0E00 0E7F 32*/ |
| 459 | uint32_t reserved5[32]; /*0E80 0EFF 32*/ |
| 460 | uint32_t message_rbuffer[32]; /*0F00 0F7F 32*/ |
| 461 | uint32_t reserved6[32]; /*0F80 0FFF 32*/ |
| 462 | }; |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 463 | |
| 464 | struct MessageUnit_B |
| 465 | { |
| 466 | uint32_t post_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE]; |
| 467 | uint32_t done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE]; |
| 468 | uint32_t postq_index; |
| 469 | uint32_t doneq_index; |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 470 | uint32_t __iomem *drv2iop_doorbell; |
| 471 | uint32_t __iomem *drv2iop_doorbell_mask; |
| 472 | uint32_t __iomem *iop2drv_doorbell; |
| 473 | uint32_t __iomem *iop2drv_doorbell_mask; |
| 474 | uint32_t __iomem *message_rwbuffer; |
| 475 | uint32_t __iomem *message_wbuffer; |
| 476 | uint32_t __iomem *message_rbuffer; |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 477 | }; |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 478 | /* |
| 479 | ********************************************************************* |
| 480 | ** LSI |
| 481 | ********************************************************************* |
| 482 | */ |
| 483 | struct MessageUnit_C{ |
| 484 | uint32_t message_unit_status; /*0000 0003*/ |
| 485 | uint32_t slave_error_attribute; /*0004 0007*/ |
| 486 | uint32_t slave_error_address; /*0008 000B*/ |
| 487 | uint32_t posted_outbound_doorbell; /*000C 000F*/ |
| 488 | uint32_t master_error_attribute; /*0010 0013*/ |
| 489 | uint32_t master_error_address_low; /*0014 0017*/ |
| 490 | uint32_t master_error_address_high; /*0018 001B*/ |
| 491 | uint32_t hcb_size; /*001C 001F*/ |
| 492 | uint32_t inbound_doorbell; /*0020 0023*/ |
| 493 | uint32_t diagnostic_rw_data; /*0024 0027*/ |
| 494 | uint32_t diagnostic_rw_address_low; /*0028 002B*/ |
| 495 | uint32_t diagnostic_rw_address_high; /*002C 002F*/ |
| 496 | uint32_t host_int_status; /*0030 0033*/ |
| 497 | uint32_t host_int_mask; /*0034 0037*/ |
| 498 | uint32_t dcr_data; /*0038 003B*/ |
| 499 | uint32_t dcr_address; /*003C 003F*/ |
| 500 | uint32_t inbound_queueport; /*0040 0043*/ |
| 501 | uint32_t outbound_queueport; /*0044 0047*/ |
| 502 | uint32_t hcb_pci_address_low; /*0048 004B*/ |
| 503 | uint32_t hcb_pci_address_high; /*004C 004F*/ |
| 504 | uint32_t iop_int_status; /*0050 0053*/ |
| 505 | uint32_t iop_int_mask; /*0054 0057*/ |
| 506 | uint32_t iop_inbound_queue_port; /*0058 005B*/ |
| 507 | uint32_t iop_outbound_queue_port; /*005C 005F*/ |
| 508 | uint32_t inbound_free_list_index; /*0060 0063*/ |
| 509 | uint32_t inbound_post_list_index; /*0064 0067*/ |
| 510 | uint32_t outbound_free_list_index; /*0068 006B*/ |
| 511 | uint32_t outbound_post_list_index; /*006C 006F*/ |
| 512 | uint32_t inbound_doorbell_clear; /*0070 0073*/ |
| 513 | uint32_t i2o_message_unit_control; /*0074 0077*/ |
| 514 | uint32_t last_used_message_source_address_low; /*0078 007B*/ |
| 515 | uint32_t last_used_message_source_address_high; /*007C 007F*/ |
| 516 | uint32_t pull_mode_data_byte_count[4]; /*0080 008F*/ |
| 517 | uint32_t message_dest_address_index; /*0090 0093*/ |
| 518 | uint32_t done_queue_not_empty_int_counter_timer; /*0094 0097*/ |
| 519 | uint32_t utility_A_int_counter_timer; /*0098 009B*/ |
| 520 | uint32_t outbound_doorbell; /*009C 009F*/ |
| 521 | uint32_t outbound_doorbell_clear; /*00A0 00A3*/ |
| 522 | uint32_t message_source_address_index; /*00A4 00A7*/ |
| 523 | uint32_t message_done_queue_index; /*00A8 00AB*/ |
| 524 | uint32_t reserved0; /*00AC 00AF*/ |
| 525 | uint32_t inbound_msgaddr0; /*00B0 00B3*/ |
| 526 | uint32_t inbound_msgaddr1; /*00B4 00B7*/ |
| 527 | uint32_t outbound_msgaddr0; /*00B8 00BB*/ |
| 528 | uint32_t outbound_msgaddr1; /*00BC 00BF*/ |
| 529 | uint32_t inbound_queueport_low; /*00C0 00C3*/ |
| 530 | uint32_t inbound_queueport_high; /*00C4 00C7*/ |
| 531 | uint32_t outbound_queueport_low; /*00C8 00CB*/ |
| 532 | uint32_t outbound_queueport_high; /*00CC 00CF*/ |
| 533 | uint32_t iop_inbound_queue_port_low; /*00D0 00D3*/ |
| 534 | uint32_t iop_inbound_queue_port_high; /*00D4 00D7*/ |
| 535 | uint32_t iop_outbound_queue_port_low; /*00D8 00DB*/ |
| 536 | uint32_t iop_outbound_queue_port_high; /*00DC 00DF*/ |
| 537 | uint32_t message_dest_queue_port_low; /*00E0 00E3*/ |
| 538 | uint32_t message_dest_queue_port_high; /*00E4 00E7*/ |
| 539 | uint32_t last_used_message_dest_address_low; /*00E8 00EB*/ |
| 540 | uint32_t last_used_message_dest_address_high; /*00EC 00EF*/ |
| 541 | uint32_t message_done_queue_base_address_low; /*00F0 00F3*/ |
| 542 | uint32_t message_done_queue_base_address_high; /*00F4 00F7*/ |
| 543 | uint32_t host_diagnostic; /*00F8 00FB*/ |
| 544 | uint32_t write_sequence; /*00FC 00FF*/ |
| 545 | uint32_t reserved1[34]; /*0100 0187*/ |
| 546 | uint32_t reserved2[1950]; /*0188 1FFF*/ |
| 547 | uint32_t message_wbuffer[32]; /*2000 207F*/ |
| 548 | uint32_t reserved3[32]; /*2080 20FF*/ |
| 549 | uint32_t message_rbuffer[32]; /*2100 217F*/ |
| 550 | uint32_t reserved4[32]; /*2180 21FF*/ |
| 551 | uint32_t msgcode_rwbuffer[256]; /*2200 23FF*/ |
| 552 | }; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 553 | /* |
Ching Huang | 5b37479 | 2014-08-19 15:25:22 +0800 | [diff] [blame^] | 554 | ********************************************************************* |
| 555 | ** Messaging Unit (MU) of Type D processor |
| 556 | ********************************************************************* |
| 557 | */ |
| 558 | struct InBound_SRB { |
| 559 | uint32_t addressLow; /* pointer to SRB block */ |
| 560 | uint32_t addressHigh; |
| 561 | uint32_t length; /* in DWORDs */ |
| 562 | uint32_t reserved0; |
| 563 | }; |
| 564 | |
| 565 | struct OutBound_SRB { |
| 566 | uint32_t addressLow; /* pointer to SRB block */ |
| 567 | uint32_t addressHigh; |
| 568 | }; |
| 569 | |
| 570 | struct MessageUnit_D { |
| 571 | struct InBound_SRB post_qbuffer[ARCMSR_MAX_ARC1214_POSTQUEUE]; |
| 572 | volatile struct OutBound_SRB |
| 573 | done_qbuffer[ARCMSR_MAX_ARC1214_DONEQUEUE]; |
| 574 | u16 postq_index; |
| 575 | volatile u16 doneq_index; |
| 576 | u32 __iomem *chip_id; /* 0x00004 */ |
| 577 | u32 __iomem *cpu_mem_config; /* 0x00008 */ |
| 578 | u32 __iomem *i2o_host_interrupt_mask; /* 0x00034 */ |
| 579 | u32 __iomem *sample_at_reset; /* 0x00100 */ |
| 580 | u32 __iomem *reset_request; /* 0x00108 */ |
| 581 | u32 __iomem *host_int_status; /* 0x00200 */ |
| 582 | u32 __iomem *pcief0_int_enable; /* 0x0020C */ |
| 583 | u32 __iomem *inbound_msgaddr0; /* 0x00400 */ |
| 584 | u32 __iomem *inbound_msgaddr1; /* 0x00404 */ |
| 585 | u32 __iomem *outbound_msgaddr0; /* 0x00420 */ |
| 586 | u32 __iomem *outbound_msgaddr1; /* 0x00424 */ |
| 587 | u32 __iomem *inbound_doorbell; /* 0x00460 */ |
| 588 | u32 __iomem *outbound_doorbell; /* 0x00480 */ |
| 589 | u32 __iomem *outbound_doorbell_enable; /* 0x00484 */ |
| 590 | u32 __iomem *inboundlist_base_low; /* 0x01000 */ |
| 591 | u32 __iomem *inboundlist_base_high; /* 0x01004 */ |
| 592 | u32 __iomem *inboundlist_write_pointer; /* 0x01018 */ |
| 593 | u32 __iomem *outboundlist_base_low; /* 0x01060 */ |
| 594 | u32 __iomem *outboundlist_base_high; /* 0x01064 */ |
| 595 | u32 __iomem *outboundlist_copy_pointer; /* 0x0106C */ |
| 596 | u32 __iomem *outboundlist_read_pointer; /* 0x01070 0x01072 */ |
| 597 | u32 __iomem *outboundlist_interrupt_cause; /* 0x1088 */ |
| 598 | u32 __iomem *outboundlist_interrupt_enable; /* 0x108C */ |
| 599 | u32 __iomem *message_wbuffer; /* 0x2000 */ |
| 600 | u32 __iomem *message_rbuffer; /* 0x2100 */ |
| 601 | u32 __iomem *msgcode_rwbuffer; /* 0x2200 */ |
| 602 | }; |
| 603 | /* |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 604 | ******************************************************************************* |
| 605 | ** Adapter Control Block |
| 606 | ******************************************************************************* |
| 607 | */ |
| 608 | struct AdapterControlBlock |
| 609 | { |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 610 | uint32_t adapter_type; /* adapter A,B..... */ |
| 611 | #define ACB_ADAPTER_TYPE_A 0x00000001 /* hba I IOP */ |
| 612 | #define ACB_ADAPTER_TYPE_B 0x00000002 /* hbb M IOP */ |
| 613 | #define ACB_ADAPTER_TYPE_C 0x00000004 /* hbc P IOP */ |
| 614 | #define ACB_ADAPTER_TYPE_D 0x00000008 /* hbd A IOP */ |
Ching Huang | 6e38adf | 2014-08-19 15:14:14 +0800 | [diff] [blame] | 615 | u32 roundup_ccbsize; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 616 | struct pci_dev * pdev; |
| 617 | struct Scsi_Host * host; |
| 618 | unsigned long vir2phy_offset; |
Ching Huang | 1d1166e | 2014-08-19 14:23:31 +0800 | [diff] [blame] | 619 | struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS]; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 620 | /* Offset is used in making arc cdb physical to virtual calculations */ |
| 621 | uint32_t outbound_int_enable; |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 622 | uint32_t cdb_phyaddr_hi32; |
| 623 | uint32_t reg_mu_acc_handle0; |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 624 | spinlock_t eh_lock; |
| 625 | spinlock_t ccblist_lock; |
Ching Huang | 5b37479 | 2014-08-19 15:25:22 +0800 | [diff] [blame^] | 626 | spinlock_t postq_lock; |
| 627 | spinlock_t doneq_lock; |
Ching Huang | bb263c4 | 2014-08-19 15:17:45 +0800 | [diff] [blame] | 628 | spinlock_t rqbuffer_lock; |
| 629 | spinlock_t wqbuffer_lock; |
Al Viro | 80da1ad | 2007-10-29 05:08:28 +0000 | [diff] [blame] | 630 | union { |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 631 | struct MessageUnit_A __iomem *pmuA; |
| 632 | struct MessageUnit_B *pmuB; |
| 633 | struct MessageUnit_C __iomem *pmuC; |
Ching Huang | 5b37479 | 2014-08-19 15:25:22 +0800 | [diff] [blame^] | 634 | struct MessageUnit_D *pmuD; |
Al Viro | 80da1ad | 2007-10-29 05:08:28 +0000 | [diff] [blame] | 635 | }; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 636 | /* message unit ATU inbound base address0 */ |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 637 | void __iomem *mem_base0; |
| 638 | void __iomem *mem_base1; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 639 | uint32_t acb_flags; |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 640 | u16 dev_id; |
Nick Cheng | 36b83de | 2010-05-17 11:22:42 +0800 | [diff] [blame] | 641 | uint8_t adapter_index; |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 642 | #define ACB_F_SCSISTOPADAPTER 0x0001 |
| 643 | #define ACB_F_MSG_STOP_BGRB 0x0002 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 644 | /* stop RAID background rebuild */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 645 | #define ACB_F_MSG_START_BGRB 0x0004 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 646 | /* stop RAID background rebuild */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 647 | #define ACB_F_IOPDATA_OVERFLOW 0x0008 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 648 | /* iop message data rqbuffer overflow */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 649 | #define ACB_F_MESSAGE_WQBUFFER_CLEARED 0x0010 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 650 | /* message clear wqbuffer */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 651 | #define ACB_F_MESSAGE_RQBUFFER_CLEARED 0x0020 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 652 | /* message clear rqbuffer */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 653 | #define ACB_F_MESSAGE_WQBUFFER_READED 0x0040 |
| 654 | #define ACB_F_BUS_RESET 0x0080 |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 655 | #define ACB_F_BUS_HANG_ON 0x0800/* need hardware reset bus */ |
| 656 | |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 657 | #define ACB_F_IOP_INITED 0x0100 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 658 | /* iop init */ |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 659 | #define ACB_F_ABORT 0x0200 |
Nick Cheng | 36b83de | 2010-05-17 11:22:42 +0800 | [diff] [blame] | 660 | #define ACB_F_FIRMWARE_TRAP 0x0400 |
Ching Huang | 1d1166e | 2014-08-19 14:23:31 +0800 | [diff] [blame] | 661 | #define ACB_F_MSI_ENABLED 0x1000 |
| 662 | #define ACB_F_MSIX_ENABLED 0x2000 |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 663 | struct CommandControlBlock * pccb_pool[ARCMSR_MAX_FREECCB_NUM]; |
| 664 | /* used for memory free */ |
| 665 | struct list_head ccb_free_list; |
| 666 | /* head of free ccb list */ |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 667 | |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 668 | atomic_t ccboutstandingcount; |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 669 | /*The present outstanding command number that in the IOP that |
| 670 | waiting for being handled by FW*/ |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 671 | |
| 672 | void * dma_coherent; |
| 673 | /* dma_coherent used for memory free */ |
| 674 | dma_addr_t dma_coherent_handle; |
| 675 | /* dma_coherent_handle used for memory free */ |
Ching Huang | 626fa32 | 2014-08-19 15:10:12 +0800 | [diff] [blame] | 676 | dma_addr_t dma_coherent_handle2; |
Ching Huang | 6e38adf | 2014-08-19 15:14:14 +0800 | [diff] [blame] | 677 | void *dma_coherent2; |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 678 | unsigned int uncache_size; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 679 | uint8_t rqbuffer[ARCMSR_MAX_QBUFFER]; |
| 680 | /* data collection buffer for read from 80331 */ |
| 681 | int32_t rqbuf_firstindex; |
| 682 | /* first of read buffer */ |
| 683 | int32_t rqbuf_lastindex; |
| 684 | /* last of read buffer */ |
| 685 | uint8_t wqbuffer[ARCMSR_MAX_QBUFFER]; |
| 686 | /* data collection buffer for write to 80331 */ |
| 687 | int32_t wqbuf_firstindex; |
| 688 | /* first of write buffer */ |
| 689 | int32_t wqbuf_lastindex; |
| 690 | /* last of write buffer */ |
| 691 | uint8_t devstate[ARCMSR_MAX_TARGETID][ARCMSR_MAX_TARGETLUN]; |
| 692 | /* id0 ..... id15, lun0...lun7 */ |
| 693 | #define ARECA_RAID_GONE 0x55 |
| 694 | #define ARECA_RAID_GOOD 0xaa |
| 695 | uint32_t num_resets; |
| 696 | uint32_t num_aborts; |
Nick Cheng | 36b83de | 2010-05-17 11:22:42 +0800 | [diff] [blame] | 697 | uint32_t signature; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 698 | uint32_t firm_request_len; |
| 699 | uint32_t firm_numbers_queue; |
| 700 | uint32_t firm_sdram_size; |
| 701 | uint32_t firm_hd_channels; |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 702 | uint32_t firm_cfg_version; |
| 703 | char firm_model[12]; |
| 704 | char firm_version[20]; |
Nick Cheng | 36b83de | 2010-05-17 11:22:42 +0800 | [diff] [blame] | 705 | char device_map[20]; /*21,84-99*/ |
| 706 | struct work_struct arcmsr_do_message_isr_bh; |
| 707 | struct timer_list eternal_timer; |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 708 | unsigned short fw_flag; |
| 709 | #define FW_NORMAL 0x0000 |
| 710 | #define FW_BOG 0x0001 |
| 711 | #define FW_DEADLOCK 0x0010 |
Nick Cheng | 36b83de | 2010-05-17 11:22:42 +0800 | [diff] [blame] | 712 | atomic_t rq_map_token; |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 713 | atomic_t ante_token_value; |
Ching Huang | 3df824a | 2014-08-19 14:29:41 +0800 | [diff] [blame] | 714 | uint32_t maxOutstanding; |
Ching Huang | 1d1166e | 2014-08-19 14:23:31 +0800 | [diff] [blame] | 715 | int msix_vector_count; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 716 | };/* HW_DEVICE_EXTENSION */ |
| 717 | /* |
| 718 | ******************************************************************************* |
| 719 | ** Command Control Block |
| 720 | ** this CCB length must be 32 bytes boundary |
| 721 | ******************************************************************************* |
| 722 | */ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 723 | struct CommandControlBlock{ |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 724 | /*x32:sizeof struct_CCB=(32+60)byte, x64:sizeof struct_CCB=(64+60)byte*/ |
| 725 | struct list_head list; /*x32: 8byte, x64: 16byte*/ |
| 726 | struct scsi_cmnd *pcmd; /*8 bytes pointer of linux scsi command */ |
| 727 | struct AdapterControlBlock *acb; /*x32: 4byte, x64: 8byte*/ |
Ching Huang | 626fa32 | 2014-08-19 15:10:12 +0800 | [diff] [blame] | 728 | uint32_t cdb_phyaddr; /*x32: 4byte, x64: 4byte*/ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 729 | uint32_t arc_cdb_size; /*x32:4byte,x64:4byte*/ |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 730 | uint16_t ccb_flags; /*x32: 2byte, x64: 2byte*/ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 731 | #define CCB_FLAG_READ 0x0000 |
| 732 | #define CCB_FLAG_WRITE 0x0001 |
| 733 | #define CCB_FLAG_ERROR 0x0002 |
| 734 | #define CCB_FLAG_FLUSHCACHE 0x0004 |
| 735 | #define CCB_FLAG_MASTER_ABORTED 0x0008 |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 736 | uint16_t startdone; /*x32:2byte,x32:2byte*/ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 737 | #define ARCMSR_CCB_DONE 0x0000 |
| 738 | #define ARCMSR_CCB_START 0x55AA |
| 739 | #define ARCMSR_CCB_ABORTED 0xAA55 |
| 740 | #define ARCMSR_CCB_ILLEGAL 0xFFFF |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 741 | #if BITS_PER_LONG == 64 |
| 742 | /* ======================512+64 bytes======================== */ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 743 | uint32_t reserved[5]; /*24 byte*/ |
| 744 | #else |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 745 | /* ======================512+32 bytes======================== */ |
Nick Cheng | cdd3cb1 | 2010-07-13 20:03:04 +0800 | [diff] [blame] | 746 | uint32_t reserved; /*8 byte*/ |
| 747 | #endif |
Nick Cheng | ae52e7f | 2010-06-18 15:39:12 +0800 | [diff] [blame] | 748 | /* ======================================================= */ |
| 749 | struct ARCMSR_CDB arcmsr_cdb; |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 750 | }; |
| 751 | /* |
| 752 | ******************************************************************************* |
| 753 | ** ARECA SCSI sense data |
| 754 | ******************************************************************************* |
| 755 | */ |
| 756 | struct SENSE_DATA |
| 757 | { |
| 758 | uint8_t ErrorCode:7; |
| 759 | #define SCSI_SENSE_CURRENT_ERRORS 0x70 |
| 760 | #define SCSI_SENSE_DEFERRED_ERRORS 0x71 |
| 761 | uint8_t Valid:1; |
| 762 | uint8_t SegmentNumber; |
| 763 | uint8_t SenseKey:4; |
| 764 | uint8_t Reserved:1; |
| 765 | uint8_t IncorrectLength:1; |
| 766 | uint8_t EndOfMedia:1; |
| 767 | uint8_t FileMark:1; |
| 768 | uint8_t Information[4]; |
| 769 | uint8_t AdditionalSenseLength; |
| 770 | uint8_t CommandSpecificInformation[4]; |
| 771 | uint8_t AdditionalSenseCode; |
| 772 | uint8_t AdditionalSenseCodeQualifier; |
| 773 | uint8_t FieldReplaceableUnitCode; |
| 774 | uint8_t SenseKeySpecific[3]; |
| 775 | }; |
| 776 | /* |
| 777 | ******************************************************************************* |
| 778 | ** Outbound Interrupt Status Register - OISR |
| 779 | ******************************************************************************* |
| 780 | */ |
| 781 | #define ARCMSR_MU_OUTBOUND_INTERRUPT_STATUS_REG 0x30 |
| 782 | #define ARCMSR_MU_OUTBOUND_PCI_INT 0x10 |
| 783 | #define ARCMSR_MU_OUTBOUND_POSTQUEUE_INT 0x08 |
| 784 | #define ARCMSR_MU_OUTBOUND_DOORBELL_INT 0x04 |
| 785 | #define ARCMSR_MU_OUTBOUND_MESSAGE1_INT 0x02 |
| 786 | #define ARCMSR_MU_OUTBOUND_MESSAGE0_INT 0x01 |
| 787 | #define ARCMSR_MU_OUTBOUND_HANDLE_INT \ |
| 788 | (ARCMSR_MU_OUTBOUND_MESSAGE0_INT \ |
| 789 | |ARCMSR_MU_OUTBOUND_MESSAGE1_INT \ |
| 790 | |ARCMSR_MU_OUTBOUND_DOORBELL_INT \ |
| 791 | |ARCMSR_MU_OUTBOUND_POSTQUEUE_INT \ |
| 792 | |ARCMSR_MU_OUTBOUND_PCI_INT) |
| 793 | /* |
| 794 | ******************************************************************************* |
| 795 | ** Outbound Interrupt Mask Register - OIMR |
| 796 | ******************************************************************************* |
| 797 | */ |
| 798 | #define ARCMSR_MU_OUTBOUND_INTERRUPT_MASK_REG 0x34 |
| 799 | #define ARCMSR_MU_OUTBOUND_PCI_INTMASKENABLE 0x10 |
| 800 | #define ARCMSR_MU_OUTBOUND_POSTQUEUE_INTMASKENABLE 0x08 |
| 801 | #define ARCMSR_MU_OUTBOUND_DOORBELL_INTMASKENABLE 0x04 |
| 802 | #define ARCMSR_MU_OUTBOUND_MESSAGE1_INTMASKENABLE 0x02 |
| 803 | #define ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE 0x01 |
| 804 | #define ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE 0x1F |
| 805 | |
Ching Huang | bb263c4 | 2014-08-19 15:17:45 +0800 | [diff] [blame] | 806 | extern void arcmsr_write_ioctldata2iop(struct AdapterControlBlock *); |
| 807 | extern uint32_t arcmsr_Read_iop_rqbuffer_data(struct AdapterControlBlock *, |
| 808 | struct QBUFFER __iomem *); |
| 809 | extern void arcmsr_clear_iop2drv_rqueue_buffer(struct AdapterControlBlock *); |
Al Viro | 80da1ad | 2007-10-29 05:08:28 +0000 | [diff] [blame] | 810 | extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 811 | extern struct device_attribute *arcmsr_host_attrs[]; |
Nick Cheng | 1a4f550 | 2007-09-13 17:26:40 +0800 | [diff] [blame] | 812 | extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *); |
Erich Chen | 1c57e86 | 2006-07-12 08:59:32 -0700 | [diff] [blame] | 813 | void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb); |