arcmsr.h 39 KB

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