ql4_83xx.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. /*
  2. * QLogic iSCSI HBA Driver
  3. * Copyright (c) 2003-2013 QLogic Corporation
  4. *
  5. * See LICENSE.qla4xxx for copyright and licensing details.
  6. */
  7. #ifndef __QL483XX_H
  8. #define __QL483XX_H
  9. /* Indirectly Mapped Registers */
  10. #define QLA83XX_FLASH_SPI_STATUS 0x2808E010
  11. #define QLA83XX_FLASH_SPI_CONTROL 0x2808E014
  12. #define QLA83XX_FLASH_STATUS 0x42100004
  13. #define QLA83XX_FLASH_CONTROL 0x42110004
  14. #define QLA83XX_FLASH_ADDR 0x42110008
  15. #define QLA83XX_FLASH_WRDATA 0x4211000C
  16. #define QLA83XX_FLASH_RDDATA 0x42110018
  17. #define QLA83XX_FLASH_DIRECT_WINDOW 0x42110030
  18. #define QLA83XX_FLASH_DIRECT_DATA(DATA) (0x42150000 | (0x0000FFFF&DATA))
  19. /* Directly Mapped Registers in 83xx register table */
  20. /* Flash access regs */
  21. #define QLA83XX_FLASH_LOCK 0x3850
  22. #define QLA83XX_FLASH_UNLOCK 0x3854
  23. #define QLA83XX_FLASH_LOCK_ID 0x3500
  24. /* Driver Lock regs */
  25. #define QLA83XX_DRV_LOCK 0x3868
  26. #define QLA83XX_DRV_UNLOCK 0x386C
  27. #define QLA83XX_DRV_LOCK_ID 0x3504
  28. #define QLA83XX_DRV_LOCKRECOVERY 0x379C
  29. /* IDC version */
  30. #define QLA83XX_IDC_VER_MAJ_VALUE 0x1
  31. #define QLA83XX_IDC_VER_MIN_VALUE 0x0
  32. /* IDC Registers : Driver Coexistence Defines */
  33. #define QLA83XX_CRB_IDC_VER_MAJOR 0x3780
  34. #define QLA83XX_CRB_IDC_VER_MINOR 0x3798
  35. #define QLA83XX_IDC_DRV_CTRL 0x3790
  36. #define QLA83XX_IDC_DRV_AUDIT 0x3794
  37. #define QLA83XX_SRE_SHIM_CONTROL 0x0D200284
  38. #define QLA83XX_PORT0_RXB_PAUSE_THRS 0x0B2003A4
  39. #define QLA83XX_PORT1_RXB_PAUSE_THRS 0x0B2013A4
  40. #define QLA83XX_PORT0_RXB_TC_MAX_CELL 0x0B200388
  41. #define QLA83XX_PORT1_RXB_TC_MAX_CELL 0x0B201388
  42. #define QLA83XX_PORT0_RXB_TC_STATS 0x0B20039C
  43. #define QLA83XX_PORT1_RXB_TC_STATS 0x0B20139C
  44. #define QLA83XX_PORT2_IFB_PAUSE_THRS 0x0B200704
  45. #define QLA83XX_PORT3_IFB_PAUSE_THRS 0x0B201704
  46. /* set value to pause threshold value */
  47. #define QLA83XX_SET_PAUSE_VAL 0x0
  48. #define QLA83XX_SET_TC_MAX_CELL_VAL 0x03FF03FF
  49. #define QLA83XX_RESET_CONTROL 0x28084E50
  50. #define QLA83XX_RESET_REG 0x28084E60
  51. #define QLA83XX_RESET_PORT0 0x28084E70
  52. #define QLA83XX_RESET_PORT1 0x28084E80
  53. #define QLA83XX_RESET_PORT2 0x28084E90
  54. #define QLA83XX_RESET_PORT3 0x28084EA0
  55. #define QLA83XX_RESET_SRE_SHIM 0x28084EB0
  56. #define QLA83XX_RESET_EPG_SHIM 0x28084EC0
  57. #define QLA83XX_RESET_ETHER_PCS 0x28084ED0
  58. /* qla_83xx_reg_tbl registers */
  59. #define QLA83XX_PEG_HALT_STATUS1 0x34A8
  60. #define QLA83XX_PEG_HALT_STATUS2 0x34AC
  61. #define QLA83XX_PEG_ALIVE_COUNTER 0x34B0 /* FW_HEARTBEAT */
  62. #define QLA83XX_FW_CAPABILITIES 0x3528
  63. #define QLA83XX_CRB_DRV_ACTIVE 0x3788 /* IDC_DRV_PRESENCE */
  64. #define QLA83XX_CRB_DEV_STATE 0x3784 /* IDC_DEV_STATE */
  65. #define QLA83XX_CRB_DRV_STATE 0x378C /* IDC_DRV_ACK */
  66. #define QLA83XX_CRB_DRV_SCRATCH 0x3548
  67. #define QLA83XX_CRB_DEV_PART_INFO1 0x37E0
  68. #define QLA83XX_CRB_DEV_PART_INFO2 0x37E4
  69. #define QLA83XX_FW_VER_MAJOR 0x3550
  70. #define QLA83XX_FW_VER_MINOR 0x3554
  71. #define QLA83XX_FW_VER_SUB 0x3558
  72. #define QLA83XX_NPAR_STATE 0x359C
  73. #define QLA83XX_FW_IMAGE_VALID 0x35FC
  74. #define QLA83XX_CMDPEG_STATE 0x3650
  75. #define QLA83XX_ASIC_TEMP 0x37B4
  76. #define QLA83XX_FW_API 0x356C
  77. #define QLA83XX_DRV_OP_MODE 0x3570
  78. static const uint32_t qla4_83xx_reg_tbl[] = {
  79. QLA83XX_PEG_HALT_STATUS1,
  80. QLA83XX_PEG_HALT_STATUS2,
  81. QLA83XX_PEG_ALIVE_COUNTER,
  82. QLA83XX_CRB_DRV_ACTIVE,
  83. QLA83XX_CRB_DEV_STATE,
  84. QLA83XX_CRB_DRV_STATE,
  85. QLA83XX_CRB_DRV_SCRATCH,
  86. QLA83XX_CRB_DEV_PART_INFO1,
  87. QLA83XX_CRB_IDC_VER_MAJOR,
  88. QLA83XX_FW_VER_MAJOR,
  89. QLA83XX_FW_VER_MINOR,
  90. QLA83XX_FW_VER_SUB,
  91. QLA83XX_CMDPEG_STATE,
  92. QLA83XX_ASIC_TEMP,
  93. };
  94. #define QLA83XX_CRB_WIN_BASE 0x3800
  95. #define QLA83XX_CRB_WIN_FUNC(f) (QLA83XX_CRB_WIN_BASE+((f)*4))
  96. #define QLA83XX_SEM_LOCK_BASE 0x3840
  97. #define QLA83XX_SEM_UNLOCK_BASE 0x3844
  98. #define QLA83XX_SEM_LOCK_FUNC(f) (QLA83XX_SEM_LOCK_BASE+((f)*8))
  99. #define QLA83XX_SEM_UNLOCK_FUNC(f) (QLA83XX_SEM_UNLOCK_BASE+((f)*8))
  100. #define QLA83XX_LINK_STATE(f) (0x3698+((f) > 7 ? 4 : 0))
  101. #define QLA83XX_LINK_SPEED(f) (0x36E0+(((f) >> 2) * 4))
  102. #define QLA83XX_MAX_LINK_SPEED(f) (0x36F0+(((f) / 4) * 4))
  103. #define QLA83XX_LINK_SPEED_FACTOR 10
  104. /* FLASH API Defines */
  105. #define QLA83xx_FLASH_MAX_WAIT_USEC 100
  106. #define QLA83XX_FLASH_LOCK_TIMEOUT 10000
  107. #define QLA83XX_FLASH_SECTOR_SIZE 65536
  108. #define QLA83XX_DRV_LOCK_TIMEOUT 2000
  109. #define QLA83XX_FLASH_SECTOR_ERASE_CMD 0xdeadbeef
  110. #define QLA83XX_FLASH_WRITE_CMD 0xdacdacda
  111. #define QLA83XX_FLASH_BUFFER_WRITE_CMD 0xcadcadca
  112. #define QLA83XX_FLASH_READ_RETRY_COUNT 2000
  113. #define QLA83XX_FLASH_STATUS_READY 0x6
  114. #define QLA83XX_FLASH_BUFFER_WRITE_MIN 2
  115. #define QLA83XX_FLASH_BUFFER_WRITE_MAX 64
  116. #define QLA83XX_FLASH_STATUS_REG_POLL_DELAY 1
  117. #define QLA83XX_ERASE_MODE 1
  118. #define QLA83XX_WRITE_MODE 2
  119. #define QLA83XX_DWORD_WRITE_MODE 3
  120. #define QLA83XX_GLOBAL_RESET 0x38CC
  121. #define QLA83XX_WILDCARD 0x38F0
  122. #define QLA83XX_INFORMANT 0x38FC
  123. #define QLA83XX_HOST_MBX_CTRL 0x3038
  124. #define QLA83XX_FW_MBX_CTRL 0x303C
  125. #define QLA83XX_BOOTLOADER_ADDR 0x355C
  126. #define QLA83XX_BOOTLOADER_SIZE 0x3560
  127. #define QLA83XX_FW_IMAGE_ADDR 0x3564
  128. #define QLA83XX_MBX_INTR_ENABLE 0x1000
  129. #define QLA83XX_MBX_INTR_MASK 0x1200
  130. /* IDC Control Register bit defines */
  131. #define DONTRESET_BIT0 0x1
  132. #define GRACEFUL_RESET_BIT1 0x2
  133. #define QLA83XX_HALT_STATUS_INFORMATIONAL (0x1 << 29)
  134. #define QLA83XX_HALT_STATUS_FW_RESET (0x2 << 29)
  135. #define QLA83XX_HALT_STATUS_UNRECOVERABLE (0x4 << 29)
  136. /* Firmware image definitions */
  137. #define QLA83XX_BOOTLOADER_FLASH_ADDR 0x10000
  138. #define QLA83XX_BOOT_FROM_FLASH 0
  139. #define QLA83XX_IDC_PARAM_ADDR 0x3e8020
  140. /* Reset template definitions */
  141. #define QLA83XX_MAX_RESET_SEQ_ENTRIES 16
  142. #define QLA83XX_RESTART_TEMPLATE_SIZE 0x2000
  143. #define QLA83XX_RESET_TEMPLATE_ADDR 0x4F0000
  144. #define QLA83XX_RESET_SEQ_VERSION 0x0101
  145. /* Reset template entry opcodes */
  146. #define OPCODE_NOP 0x0000
  147. #define OPCODE_WRITE_LIST 0x0001
  148. #define OPCODE_READ_WRITE_LIST 0x0002
  149. #define OPCODE_POLL_LIST 0x0004
  150. #define OPCODE_POLL_WRITE_LIST 0x0008
  151. #define OPCODE_READ_MODIFY_WRITE 0x0010
  152. #define OPCODE_SEQ_PAUSE 0x0020
  153. #define OPCODE_SEQ_END 0x0040
  154. #define OPCODE_TMPL_END 0x0080
  155. #define OPCODE_POLL_READ_LIST 0x0100
  156. /* Template Header */
  157. #define RESET_TMPLT_HDR_SIGNATURE 0xCAFE
  158. struct qla4_83xx_reset_template_hdr {
  159. __le16 version;
  160. __le16 signature;
  161. __le16 size;
  162. __le16 entries;
  163. __le16 hdr_size;
  164. __le16 checksum;
  165. __le16 init_seq_offset;
  166. __le16 start_seq_offset;
  167. } __packed;
  168. /* Common Entry Header. */
  169. struct qla4_83xx_reset_entry_hdr {
  170. __le16 cmd;
  171. __le16 size;
  172. __le16 count;
  173. __le16 delay;
  174. } __packed;
  175. /* Generic poll entry type. */
  176. struct qla4_83xx_poll {
  177. __le32 test_mask;
  178. __le32 test_value;
  179. } __packed;
  180. /* Read modify write entry type. */
  181. struct qla4_83xx_rmw {
  182. __le32 test_mask;
  183. __le32 xor_value;
  184. __le32 or_value;
  185. uint8_t shl;
  186. uint8_t shr;
  187. uint8_t index_a;
  188. uint8_t rsvd;
  189. } __packed;
  190. /* Generic Entry Item with 2 DWords. */
  191. struct qla4_83xx_entry {
  192. __le32 arg1;
  193. __le32 arg2;
  194. } __packed;
  195. /* Generic Entry Item with 4 DWords.*/
  196. struct qla4_83xx_quad_entry {
  197. __le32 dr_addr;
  198. __le32 dr_value;
  199. __le32 ar_addr;
  200. __le32 ar_value;
  201. } __packed;
  202. struct qla4_83xx_reset_template {
  203. int seq_index;
  204. int seq_error;
  205. int array_index;
  206. uint32_t array[QLA83XX_MAX_RESET_SEQ_ENTRIES];
  207. uint8_t *buff;
  208. uint8_t *stop_offset;
  209. uint8_t *start_offset;
  210. uint8_t *init_offset;
  211. struct qla4_83xx_reset_template_hdr *hdr;
  212. uint8_t seq_end;
  213. uint8_t template_end;
  214. };
  215. /* POLLRD Entry */
  216. struct qla83xx_minidump_entry_pollrd {
  217. struct qla8xxx_minidump_entry_hdr h;
  218. uint32_t select_addr;
  219. uint32_t read_addr;
  220. uint32_t select_value;
  221. uint16_t select_value_stride;
  222. uint16_t op_count;
  223. uint32_t poll_wait;
  224. uint32_t poll_mask;
  225. uint32_t data_size;
  226. uint32_t rsvd_1;
  227. };
  228. struct qla8044_minidump_entry_rddfe {
  229. struct qla8xxx_minidump_entry_hdr h;
  230. uint32_t addr_1;
  231. uint32_t value;
  232. uint8_t stride;
  233. uint8_t stride2;
  234. uint16_t count;
  235. uint32_t poll;
  236. uint32_t mask;
  237. uint32_t modify_mask;
  238. uint32_t data_size;
  239. uint32_t rsvd;
  240. } __packed;
  241. struct qla8044_minidump_entry_rdmdio {
  242. struct qla8xxx_minidump_entry_hdr h;
  243. uint32_t addr_1;
  244. uint32_t addr_2;
  245. uint32_t value_1;
  246. uint8_t stride_1;
  247. uint8_t stride_2;
  248. uint16_t count;
  249. uint32_t poll;
  250. uint32_t mask;
  251. uint32_t value_2;
  252. uint32_t data_size;
  253. } __packed;
  254. struct qla8044_minidump_entry_pollwr {
  255. struct qla8xxx_minidump_entry_hdr h;
  256. uint32_t addr_1;
  257. uint32_t addr_2;
  258. uint32_t value_1;
  259. uint32_t value_2;
  260. uint32_t poll;
  261. uint32_t mask;
  262. uint32_t data_size;
  263. uint32_t rsvd;
  264. } __packed;
  265. /* RDMUX2 Entry */
  266. struct qla83xx_minidump_entry_rdmux2 {
  267. struct qla8xxx_minidump_entry_hdr h;
  268. uint32_t select_addr_1;
  269. uint32_t select_addr_2;
  270. uint32_t select_value_1;
  271. uint32_t select_value_2;
  272. uint32_t op_count;
  273. uint32_t select_value_mask;
  274. uint32_t read_addr;
  275. uint8_t select_value_stride;
  276. uint8_t data_size;
  277. uint8_t rsvd[2];
  278. };
  279. /* POLLRDMWR Entry */
  280. struct qla83xx_minidump_entry_pollrdmwr {
  281. struct qla8xxx_minidump_entry_hdr h;
  282. uint32_t addr_1;
  283. uint32_t addr_2;
  284. uint32_t value_1;
  285. uint32_t value_2;
  286. uint32_t poll_wait;
  287. uint32_t poll_mask;
  288. uint32_t modify_mask;
  289. uint32_t data_size;
  290. };
  291. /* IDC additional information */
  292. struct qla4_83xx_idc_information {
  293. uint32_t request_desc; /* IDC request descriptor */
  294. uint32_t info1; /* IDC additional info */
  295. uint32_t info2; /* IDC additional info */
  296. uint32_t info3; /* IDC additional info */
  297. };
  298. #define QLA83XX_PEX_DMA_ENGINE_INDEX 8
  299. #define QLA83XX_PEX_DMA_BASE_ADDRESS 0x77320000
  300. #define QLA83XX_PEX_DMA_NUM_OFFSET 0x10000
  301. #define QLA83XX_PEX_DMA_CMD_ADDR_LOW 0x0
  302. #define QLA83XX_PEX_DMA_CMD_ADDR_HIGH 0x04
  303. #define QLA83XX_PEX_DMA_CMD_STS_AND_CNTRL 0x08
  304. #define QLA83XX_PEX_DMA_READ_SIZE (16 * 1024)
  305. #define QLA83XX_PEX_DMA_MAX_WAIT (100 * 100) /* Max wait of 100 msecs */
  306. /* Read Memory: For Pex-DMA */
  307. struct qla4_83xx_minidump_entry_rdmem_pex_dma {
  308. struct qla8xxx_minidump_entry_hdr h;
  309. uint32_t desc_card_addr;
  310. uint16_t dma_desc_cmd;
  311. uint8_t rsvd[2];
  312. uint32_t start_dma_cmd;
  313. uint8_t rsvd2[12];
  314. uint32_t read_addr;
  315. uint32_t read_data_size;
  316. };
  317. struct qla4_83xx_pex_dma_descriptor {
  318. struct {
  319. uint32_t read_data_size; /* 0-23: size, 24-31: rsvd */
  320. uint8_t rsvd[2];
  321. uint16_t dma_desc_cmd;
  322. } cmd;
  323. uint64_t src_addr;
  324. uint64_t dma_bus_addr; /* 0-3: desc-cmd, 4-7: pci-func,
  325. * 8-15: desc-cmd */
  326. uint8_t rsvd[24];
  327. } __packed;
  328. #endif