ql4_nx.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  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 __QLA_NX_H
  8. #define __QLA_NX_H
  9. /*
  10. * Following are the states of the Phantom. Phantom will set them and
  11. * Host will read to check if the fields are correct.
  12. */
  13. #define PHAN_INITIALIZE_FAILED 0xffff
  14. #define PHAN_INITIALIZE_COMPLETE 0xff01
  15. /* Host writes the following to notify that it has done the init-handshake */
  16. #define PHAN_INITIALIZE_ACK 0xf00f
  17. #define PHAN_PEG_RCV_INITIALIZED 0xff01
  18. /*CRB_RELATED*/
  19. #define QLA82XX_CRB_BASE (QLA82XX_CAM_RAM(0x200))
  20. #define QLA82XX_REG(X) (QLA82XX_CRB_BASE+(X))
  21. #define CRB_CMDPEG_STATE QLA82XX_REG(0x50)
  22. #define CRB_RCVPEG_STATE QLA82XX_REG(0x13c)
  23. #define CRB_DMA_SHIFT QLA82XX_REG(0xcc)
  24. #define CRB_TEMP_STATE QLA82XX_REG(0x1b4)
  25. #define CRB_CMDPEG_CHECK_RETRY_COUNT 60
  26. #define CRB_CMDPEG_CHECK_DELAY 500
  27. #define qla82xx_get_temp_val(x) ((x) >> 16)
  28. #define qla82xx_get_temp_state(x) ((x) & 0xffff)
  29. #define qla82xx_encode_temp(val, state) (((val) << 16) | (state))
  30. /*
  31. * Temperature control.
  32. */
  33. enum {
  34. QLA82XX_TEMP_NORMAL = 0x1, /* Normal operating range */
  35. QLA82XX_TEMP_WARN, /* Sound alert, temperature getting high */
  36. QLA82XX_TEMP_PANIC /* Fatal error, hardware has shut down. */
  37. };
  38. #define CRB_NIU_XG_PAUSE_CTL_P0 0x1
  39. #define CRB_NIU_XG_PAUSE_CTL_P1 0x8
  40. #define QLA82XX_HW_H0_CH_HUB_ADR 0x05
  41. #define QLA82XX_HW_H1_CH_HUB_ADR 0x0E
  42. #define QLA82XX_HW_H2_CH_HUB_ADR 0x03
  43. #define QLA82XX_HW_H3_CH_HUB_ADR 0x01
  44. #define QLA82XX_HW_H4_CH_HUB_ADR 0x06
  45. #define QLA82XX_HW_H5_CH_HUB_ADR 0x07
  46. #define QLA82XX_HW_H6_CH_HUB_ADR 0x08
  47. /* Hub 0 */
  48. #define QLA82XX_HW_MN_CRB_AGT_ADR 0x15
  49. #define QLA82XX_HW_MS_CRB_AGT_ADR 0x25
  50. /* Hub 1 */
  51. #define QLA82XX_HW_PS_CRB_AGT_ADR 0x73
  52. #define QLA82XX_HW_QMS_CRB_AGT_ADR 0x00
  53. #define QLA82XX_HW_RPMX3_CRB_AGT_ADR 0x0b
  54. #define QLA82XX_HW_SQGS0_CRB_AGT_ADR 0x01
  55. #define QLA82XX_HW_SQGS1_CRB_AGT_ADR 0x02
  56. #define QLA82XX_HW_SQGS2_CRB_AGT_ADR 0x03
  57. #define QLA82XX_HW_SQGS3_CRB_AGT_ADR 0x04
  58. #define QLA82XX_HW_C2C0_CRB_AGT_ADR 0x58
  59. #define QLA82XX_HW_C2C1_CRB_AGT_ADR 0x59
  60. #define QLA82XX_HW_C2C2_CRB_AGT_ADR 0x5a
  61. #define QLA82XX_HW_RPMX2_CRB_AGT_ADR 0x0a
  62. #define QLA82XX_HW_RPMX4_CRB_AGT_ADR 0x0c
  63. #define QLA82XX_HW_RPMX7_CRB_AGT_ADR 0x0f
  64. #define QLA82XX_HW_RPMX9_CRB_AGT_ADR 0x12
  65. #define QLA82XX_HW_SMB_CRB_AGT_ADR 0x18
  66. /* Hub 2 */
  67. #define QLA82XX_HW_NIU_CRB_AGT_ADR 0x31
  68. #define QLA82XX_HW_I2C0_CRB_AGT_ADR 0x19
  69. #define QLA82XX_HW_I2C1_CRB_AGT_ADR 0x29
  70. #define QLA82XX_HW_SN_CRB_AGT_ADR 0x10
  71. #define QLA82XX_HW_I2Q_CRB_AGT_ADR 0x20
  72. #define QLA82XX_HW_LPC_CRB_AGT_ADR 0x22
  73. #define QLA82XX_HW_ROMUSB_CRB_AGT_ADR 0x21
  74. #define QLA82XX_HW_QM_CRB_AGT_ADR 0x66
  75. #define QLA82XX_HW_SQG0_CRB_AGT_ADR 0x60
  76. #define QLA82XX_HW_SQG1_CRB_AGT_ADR 0x61
  77. #define QLA82XX_HW_SQG2_CRB_AGT_ADR 0x62
  78. #define QLA82XX_HW_SQG3_CRB_AGT_ADR 0x63
  79. #define QLA82XX_HW_RPMX1_CRB_AGT_ADR 0x09
  80. #define QLA82XX_HW_RPMX5_CRB_AGT_ADR 0x0d
  81. #define QLA82XX_HW_RPMX6_CRB_AGT_ADR 0x0e
  82. #define QLA82XX_HW_RPMX8_CRB_AGT_ADR 0x11
  83. /* Hub 3 */
  84. #define QLA82XX_HW_PH_CRB_AGT_ADR 0x1A
  85. #define QLA82XX_HW_SRE_CRB_AGT_ADR 0x50
  86. #define QLA82XX_HW_EG_CRB_AGT_ADR 0x51
  87. #define QLA82XX_HW_RPMX0_CRB_AGT_ADR 0x08
  88. /* Hub 4 */
  89. #define QLA82XX_HW_PEGN0_CRB_AGT_ADR 0x40
  90. #define QLA82XX_HW_PEGN1_CRB_AGT_ADR 0x41
  91. #define QLA82XX_HW_PEGN2_CRB_AGT_ADR 0x42
  92. #define QLA82XX_HW_PEGN3_CRB_AGT_ADR 0x43
  93. #define QLA82XX_HW_PEGNI_CRB_AGT_ADR 0x44
  94. #define QLA82XX_HW_PEGND_CRB_AGT_ADR 0x45
  95. #define QLA82XX_HW_PEGNC_CRB_AGT_ADR 0x46
  96. #define QLA82XX_HW_PEGR0_CRB_AGT_ADR 0x47
  97. #define QLA82XX_HW_PEGR1_CRB_AGT_ADR 0x48
  98. #define QLA82XX_HW_PEGR2_CRB_AGT_ADR 0x49
  99. #define QLA82XX_HW_PEGR3_CRB_AGT_ADR 0x4a
  100. #define QLA82XX_HW_PEGN4_CRB_AGT_ADR 0x4b
  101. /* Hub 5 */
  102. #define QLA82XX_HW_PEGS0_CRB_AGT_ADR 0x40
  103. #define QLA82XX_HW_PEGS1_CRB_AGT_ADR 0x41
  104. #define QLA82XX_HW_PEGS2_CRB_AGT_ADR 0x42
  105. #define QLA82XX_HW_PEGS3_CRB_AGT_ADR 0x43
  106. #define QLA82XX_HW_PEGSI_CRB_AGT_ADR 0x44
  107. #define QLA82XX_HW_PEGSD_CRB_AGT_ADR 0x45
  108. #define QLA82XX_HW_PEGSC_CRB_AGT_ADR 0x46
  109. /* Hub 6 */
  110. #define QLA82XX_HW_CAS0_CRB_AGT_ADR 0x46
  111. #define QLA82XX_HW_CAS1_CRB_AGT_ADR 0x47
  112. #define QLA82XX_HW_CAS2_CRB_AGT_ADR 0x48
  113. #define QLA82XX_HW_CAS3_CRB_AGT_ADR 0x49
  114. #define QLA82XX_HW_NCM_CRB_AGT_ADR 0x16
  115. #define QLA82XX_HW_TMR_CRB_AGT_ADR 0x17
  116. #define QLA82XX_HW_XDMA_CRB_AGT_ADR 0x05
  117. #define QLA82XX_HW_OCM0_CRB_AGT_ADR 0x06
  118. #define QLA82XX_HW_OCM1_CRB_AGT_ADR 0x07
  119. /* This field defines PCI/X adr [25:20] of agents on the CRB */
  120. /* */
  121. #define QLA82XX_HW_PX_MAP_CRB_PH 0
  122. #define QLA82XX_HW_PX_MAP_CRB_PS 1
  123. #define QLA82XX_HW_PX_MAP_CRB_MN 2
  124. #define QLA82XX_HW_PX_MAP_CRB_MS 3
  125. #define QLA82XX_HW_PX_MAP_CRB_SRE 5
  126. #define QLA82XX_HW_PX_MAP_CRB_NIU 6
  127. #define QLA82XX_HW_PX_MAP_CRB_QMN 7
  128. #define QLA82XX_HW_PX_MAP_CRB_SQN0 8
  129. #define QLA82XX_HW_PX_MAP_CRB_SQN1 9
  130. #define QLA82XX_HW_PX_MAP_CRB_SQN2 10
  131. #define QLA82XX_HW_PX_MAP_CRB_SQN3 11
  132. #define QLA82XX_HW_PX_MAP_CRB_QMS 12
  133. #define QLA82XX_HW_PX_MAP_CRB_SQS0 13
  134. #define QLA82XX_HW_PX_MAP_CRB_SQS1 14
  135. #define QLA82XX_HW_PX_MAP_CRB_SQS2 15
  136. #define QLA82XX_HW_PX_MAP_CRB_SQS3 16
  137. #define QLA82XX_HW_PX_MAP_CRB_PGN0 17
  138. #define QLA82XX_HW_PX_MAP_CRB_PGN1 18
  139. #define QLA82XX_HW_PX_MAP_CRB_PGN2 19
  140. #define QLA82XX_HW_PX_MAP_CRB_PGN3 20
  141. #define QLA82XX_HW_PX_MAP_CRB_PGN4 QLA82XX_HW_PX_MAP_CRB_SQS2
  142. #define QLA82XX_HW_PX_MAP_CRB_PGND 21
  143. #define QLA82XX_HW_PX_MAP_CRB_PGNI 22
  144. #define QLA82XX_HW_PX_MAP_CRB_PGS0 23
  145. #define QLA82XX_HW_PX_MAP_CRB_PGS1 24
  146. #define QLA82XX_HW_PX_MAP_CRB_PGS2 25
  147. #define QLA82XX_HW_PX_MAP_CRB_PGS3 26
  148. #define QLA82XX_HW_PX_MAP_CRB_PGSD 27
  149. #define QLA82XX_HW_PX_MAP_CRB_PGSI 28
  150. #define QLA82XX_HW_PX_MAP_CRB_SN 29
  151. #define QLA82XX_HW_PX_MAP_CRB_EG 31
  152. #define QLA82XX_HW_PX_MAP_CRB_PH2 32
  153. #define QLA82XX_HW_PX_MAP_CRB_PS2 33
  154. #define QLA82XX_HW_PX_MAP_CRB_CAM 34
  155. #define QLA82XX_HW_PX_MAP_CRB_CAS0 35
  156. #define QLA82XX_HW_PX_MAP_CRB_CAS1 36
  157. #define QLA82XX_HW_PX_MAP_CRB_CAS2 37
  158. #define QLA82XX_HW_PX_MAP_CRB_C2C0 38
  159. #define QLA82XX_HW_PX_MAP_CRB_C2C1 39
  160. #define QLA82XX_HW_PX_MAP_CRB_TIMR 40
  161. #define QLA82XX_HW_PX_MAP_CRB_RPMX1 42
  162. #define QLA82XX_HW_PX_MAP_CRB_RPMX2 43
  163. #define QLA82XX_HW_PX_MAP_CRB_RPMX3 44
  164. #define QLA82XX_HW_PX_MAP_CRB_RPMX4 45
  165. #define QLA82XX_HW_PX_MAP_CRB_RPMX5 46
  166. #define QLA82XX_HW_PX_MAP_CRB_RPMX6 47
  167. #define QLA82XX_HW_PX_MAP_CRB_RPMX7 48
  168. #define QLA82XX_HW_PX_MAP_CRB_XDMA 49
  169. #define QLA82XX_HW_PX_MAP_CRB_I2Q 50
  170. #define QLA82XX_HW_PX_MAP_CRB_ROMUSB 51
  171. #define QLA82XX_HW_PX_MAP_CRB_CAS3 52
  172. #define QLA82XX_HW_PX_MAP_CRB_RPMX0 53
  173. #define QLA82XX_HW_PX_MAP_CRB_RPMX8 54
  174. #define QLA82XX_HW_PX_MAP_CRB_RPMX9 55
  175. #define QLA82XX_HW_PX_MAP_CRB_OCM0 56
  176. #define QLA82XX_HW_PX_MAP_CRB_OCM1 57
  177. #define QLA82XX_HW_PX_MAP_CRB_SMB 58
  178. #define QLA82XX_HW_PX_MAP_CRB_I2C0 59
  179. #define QLA82XX_HW_PX_MAP_CRB_I2C1 60
  180. #define QLA82XX_HW_PX_MAP_CRB_LPC 61
  181. #define QLA82XX_HW_PX_MAP_CRB_PGNC 62
  182. #define QLA82XX_HW_PX_MAP_CRB_PGR0 63
  183. #define QLA82XX_HW_PX_MAP_CRB_PGR1 4
  184. #define QLA82XX_HW_PX_MAP_CRB_PGR2 30
  185. #define QLA82XX_HW_PX_MAP_CRB_PGR3 41
  186. /* This field defines CRB adr [31:20] of the agents */
  187. /* */
  188. #define QLA82XX_HW_CRB_HUB_AGT_ADR_MN ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
  189. QLA82XX_HW_MN_CRB_AGT_ADR)
  190. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PH ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
  191. QLA82XX_HW_PH_CRB_AGT_ADR)
  192. #define QLA82XX_HW_CRB_HUB_AGT_ADR_MS ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
  193. QLA82XX_HW_MS_CRB_AGT_ADR)
  194. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PS ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  195. QLA82XX_HW_PS_CRB_AGT_ADR)
  196. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SS ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  197. QLA82XX_HW_SS_CRB_AGT_ADR)
  198. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX3 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  199. QLA82XX_HW_RPMX3_CRB_AGT_ADR)
  200. #define QLA82XX_HW_CRB_HUB_AGT_ADR_QMS ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  201. QLA82XX_HW_QMS_CRB_AGT_ADR)
  202. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS0 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  203. QLA82XX_HW_SQGS0_CRB_AGT_ADR)
  204. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS1 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  205. QLA82XX_HW_SQGS1_CRB_AGT_ADR)
  206. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS2 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  207. QLA82XX_HW_SQGS2_CRB_AGT_ADR)
  208. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS3 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  209. QLA82XX_HW_SQGS3_CRB_AGT_ADR)
  210. #define QLA82XX_HW_CRB_HUB_AGT_ADR_C2C0 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  211. QLA82XX_HW_C2C0_CRB_AGT_ADR)
  212. #define QLA82XX_HW_CRB_HUB_AGT_ADR_C2C1 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  213. QLA82XX_HW_C2C1_CRB_AGT_ADR)
  214. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX2 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  215. QLA82XX_HW_RPMX2_CRB_AGT_ADR)
  216. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX4 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  217. QLA82XX_HW_RPMX4_CRB_AGT_ADR)
  218. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX7 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  219. QLA82XX_HW_RPMX7_CRB_AGT_ADR)
  220. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX9 ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  221. QLA82XX_HW_RPMX9_CRB_AGT_ADR)
  222. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SMB ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
  223. QLA82XX_HW_SMB_CRB_AGT_ADR)
  224. #define QLA82XX_HW_CRB_HUB_AGT_ADR_NIU ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
  225. QLA82XX_HW_NIU_CRB_AGT_ADR)
  226. #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2C0 ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
  227. QLA82XX_HW_I2C0_CRB_AGT_ADR)
  228. #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2C1 ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
  229. QLA82XX_HW_I2C1_CRB_AGT_ADR)
  230. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SRE ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  231. QLA82XX_HW_SRE_CRB_AGT_ADR)
  232. #define QLA82XX_HW_CRB_HUB_AGT_ADR_EG ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  233. QLA82XX_HW_EG_CRB_AGT_ADR)
  234. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX0 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  235. QLA82XX_HW_RPMX0_CRB_AGT_ADR)
  236. #define QLA82XX_HW_CRB_HUB_AGT_ADR_QMN ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  237. QLA82XX_HW_QM_CRB_AGT_ADR)
  238. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN0 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  239. QLA82XX_HW_SQG0_CRB_AGT_ADR)
  240. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN1 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  241. QLA82XX_HW_SQG1_CRB_AGT_ADR)
  242. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN2 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  243. QLA82XX_HW_SQG2_CRB_AGT_ADR)
  244. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN3 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  245. QLA82XX_HW_SQG3_CRB_AGT_ADR)
  246. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX1 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  247. QLA82XX_HW_RPMX1_CRB_AGT_ADR)
  248. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX5 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  249. QLA82XX_HW_RPMX5_CRB_AGT_ADR)
  250. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX6 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  251. QLA82XX_HW_RPMX6_CRB_AGT_ADR)
  252. #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX8 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  253. QLA82XX_HW_RPMX8_CRB_AGT_ADR)
  254. #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS0 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  255. QLA82XX_HW_CAS0_CRB_AGT_ADR)
  256. #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS1 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  257. QLA82XX_HW_CAS1_CRB_AGT_ADR)
  258. #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS2 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  259. QLA82XX_HW_CAS2_CRB_AGT_ADR)
  260. #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS3 ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
  261. QLA82XX_HW_CAS3_CRB_AGT_ADR)
  262. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGNI ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  263. QLA82XX_HW_PEGNI_CRB_AGT_ADR)
  264. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGND ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  265. QLA82XX_HW_PEGND_CRB_AGT_ADR)
  266. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN0 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  267. QLA82XX_HW_PEGN0_CRB_AGT_ADR)
  268. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN1 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  269. QLA82XX_HW_PEGN1_CRB_AGT_ADR)
  270. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN2 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  271. QLA82XX_HW_PEGN2_CRB_AGT_ADR)
  272. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN3 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  273. QLA82XX_HW_PEGN3_CRB_AGT_ADR)
  274. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN4 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  275. QLA82XX_HW_PEGN4_CRB_AGT_ADR)
  276. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGNC ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  277. QLA82XX_HW_PEGNC_CRB_AGT_ADR)
  278. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR0 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  279. QLA82XX_HW_PEGR0_CRB_AGT_ADR)
  280. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR1 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  281. QLA82XX_HW_PEGR1_CRB_AGT_ADR)
  282. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR2 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  283. QLA82XX_HW_PEGR2_CRB_AGT_ADR)
  284. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR3 ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
  285. QLA82XX_HW_PEGR3_CRB_AGT_ADR)
  286. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSI ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
  287. QLA82XX_HW_PEGSI_CRB_AGT_ADR)
  288. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSD ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
  289. QLA82XX_HW_PEGSD_CRB_AGT_ADR)
  290. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS0 ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
  291. QLA82XX_HW_PEGS0_CRB_AGT_ADR)
  292. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS1 ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
  293. QLA82XX_HW_PEGS1_CRB_AGT_ADR)
  294. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS2 ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
  295. QLA82XX_HW_PEGS2_CRB_AGT_ADR)
  296. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS3 ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
  297. QLA82XX_HW_PEGS3_CRB_AGT_ADR)
  298. #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSC ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
  299. QLA82XX_HW_PEGSC_CRB_AGT_ADR)
  300. #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAM ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  301. QLA82XX_HW_NCM_CRB_AGT_ADR)
  302. #define QLA82XX_HW_CRB_HUB_AGT_ADR_TIMR ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  303. QLA82XX_HW_TMR_CRB_AGT_ADR)
  304. #define QLA82XX_HW_CRB_HUB_AGT_ADR_XDMA ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  305. QLA82XX_HW_XDMA_CRB_AGT_ADR)
  306. #define QLA82XX_HW_CRB_HUB_AGT_ADR_SN ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  307. QLA82XX_HW_SN_CRB_AGT_ADR)
  308. #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2Q ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  309. QLA82XX_HW_I2Q_CRB_AGT_ADR)
  310. #define QLA82XX_HW_CRB_HUB_AGT_ADR_ROMUSB ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  311. QLA82XX_HW_ROMUSB_CRB_AGT_ADR)
  312. #define QLA82XX_HW_CRB_HUB_AGT_ADR_OCM0 ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  313. QLA82XX_HW_OCM0_CRB_AGT_ADR)
  314. #define QLA82XX_HW_CRB_HUB_AGT_ADR_OCM1 ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  315. QLA82XX_HW_OCM1_CRB_AGT_ADR)
  316. #define QLA82XX_HW_CRB_HUB_AGT_ADR_LPC ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
  317. QLA82XX_HW_LPC_CRB_AGT_ADR)
  318. #define ROMUSB_GLB (QLA82XX_CRB_ROMUSB + 0x00000)
  319. #define QLA82XX_ROMUSB_GLB_PEGTUNE_DONE (ROMUSB_GLB + 0x005c)
  320. #define QLA82XX_ROMUSB_GLB_STATUS (ROMUSB_GLB + 0x0004)
  321. #define QLA82XX_ROMUSB_GLB_SW_RESET (ROMUSB_GLB + 0x0008)
  322. #define QLA82XX_ROMUSB_ROM_ADDRESS (ROMUSB_ROM + 0x0008)
  323. #define QLA82XX_ROMUSB_ROM_WDATA (ROMUSB_ROM + 0x000c)
  324. #define QLA82XX_ROMUSB_ROM_ABYTE_CNT (ROMUSB_ROM + 0x0010)
  325. #define QLA82XX_ROMUSB_ROM_DUMMY_BYTE_CNT (ROMUSB_ROM + 0x0014)
  326. #define QLA82XX_ROMUSB_ROM_RDATA (ROMUSB_ROM + 0x0018)
  327. #define ROMUSB_ROM (QLA82XX_CRB_ROMUSB + 0x10000)
  328. #define QLA82XX_ROMUSB_ROM_INSTR_OPCODE (ROMUSB_ROM + 0x0004)
  329. #define QLA82XX_ROMUSB_GLB_CAS_RST (ROMUSB_GLB + 0x0038)
  330. /* Lock IDs for ROM lock */
  331. #define ROM_LOCK_DRIVER 0x0d417340
  332. #define QLA82XX_PCI_CRB_WINDOWSIZE 0x00100000 /* all are 1MB windows */
  333. #define QLA82XX_PCI_CRB_WINDOW(A) (QLA82XX_PCI_CRBSPACE + \
  334. (A)*QLA82XX_PCI_CRB_WINDOWSIZE)
  335. #define QLA82XX_CRB_C2C_0 \
  336. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C0)
  337. #define QLA82XX_CRB_C2C_1 \
  338. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C1)
  339. #define QLA82XX_CRB_C2C_2 \
  340. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C2)
  341. #define QLA82XX_CRB_CAM \
  342. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAM)
  343. #define QLA82XX_CRB_CASPER \
  344. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS)
  345. #define QLA82XX_CRB_CASPER_0 \
  346. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS0)
  347. #define QLA82XX_CRB_CASPER_1 \
  348. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS1)
  349. #define QLA82XX_CRB_CASPER_2 \
  350. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS2)
  351. #define QLA82XX_CRB_DDR_MD \
  352. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_MS)
  353. #define QLA82XX_CRB_DDR_NET \
  354. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_MN)
  355. #define QLA82XX_CRB_EPG \
  356. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_EG)
  357. #define QLA82XX_CRB_I2Q \
  358. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2Q)
  359. #define QLA82XX_CRB_NIU \
  360. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_NIU)
  361. /* HACK upon HACK upon HACK (for PCIE builds) */
  362. #define QLA82XX_CRB_PCIX_HOST \
  363. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PH)
  364. #define QLA82XX_CRB_PCIX_HOST2 \
  365. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PH2)
  366. #define QLA82XX_CRB_PCIX_MD \
  367. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PS)
  368. #define QLA82XX_CRB_PCIE QLA82XX_CRB_PCIX_MD
  369. /* window 1 pcie slot */
  370. #define QLA82XX_CRB_PCIE2 \
  371. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PS2)
  372. #define QLA82XX_CRB_PEG_MD_0 \
  373. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS0)
  374. #define QLA82XX_CRB_PEG_MD_1 \
  375. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS1)
  376. #define QLA82XX_CRB_PEG_MD_2 \
  377. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS2)
  378. #define QLA82XX_CRB_PEG_MD_3 \
  379. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS3)
  380. #define QLA82XX_CRB_PEG_MD_3 \
  381. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS3)
  382. #define QLA82XX_CRB_PEG_MD_D \
  383. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGSD)
  384. #define QLA82XX_CRB_PEG_MD_I \
  385. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGSI)
  386. #define QLA82XX_CRB_PEG_NET_0 \
  387. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN0)
  388. #define QLA82XX_CRB_PEG_NET_1 \
  389. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN1)
  390. #define QLA82XX_CRB_PEG_NET_2 \
  391. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN2)
  392. #define QLA82XX_CRB_PEG_NET_3 \
  393. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN3)
  394. #define QLA82XX_CRB_PEG_NET_4 \
  395. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN4)
  396. #define QLA82XX_CRB_PEG_NET_D \
  397. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGND)
  398. #define QLA82XX_CRB_PEG_NET_I \
  399. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGNI)
  400. #define QLA82XX_CRB_PQM_MD \
  401. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_QMS)
  402. #define QLA82XX_CRB_PQM_NET \
  403. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_QMN)
  404. #define QLA82XX_CRB_QDR_MD \
  405. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SS)
  406. #define QLA82XX_CRB_QDR_NET \
  407. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SN)
  408. #define QLA82XX_CRB_ROMUSB \
  409. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_ROMUSB)
  410. #define QLA82XX_CRB_RPMX_0 \
  411. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX0)
  412. #define QLA82XX_CRB_RPMX_1 \
  413. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX1)
  414. #define QLA82XX_CRB_RPMX_2 \
  415. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX2)
  416. #define QLA82XX_CRB_RPMX_3 \
  417. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX3)
  418. #define QLA82XX_CRB_RPMX_4 \
  419. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX4)
  420. #define QLA82XX_CRB_RPMX_5 \
  421. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX5)
  422. #define QLA82XX_CRB_RPMX_6 \
  423. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX6)
  424. #define QLA82XX_CRB_RPMX_7 \
  425. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX7)
  426. #define QLA82XX_CRB_SQM_MD_0 \
  427. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS0)
  428. #define QLA82XX_CRB_SQM_MD_1 \
  429. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS1)
  430. #define QLA82XX_CRB_SQM_MD_2 \
  431. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS2)
  432. #define QLA82XX_CRB_SQM_MD_3 \
  433. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS3)
  434. #define QLA82XX_CRB_SQM_NET_0 \
  435. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN0)
  436. #define QLA82XX_CRB_SQM_NET_1 \
  437. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN1)
  438. #define QLA82XX_CRB_SQM_NET_2 \
  439. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN2)
  440. #define QLA82XX_CRB_SQM_NET_3 \
  441. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN3)
  442. #define QLA82XX_CRB_SRE \
  443. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SRE)
  444. #define QLA82XX_CRB_TIMER \
  445. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_TIMR)
  446. #define QLA82XX_CRB_XDMA \
  447. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_XDMA)
  448. #define QLA82XX_CRB_I2C0 \
  449. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2C0)
  450. #define QLA82XX_CRB_I2C1 \
  451. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2C1)
  452. #define QLA82XX_CRB_OCM0 \
  453. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_OCM0)
  454. #define QLA82XX_CRB_SMB \
  455. QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SMB)
  456. #define QLA82XX_CRB_MAX QLA82XX_PCI_CRB_WINDOW(64)
  457. /*
  458. * ====================== BASE ADDRESSES ON-CHIP ======================
  459. * Base addresses of major components on-chip.
  460. * ====================== BASE ADDRESSES ON-CHIP ======================
  461. */
  462. #define QLA8XXX_ADDR_DDR_NET (0x0000000000000000ULL)
  463. #define QLA8XXX_ADDR_DDR_NET_MAX (0x000000000fffffffULL)
  464. /* Imbus address bit used to indicate a host address. This bit is
  465. * eliminated by the pcie bar and bar select before presentation
  466. * over pcie. */
  467. /* host memory via IMBUS */
  468. #define QLA82XX_P2_ADDR_PCIE (0x0000000800000000ULL)
  469. #define QLA82XX_P3_ADDR_PCIE (0x0000008000000000ULL)
  470. #define QLA82XX_ADDR_PCIE_MAX (0x0000000FFFFFFFFFULL)
  471. #define QLA8XXX_ADDR_OCM0 (0x0000000200000000ULL)
  472. #define QLA8XXX_ADDR_OCM0_MAX (0x00000002000fffffULL)
  473. #define QLA8XXX_ADDR_OCM1 (0x0000000200400000ULL)
  474. #define QLA8XXX_ADDR_OCM1_MAX (0x00000002004fffffULL)
  475. #define QLA8XXX_ADDR_QDR_NET (0x0000000300000000ULL)
  476. #define QLA82XX_P2_ADDR_QDR_NET_MAX (0x00000003001fffffULL)
  477. #define QLA82XX_P3_ADDR_QDR_NET_MAX (0x0000000303ffffffULL)
  478. #define QLA8XXX_ADDR_QDR_NET_MAX (0x0000000307ffffffULL)
  479. #define QLA82XX_PCI_CRBSPACE (unsigned long)0x06000000
  480. #define QLA82XX_PCI_DIRECT_CRB (unsigned long)0x04400000
  481. #define QLA82XX_PCI_CAMQM (unsigned long)0x04800000
  482. #define QLA82XX_PCI_CAMQM_MAX (unsigned long)0x04ffffff
  483. #define QLA82XX_PCI_DDR_NET (unsigned long)0x00000000
  484. #define QLA82XX_PCI_QDR_NET (unsigned long)0x04000000
  485. #define QLA82XX_PCI_QDR_NET_MAX (unsigned long)0x043fffff
  486. /* PCI Windowing for DDR regions. */
  487. #define QLA8XXX_ADDR_IN_RANGE(addr, low, high) \
  488. (((addr) <= (high)) && ((addr) >= (low)))
  489. /*
  490. * Register offsets for MN
  491. */
  492. #define MIU_CONTROL (0x000)
  493. #define MIU_TAG (0x004)
  494. #define MIU_TEST_AGT_CTRL (0x090)
  495. #define MIU_TEST_AGT_ADDR_LO (0x094)
  496. #define MIU_TEST_AGT_ADDR_HI (0x098)
  497. #define MIU_TEST_AGT_WRDATA_LO (0x0a0)
  498. #define MIU_TEST_AGT_WRDATA_HI (0x0a4)
  499. #define MIU_TEST_AGT_WRDATA(i) (0x0a0+(4*(i)))
  500. #define MIU_TEST_AGT_RDDATA_LO (0x0a8)
  501. #define MIU_TEST_AGT_RDDATA_HI (0x0ac)
  502. #define MIU_TEST_AGT_RDDATA(i) (0x0a8+(4*(i)))
  503. #define MIU_TEST_AGT_ADDR_MASK 0xfffffff8
  504. #define MIU_TEST_AGT_UPPER_ADDR(off) (0)
  505. /* MIU_TEST_AGT_CTRL flags. work for SIU as well */
  506. #define MIU_TA_CTL_START 1
  507. #define MIU_TA_CTL_ENABLE 2
  508. #define MIU_TA_CTL_WRITE 4
  509. #define MIU_TA_CTL_BUSY 8
  510. #define MIU_TA_CTL_WRITE_ENABLE (MIU_TA_CTL_WRITE | MIU_TA_CTL_ENABLE)
  511. #define MIU_TA_CTL_WRITE_START (MIU_TA_CTL_WRITE | MIU_TA_CTL_ENABLE |\
  512. MIU_TA_CTL_START)
  513. #define MIU_TA_CTL_START_ENABLE (MIU_TA_CTL_START | MIU_TA_CTL_ENABLE)
  514. /*CAM RAM */
  515. # define QLA82XX_CAM_RAM_BASE (QLA82XX_CRB_CAM + 0x02000)
  516. # define QLA82XX_CAM_RAM(reg) (QLA82XX_CAM_RAM_BASE + (reg))
  517. #define QLA82XX_PORT_MODE_ADDR (QLA82XX_CAM_RAM(0x24))
  518. #define QLA82XX_PEG_HALT_STATUS1 (QLA82XX_CAM_RAM(0xa8))
  519. #define QLA82XX_PEG_HALT_STATUS2 (QLA82XX_CAM_RAM(0xac))
  520. #define QLA82XX_PEG_ALIVE_COUNTER (QLA82XX_CAM_RAM(0xb0))
  521. #define QLA82XX_CAM_RAM_DB1 (QLA82XX_CAM_RAM(0x1b0))
  522. #define QLA82XX_CAM_RAM_DB2 (QLA82XX_CAM_RAM(0x1b4))
  523. #define HALT_STATUS_UNRECOVERABLE 0x80000000
  524. #define HALT_STATUS_RECOVERABLE 0x40000000
  525. #define QLA82XX_ROM_LOCK_ID (QLA82XX_CAM_RAM(0x100))
  526. #define QLA82XX_CRB_WIN_LOCK_ID (QLA82XX_CAM_RAM(0x124))
  527. #define QLA82XX_FW_VERSION_MAJOR (QLA82XX_CAM_RAM(0x150))
  528. #define QLA82XX_FW_VERSION_MINOR (QLA82XX_CAM_RAM(0x154))
  529. #define QLA82XX_FW_VERSION_SUB (QLA82XX_CAM_RAM(0x158))
  530. #define QLA82XX_PCIE_REG(reg) (QLA82XX_CRB_PCIE + (reg))
  531. /* Driver Coexistence Defines */
  532. #define QLA82XX_CRB_DRV_ACTIVE (QLA82XX_CAM_RAM(0x138))
  533. #define QLA82XX_CRB_DEV_STATE (QLA82XX_CAM_RAM(0x140))
  534. #define QLA82XX_CRB_DRV_STATE (QLA82XX_CAM_RAM(0x144))
  535. #define QLA82XX_CRB_DRV_SCRATCH (QLA82XX_CAM_RAM(0x148))
  536. #define QLA82XX_CRB_DEV_PART_INFO (QLA82XX_CAM_RAM(0x14c))
  537. #define QLA82XX_CRB_DRV_IDC_VERSION (QLA82XX_CAM_RAM(0x174))
  538. enum qla_regs {
  539. QLA8XXX_PEG_HALT_STATUS1 = 0,
  540. QLA8XXX_PEG_HALT_STATUS2,
  541. QLA8XXX_PEG_ALIVE_COUNTER,
  542. QLA8XXX_CRB_DRV_ACTIVE,
  543. QLA8XXX_CRB_DEV_STATE,
  544. QLA8XXX_CRB_DRV_STATE,
  545. QLA8XXX_CRB_DRV_SCRATCH,
  546. QLA8XXX_CRB_DEV_PART_INFO,
  547. QLA8XXX_CRB_DRV_IDC_VERSION,
  548. QLA8XXX_FW_VERSION_MAJOR,
  549. QLA8XXX_FW_VERSION_MINOR,
  550. QLA8XXX_FW_VERSION_SUB,
  551. QLA8XXX_CRB_CMDPEG_STATE,
  552. QLA8XXX_CRB_TEMP_STATE,
  553. };
  554. static const uint32_t qla4_82xx_reg_tbl[] = {
  555. QLA82XX_PEG_HALT_STATUS1,
  556. QLA82XX_PEG_HALT_STATUS2,
  557. QLA82XX_PEG_ALIVE_COUNTER,
  558. QLA82XX_CRB_DRV_ACTIVE,
  559. QLA82XX_CRB_DEV_STATE,
  560. QLA82XX_CRB_DRV_STATE,
  561. QLA82XX_CRB_DRV_SCRATCH,
  562. QLA82XX_CRB_DEV_PART_INFO,
  563. QLA82XX_CRB_DRV_IDC_VERSION,
  564. QLA82XX_FW_VERSION_MAJOR,
  565. QLA82XX_FW_VERSION_MINOR,
  566. QLA82XX_FW_VERSION_SUB,
  567. CRB_CMDPEG_STATE,
  568. CRB_TEMP_STATE,
  569. };
  570. /* Every driver should use these Device State */
  571. #define QLA8XXX_DEV_COLD 1
  572. #define QLA8XXX_DEV_INITIALIZING 2
  573. #define QLA8XXX_DEV_READY 3
  574. #define QLA8XXX_DEV_NEED_RESET 4
  575. #define QLA8XXX_DEV_NEED_QUIESCENT 5
  576. #define QLA8XXX_DEV_FAILED 6
  577. #define QLA8XXX_DEV_QUIESCENT 7
  578. #define MAX_STATES 8 /* Increment if new state added */
  579. #define QLA82XX_IDC_VERSION 0x1
  580. #define ROM_DEV_INIT_TIMEOUT 30
  581. #define ROM_DRV_RESET_ACK_TIMEOUT 10
  582. #define PCIE_SETUP_FUNCTION (0x12040)
  583. #define PCIE_SETUP_FUNCTION2 (0x12048)
  584. #define QLA82XX_PCIX_PS_REG(reg) (QLA82XX_CRB_PCIX_MD + (reg))
  585. #define QLA82XX_PCIX_PS2_REG(reg) (QLA82XX_CRB_PCIE2 + (reg))
  586. #define PCIE_SEM2_LOCK (0x1c010) /* Flash lock */
  587. #define PCIE_SEM2_UNLOCK (0x1c014) /* Flash unlock */
  588. #define PCIE_SEM5_LOCK (0x1c028) /* Coexistence lock */
  589. #define PCIE_SEM5_UNLOCK (0x1c02c) /* Coexistence unlock */
  590. #define PCIE_SEM7_LOCK (0x1c038) /* crb win lock */
  591. #define PCIE_SEM7_UNLOCK (0x1c03c) /* crbwin unlock*/
  592. /*
  593. * The PCI VendorID and DeviceID for our board.
  594. */
  595. #define QLA82XX_MSIX_TBL_SPACE 8192
  596. #define QLA82XX_PCI_REG_MSIX_TBL 0x44
  597. #define QLA82XX_PCI_MSIX_CONTROL 0x40
  598. struct crb_128M_2M_sub_block_map {
  599. unsigned valid;
  600. unsigned start_128M;
  601. unsigned end_128M;
  602. unsigned start_2M;
  603. };
  604. struct crb_128M_2M_block_map {
  605. struct crb_128M_2M_sub_block_map sub_block[16];
  606. };
  607. struct crb_addr_pair {
  608. long addr;
  609. long data;
  610. };
  611. #define ADDR_ERROR ((unsigned long) 0xffffffff)
  612. #define MAX_CTL_CHECK 1000
  613. #define QLA82XX_FWERROR_CODE(code) ((code >> 8) & 0x1fffff)
  614. /***************************************************************************
  615. * PCI related defines.
  616. **************************************************************************/
  617. /*
  618. * Interrupt related defines.
  619. */
  620. #define PCIX_TARGET_STATUS (0x10118)
  621. #define PCIX_TARGET_STATUS_F1 (0x10160)
  622. #define PCIX_TARGET_STATUS_F2 (0x10164)
  623. #define PCIX_TARGET_STATUS_F3 (0x10168)
  624. #define PCIX_TARGET_STATUS_F4 (0x10360)
  625. #define PCIX_TARGET_STATUS_F5 (0x10364)
  626. #define PCIX_TARGET_STATUS_F6 (0x10368)
  627. #define PCIX_TARGET_STATUS_F7 (0x1036c)
  628. #define PCIX_TARGET_MASK (0x10128)
  629. #define PCIX_TARGET_MASK_F1 (0x10170)
  630. #define PCIX_TARGET_MASK_F2 (0x10174)
  631. #define PCIX_TARGET_MASK_F3 (0x10178)
  632. #define PCIX_TARGET_MASK_F4 (0x10370)
  633. #define PCIX_TARGET_MASK_F5 (0x10374)
  634. #define PCIX_TARGET_MASK_F6 (0x10378)
  635. #define PCIX_TARGET_MASK_F7 (0x1037c)
  636. /*
  637. * Message Signaled Interrupts
  638. */
  639. #define PCIX_MSI_F0 (0x13000)
  640. #define PCIX_MSI_F1 (0x13004)
  641. #define PCIX_MSI_F2 (0x13008)
  642. #define PCIX_MSI_F3 (0x1300c)
  643. #define PCIX_MSI_F4 (0x13010)
  644. #define PCIX_MSI_F5 (0x13014)
  645. #define PCIX_MSI_F6 (0x13018)
  646. #define PCIX_MSI_F7 (0x1301c)
  647. #define PCIX_MSI_F(FUNC) (0x13000 + ((FUNC) * 4))
  648. /*
  649. *
  650. */
  651. #define PCIX_INT_VECTOR (0x10100)
  652. #define PCIX_INT_MASK (0x10104)
  653. /*
  654. * Interrupt state machine and other bits.
  655. */
  656. #define PCIE_MISCCFG_RC (0x1206c)
  657. #define ISR_INT_TARGET_STATUS \
  658. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS))
  659. #define ISR_INT_TARGET_STATUS_F1 \
  660. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F1))
  661. #define ISR_INT_TARGET_STATUS_F2 \
  662. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F2))
  663. #define ISR_INT_TARGET_STATUS_F3 \
  664. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F3))
  665. #define ISR_INT_TARGET_STATUS_F4 \
  666. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F4))
  667. #define ISR_INT_TARGET_STATUS_F5 \
  668. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F5))
  669. #define ISR_INT_TARGET_STATUS_F6 \
  670. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F6))
  671. #define ISR_INT_TARGET_STATUS_F7 \
  672. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F7))
  673. #define ISR_INT_TARGET_MASK \
  674. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK))
  675. #define ISR_INT_TARGET_MASK_F1 \
  676. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F1))
  677. #define ISR_INT_TARGET_MASK_F2 \
  678. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F2))
  679. #define ISR_INT_TARGET_MASK_F3 \
  680. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F3))
  681. #define ISR_INT_TARGET_MASK_F4 \
  682. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F4))
  683. #define ISR_INT_TARGET_MASK_F5 \
  684. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F5))
  685. #define ISR_INT_TARGET_MASK_F6 \
  686. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F6))
  687. #define ISR_INT_TARGET_MASK_F7 \
  688. (QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F7))
  689. #define ISR_INT_VECTOR (QLA82XX_PCIX_PS_REG(PCIX_INT_VECTOR))
  690. #define ISR_INT_MASK (QLA82XX_PCIX_PS_REG(PCIX_INT_MASK))
  691. #define ISR_INT_STATE_REG (QLA82XX_PCIX_PS_REG(PCIE_MISCCFG_RC))
  692. #define ISR_MSI_INT_TRIGGER(FUNC) (QLA82XX_PCIX_PS_REG(PCIX_MSI_F(FUNC)))
  693. #define ISR_IS_LEGACY_INTR_IDLE(VAL) (((VAL) & 0x300) == 0)
  694. #define ISR_IS_LEGACY_INTR_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200)
  695. /*
  696. * PCI Interrupt Vector Values.
  697. */
  698. #define PCIX_INT_VECTOR_BIT_F0 0x0080
  699. #define PCIX_INT_VECTOR_BIT_F1 0x0100
  700. #define PCIX_INT_VECTOR_BIT_F2 0x0200
  701. #define PCIX_INT_VECTOR_BIT_F3 0x0400
  702. #define PCIX_INT_VECTOR_BIT_F4 0x0800
  703. #define PCIX_INT_VECTOR_BIT_F5 0x1000
  704. #define PCIX_INT_VECTOR_BIT_F6 0x2000
  705. #define PCIX_INT_VECTOR_BIT_F7 0x4000
  706. /* struct qla4_8xxx_legacy_intr_set defined in ql4_def.h */
  707. #define QLA82XX_LEGACY_INTR_CONFIG \
  708. { \
  709. { \
  710. .int_vec_bit = PCIX_INT_VECTOR_BIT_F0, \
  711. .tgt_status_reg = ISR_INT_TARGET_STATUS, \
  712. .tgt_mask_reg = ISR_INT_TARGET_MASK, \
  713. .pci_int_reg = ISR_MSI_INT_TRIGGER(0) }, \
  714. \
  715. { \
  716. .int_vec_bit = PCIX_INT_VECTOR_BIT_F1, \
  717. .tgt_status_reg = ISR_INT_TARGET_STATUS_F1, \
  718. .tgt_mask_reg = ISR_INT_TARGET_MASK_F1, \
  719. .pci_int_reg = ISR_MSI_INT_TRIGGER(1) }, \
  720. \
  721. { \
  722. .int_vec_bit = PCIX_INT_VECTOR_BIT_F2, \
  723. .tgt_status_reg = ISR_INT_TARGET_STATUS_F2, \
  724. .tgt_mask_reg = ISR_INT_TARGET_MASK_F2, \
  725. .pci_int_reg = ISR_MSI_INT_TRIGGER(2) }, \
  726. \
  727. { \
  728. .int_vec_bit = PCIX_INT_VECTOR_BIT_F3, \
  729. .tgt_status_reg = ISR_INT_TARGET_STATUS_F3, \
  730. .tgt_mask_reg = ISR_INT_TARGET_MASK_F3, \
  731. .pci_int_reg = ISR_MSI_INT_TRIGGER(3) }, \
  732. \
  733. { \
  734. .int_vec_bit = PCIX_INT_VECTOR_BIT_F4, \
  735. .tgt_status_reg = ISR_INT_TARGET_STATUS_F4, \
  736. .tgt_mask_reg = ISR_INT_TARGET_MASK_F4, \
  737. .pci_int_reg = ISR_MSI_INT_TRIGGER(4) }, \
  738. \
  739. { \
  740. .int_vec_bit = PCIX_INT_VECTOR_BIT_F5, \
  741. .tgt_status_reg = ISR_INT_TARGET_STATUS_F5, \
  742. .tgt_mask_reg = ISR_INT_TARGET_MASK_F5, \
  743. .pci_int_reg = ISR_MSI_INT_TRIGGER(5) }, \
  744. \
  745. { \
  746. .int_vec_bit = PCIX_INT_VECTOR_BIT_F6, \
  747. .tgt_status_reg = ISR_INT_TARGET_STATUS_F6, \
  748. .tgt_mask_reg = ISR_INT_TARGET_MASK_F6, \
  749. .pci_int_reg = ISR_MSI_INT_TRIGGER(6) }, \
  750. \
  751. { \
  752. .int_vec_bit = PCIX_INT_VECTOR_BIT_F7, \
  753. .tgt_status_reg = ISR_INT_TARGET_STATUS_F7, \
  754. .tgt_mask_reg = ISR_INT_TARGET_MASK_F7, \
  755. .pci_int_reg = ISR_MSI_INT_TRIGGER(7) }, \
  756. }
  757. /* Magic number to let user know flash is programmed */
  758. #define QLA82XX_BDINFO_MAGIC 0x12345678
  759. #define FW_SIZE_OFFSET (0x3e840c)
  760. /* QLA82XX additions */
  761. #define MIU_TEST_AGT_WRDATA_UPPER_LO (0x0b0)
  762. #define MIU_TEST_AGT_WRDATA_UPPER_HI (0x0b4)
  763. /* Minidump related */
  764. /* Entry Type Defines */
  765. #define QLA8XXX_RDNOP 0
  766. #define QLA8XXX_RDCRB 1
  767. #define QLA8XXX_RDMUX 2
  768. #define QLA8XXX_QUEUE 3
  769. #define QLA8XXX_BOARD 4
  770. #define QLA8XXX_RDOCM 6
  771. #define QLA8XXX_PREGS 7
  772. #define QLA8XXX_L1DTG 8
  773. #define QLA8XXX_L1ITG 9
  774. #define QLA8XXX_L1DAT 11
  775. #define QLA8XXX_L1INS 12
  776. #define QLA8XXX_L2DTG 21
  777. #define QLA8XXX_L2ITG 22
  778. #define QLA8XXX_L2DAT 23
  779. #define QLA8XXX_L2INS 24
  780. #define QLA83XX_POLLRD 35
  781. #define QLA83XX_RDMUX2 36
  782. #define QLA83XX_POLLRDMWR 37
  783. #define QLA8044_RDDFE 38
  784. #define QLA8044_RDMDIO 39
  785. #define QLA8044_POLLWR 40
  786. #define QLA8XXX_RDROM 71
  787. #define QLA8XXX_RDMEM 72
  788. #define QLA8XXX_CNTRL 98
  789. #define QLA83XX_TLHDR 99
  790. #define QLA8XXX_RDEND 255
  791. /* Opcodes for Control Entries.
  792. * These Flags are bit fields.
  793. */
  794. #define QLA8XXX_DBG_OPCODE_WR 0x01
  795. #define QLA8XXX_DBG_OPCODE_RW 0x02
  796. #define QLA8XXX_DBG_OPCODE_AND 0x04
  797. #define QLA8XXX_DBG_OPCODE_OR 0x08
  798. #define QLA8XXX_DBG_OPCODE_POLL 0x10
  799. #define QLA8XXX_DBG_OPCODE_RDSTATE 0x20
  800. #define QLA8XXX_DBG_OPCODE_WRSTATE 0x40
  801. #define QLA8XXX_DBG_OPCODE_MDSTATE 0x80
  802. /* Driver Flags */
  803. #define QLA8XXX_DBG_SKIPPED_FLAG 0x80 /* driver skipped this entry */
  804. #define QLA8XXX_DBG_SIZE_ERR_FLAG 0x40 /* Entry vs Capture size
  805. * mismatch */
  806. /* Driver_code is for driver to write some info about the entry
  807. * currently not used.
  808. */
  809. struct qla8xxx_minidump_entry_hdr {
  810. uint32_t entry_type;
  811. uint32_t entry_size;
  812. uint32_t entry_capture_size;
  813. struct {
  814. uint8_t entry_capture_mask;
  815. uint8_t entry_code;
  816. uint8_t driver_code;
  817. uint8_t driver_flags;
  818. } d_ctrl;
  819. };
  820. /* Read CRB entry header */
  821. struct qla8xxx_minidump_entry_crb {
  822. struct qla8xxx_minidump_entry_hdr h;
  823. uint32_t addr;
  824. struct {
  825. uint8_t addr_stride;
  826. uint8_t state_index_a;
  827. uint16_t poll_timeout;
  828. } crb_strd;
  829. uint32_t data_size;
  830. uint32_t op_count;
  831. struct {
  832. uint8_t opcode;
  833. uint8_t state_index_v;
  834. uint8_t shl;
  835. uint8_t shr;
  836. } crb_ctrl;
  837. uint32_t value_1;
  838. uint32_t value_2;
  839. uint32_t value_3;
  840. };
  841. struct qla8xxx_minidump_entry_cache {
  842. struct qla8xxx_minidump_entry_hdr h;
  843. uint32_t tag_reg_addr;
  844. struct {
  845. uint16_t tag_value_stride;
  846. uint16_t init_tag_value;
  847. } addr_ctrl;
  848. uint32_t data_size;
  849. uint32_t op_count;
  850. uint32_t control_addr;
  851. struct {
  852. uint16_t write_value;
  853. uint8_t poll_mask;
  854. uint8_t poll_wait;
  855. } cache_ctrl;
  856. uint32_t read_addr;
  857. struct {
  858. uint8_t read_addr_stride;
  859. uint8_t read_addr_cnt;
  860. uint16_t rsvd_1;
  861. } read_ctrl;
  862. };
  863. /* Read OCM */
  864. struct qla8xxx_minidump_entry_rdocm {
  865. struct qla8xxx_minidump_entry_hdr h;
  866. uint32_t rsvd_0;
  867. uint32_t rsvd_1;
  868. uint32_t data_size;
  869. uint32_t op_count;
  870. uint32_t rsvd_2;
  871. uint32_t rsvd_3;
  872. uint32_t read_addr;
  873. uint32_t read_addr_stride;
  874. };
  875. /* Read Memory */
  876. struct qla8xxx_minidump_entry_rdmem {
  877. struct qla8xxx_minidump_entry_hdr h;
  878. uint32_t rsvd[6];
  879. uint32_t read_addr;
  880. uint32_t read_data_size;
  881. };
  882. /* Read ROM */
  883. struct qla8xxx_minidump_entry_rdrom {
  884. struct qla8xxx_minidump_entry_hdr h;
  885. uint32_t rsvd[6];
  886. uint32_t read_addr;
  887. uint32_t read_data_size;
  888. };
  889. /* Mux entry */
  890. struct qla8xxx_minidump_entry_mux {
  891. struct qla8xxx_minidump_entry_hdr h;
  892. uint32_t select_addr;
  893. uint32_t rsvd_0;
  894. uint32_t data_size;
  895. uint32_t op_count;
  896. uint32_t select_value;
  897. uint32_t select_value_stride;
  898. uint32_t read_addr;
  899. uint32_t rsvd_1;
  900. };
  901. /* Queue entry */
  902. struct qla8xxx_minidump_entry_queue {
  903. struct qla8xxx_minidump_entry_hdr h;
  904. uint32_t select_addr;
  905. struct {
  906. uint16_t queue_id_stride;
  907. uint16_t rsvd_0;
  908. } q_strd;
  909. uint32_t data_size;
  910. uint32_t op_count;
  911. uint32_t rsvd_1;
  912. uint32_t rsvd_2;
  913. uint32_t read_addr;
  914. struct {
  915. uint8_t read_addr_stride;
  916. uint8_t read_addr_cnt;
  917. uint16_t rsvd_3;
  918. } rd_strd;
  919. };
  920. #define MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE 0x129
  921. #define RQST_TMPLT_SIZE 0x0
  922. #define RQST_TMPLT 0x1
  923. #define MD_DIRECT_ROM_WINDOW 0x42110030
  924. #define MD_DIRECT_ROM_READ_BASE 0x42150000
  925. #define MD_MIU_TEST_AGT_CTRL 0x41000090
  926. #define MD_MIU_TEST_AGT_ADDR_LO 0x41000094
  927. #define MD_MIU_TEST_AGT_ADDR_HI 0x41000098
  928. #define MD_MIU_TEST_AGT_WRDATA_LO 0x410000A0
  929. #define MD_MIU_TEST_AGT_WRDATA_HI 0x410000A4
  930. #define MD_MIU_TEST_AGT_WRDATA_ULO 0x410000B0
  931. #define MD_MIU_TEST_AGT_WRDATA_UHI 0x410000B4
  932. #define MD_MIU_TEST_AGT_RDDATA_LO 0x410000A8
  933. #define MD_MIU_TEST_AGT_RDDATA_HI 0x410000AC
  934. #define MD_MIU_TEST_AGT_RDDATA_ULO 0x410000B8
  935. #define MD_MIU_TEST_AGT_RDDATA_UHI 0x410000BC
  936. static const int MD_MIU_TEST_AGT_RDDATA[] = { 0x410000A8,
  937. 0x410000AC, 0x410000B8, 0x410000BC };
  938. #endif