bnx2x_init.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. /* bnx2x_init.h: Broadcom Everest network driver.
  2. * Structures and macroes needed during the initialization.
  3. *
  4. * Copyright (c) 2007-2011 Broadcom Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation.
  9. *
  10. * Maintained by: Eilon Greenstein <eilong@broadcom.com>
  11. * Written by: Eliezer Tamir
  12. * Modified by: Vladislav Zolotarov <vladz@broadcom.com>
  13. */
  14. #ifndef BNX2X_INIT_H
  15. #define BNX2X_INIT_H
  16. /* RAM0 size in bytes */
  17. #define STORM_INTMEM_SIZE_E1 0x5800
  18. #define STORM_INTMEM_SIZE_E1H 0x10000
  19. #define STORM_INTMEM_SIZE(bp) ((CHIP_IS_E1(bp) ? STORM_INTMEM_SIZE_E1 : \
  20. STORM_INTMEM_SIZE_E1H) / 4)
  21. /* Init operation types and structures */
  22. /* Common for both E1 and E1H */
  23. #define OP_RD 0x1 /* read single register */
  24. #define OP_WR 0x2 /* write single register */
  25. #define OP_IW 0x3 /* write single register using mailbox */
  26. #define OP_SW 0x4 /* copy a string to the device */
  27. #define OP_SI 0x5 /* copy a string using mailbox */
  28. #define OP_ZR 0x6 /* clear memory */
  29. #define OP_ZP 0x7 /* unzip then copy with DMAE */
  30. #define OP_WR_64 0x8 /* write 64 bit pattern */
  31. #define OP_WB 0x9 /* copy a string using DMAE */
  32. /* FPGA and EMUL specific operations */
  33. #define OP_WR_EMUL 0xa /* write single register on Emulation */
  34. #define OP_WR_FPGA 0xb /* write single register on FPGA */
  35. #define OP_WR_ASIC 0xc /* write single register on ASIC */
  36. /* Init stages */
  37. /* Never reorder stages !!! */
  38. #define COMMON_STAGE 0
  39. #define PORT0_STAGE 1
  40. #define PORT1_STAGE 2
  41. #define FUNC0_STAGE 3
  42. #define FUNC1_STAGE 4
  43. #define FUNC2_STAGE 5
  44. #define FUNC3_STAGE 6
  45. #define FUNC4_STAGE 7
  46. #define FUNC5_STAGE 8
  47. #define FUNC6_STAGE 9
  48. #define FUNC7_STAGE 10
  49. #define STAGE_IDX_MAX 11
  50. #define STAGE_START 0
  51. #define STAGE_END 1
  52. /* Indices of blocks */
  53. #define PRS_BLOCK 0
  54. #define SRCH_BLOCK 1
  55. #define TSDM_BLOCK 2
  56. #define TCM_BLOCK 3
  57. #define BRB1_BLOCK 4
  58. #define TSEM_BLOCK 5
  59. #define PXPCS_BLOCK 6
  60. #define EMAC0_BLOCK 7
  61. #define EMAC1_BLOCK 8
  62. #define DBU_BLOCK 9
  63. #define MISC_BLOCK 10
  64. #define DBG_BLOCK 11
  65. #define NIG_BLOCK 12
  66. #define MCP_BLOCK 13
  67. #define UPB_BLOCK 14
  68. #define CSDM_BLOCK 15
  69. #define USDM_BLOCK 16
  70. #define CCM_BLOCK 17
  71. #define UCM_BLOCK 18
  72. #define USEM_BLOCK 19
  73. #define CSEM_BLOCK 20
  74. #define XPB_BLOCK 21
  75. #define DQ_BLOCK 22
  76. #define TIMERS_BLOCK 23
  77. #define XSDM_BLOCK 24
  78. #define QM_BLOCK 25
  79. #define PBF_BLOCK 26
  80. #define XCM_BLOCK 27
  81. #define XSEM_BLOCK 28
  82. #define CDU_BLOCK 29
  83. #define DMAE_BLOCK 30
  84. #define PXP_BLOCK 31
  85. #define CFC_BLOCK 32
  86. #define HC_BLOCK 33
  87. #define PXP2_BLOCK 34
  88. #define MISC_AEU_BLOCK 35
  89. #define PGLUE_B_BLOCK 36
  90. #define IGU_BLOCK 37
  91. #define ATC_BLOCK 38
  92. #define QM_4PORT_BLOCK 39
  93. #define XSEM_4PORT_BLOCK 40
  94. /* Returns the index of start or end of a specific block stage in ops array*/
  95. #define BLOCK_OPS_IDX(block, stage, end) \
  96. (2*(((block)*STAGE_IDX_MAX) + (stage)) + (end))
  97. struct raw_op {
  98. u32 op:8;
  99. u32 offset:24;
  100. u32 raw_data;
  101. };
  102. struct op_read {
  103. u32 op:8;
  104. u32 offset:24;
  105. u32 pad;
  106. };
  107. struct op_write {
  108. u32 op:8;
  109. u32 offset:24;
  110. u32 val;
  111. };
  112. struct op_string_write {
  113. u32 op:8;
  114. u32 offset:24;
  115. #ifdef __LITTLE_ENDIAN
  116. u16 data_off;
  117. u16 data_len;
  118. #else /* __BIG_ENDIAN */
  119. u16 data_len;
  120. u16 data_off;
  121. #endif
  122. };
  123. struct op_zero {
  124. u32 op:8;
  125. u32 offset:24;
  126. u32 len;
  127. };
  128. union init_op {
  129. struct op_read read;
  130. struct op_write write;
  131. struct op_string_write str_wr;
  132. struct op_zero zero;
  133. struct raw_op raw;
  134. };
  135. #define INITOP_SET 0 /* set the HW directly */
  136. #define INITOP_CLEAR 1 /* clear the HW directly */
  137. #define INITOP_INIT 2 /* set the init-value array */
  138. /****************************************************************************
  139. * ILT management
  140. ****************************************************************************/
  141. struct ilt_line {
  142. dma_addr_t page_mapping;
  143. void *page;
  144. u32 size;
  145. };
  146. struct ilt_client_info {
  147. u32 page_size;
  148. u16 start;
  149. u16 end;
  150. u16 client_num;
  151. u16 flags;
  152. #define ILT_CLIENT_SKIP_INIT 0x1
  153. #define ILT_CLIENT_SKIP_MEM 0x2
  154. };
  155. struct bnx2x_ilt {
  156. u32 start_line;
  157. struct ilt_line *lines;
  158. struct ilt_client_info clients[4];
  159. #define ILT_CLIENT_CDU 0
  160. #define ILT_CLIENT_QM 1
  161. #define ILT_CLIENT_SRC 2
  162. #define ILT_CLIENT_TM 3
  163. };
  164. /****************************************************************************
  165. * SRC configuration
  166. ****************************************************************************/
  167. struct src_ent {
  168. u8 opaque[56];
  169. u64 next;
  170. };
  171. /****************************************************************************
  172. * Parity configuration
  173. ****************************************************************************/
  174. #define BLOCK_PRTY_INFO(block, en_mask, m1, m1h, m2) \
  175. { \
  176. block##_REG_##block##_PRTY_MASK, \
  177. block##_REG_##block##_PRTY_STS_CLR, \
  178. en_mask, {m1, m1h, m2}, #block \
  179. }
  180. #define BLOCK_PRTY_INFO_0(block, en_mask, m1, m1h, m2) \
  181. { \
  182. block##_REG_##block##_PRTY_MASK_0, \
  183. block##_REG_##block##_PRTY_STS_CLR_0, \
  184. en_mask, {m1, m1h, m2}, #block"_0" \
  185. }
  186. #define BLOCK_PRTY_INFO_1(block, en_mask, m1, m1h, m2) \
  187. { \
  188. block##_REG_##block##_PRTY_MASK_1, \
  189. block##_REG_##block##_PRTY_STS_CLR_1, \
  190. en_mask, {m1, m1h, m2}, #block"_1" \
  191. }
  192. static const struct {
  193. u32 mask_addr;
  194. u32 sts_clr_addr;
  195. u32 en_mask; /* Mask to enable parity attentions */
  196. struct {
  197. u32 e1; /* 57710 */
  198. u32 e1h; /* 57711 */
  199. u32 e2; /* 57712 */
  200. } reg_mask; /* Register mask (all valid bits) */
  201. char name[7]; /* Block's longest name is 6 characters long
  202. * (name + suffix)
  203. */
  204. } bnx2x_blocks_parity_data[] = {
  205. /* bit 19 masked */
  206. /* REG_WR(bp, PXP_REG_PXP_PRTY_MASK, 0x80000); */
  207. /* bit 5,18,20-31 */
  208. /* REG_WR(bp, PXP2_REG_PXP2_PRTY_MASK_0, 0xfff40020); */
  209. /* bit 5 */
  210. /* REG_WR(bp, PXP2_REG_PXP2_PRTY_MASK_1, 0x20); */
  211. /* REG_WR(bp, HC_REG_HC_PRTY_MASK, 0x0); */
  212. /* REG_WR(bp, MISC_REG_MISC_PRTY_MASK, 0x0); */
  213. /* Block IGU, MISC, PXP and PXP2 parity errors as long as we don't
  214. * want to handle "system kill" flow at the moment.
  215. */
  216. BLOCK_PRTY_INFO(PXP, 0x7ffffff, 0x3ffffff, 0x3ffffff, 0x7ffffff),
  217. BLOCK_PRTY_INFO_0(PXP2, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff),
  218. BLOCK_PRTY_INFO_1(PXP2, 0x7ff, 0x7f, 0x7f, 0x7ff),
  219. BLOCK_PRTY_INFO(HC, 0x7, 0x7, 0x7, 0),
  220. BLOCK_PRTY_INFO(IGU, 0x7ff, 0, 0, 0x7ff),
  221. BLOCK_PRTY_INFO(MISC, 0x1, 0x1, 0x1, 0x1),
  222. BLOCK_PRTY_INFO(QM, 0, 0x1ff, 0xfff, 0xfff),
  223. BLOCK_PRTY_INFO(DORQ, 0, 0x3, 0x3, 0x3),
  224. {GRCBASE_UPB + PB_REG_PB_PRTY_MASK,
  225. GRCBASE_UPB + PB_REG_PB_PRTY_STS_CLR, 0,
  226. {0xf, 0xf, 0xf}, "UPB"},
  227. {GRCBASE_XPB + PB_REG_PB_PRTY_MASK,
  228. GRCBASE_XPB + PB_REG_PB_PRTY_STS_CLR, 0,
  229. {0xf, 0xf, 0xf}, "XPB"},
  230. BLOCK_PRTY_INFO(SRC, 0x4, 0x7, 0x7, 0x7),
  231. BLOCK_PRTY_INFO(CDU, 0, 0x1f, 0x1f, 0x1f),
  232. BLOCK_PRTY_INFO(CFC, 0, 0xf, 0xf, 0xf),
  233. BLOCK_PRTY_INFO(DBG, 0, 0x1, 0x1, 0x1),
  234. BLOCK_PRTY_INFO(DMAE, 0, 0xf, 0xf, 0xf),
  235. BLOCK_PRTY_INFO(BRB1, 0, 0xf, 0xf, 0xf),
  236. BLOCK_PRTY_INFO(PRS, (1<<6), 0xff, 0xff, 0xff),
  237. BLOCK_PRTY_INFO(TSDM, 0x18, 0x7ff, 0x7ff, 0x7ff),
  238. BLOCK_PRTY_INFO(CSDM, 0x8, 0x7ff, 0x7ff, 0x7ff),
  239. BLOCK_PRTY_INFO(USDM, 0x38, 0x7ff, 0x7ff, 0x7ff),
  240. BLOCK_PRTY_INFO(XSDM, 0x8, 0x7ff, 0x7ff, 0x7ff),
  241. BLOCK_PRTY_INFO_0(TSEM, 0, 0xffffffff, 0xffffffff, 0xffffffff),
  242. BLOCK_PRTY_INFO_1(TSEM, 0, 0x3, 0x1f, 0x3f),
  243. BLOCK_PRTY_INFO_0(USEM, 0, 0xffffffff, 0xffffffff, 0xffffffff),
  244. BLOCK_PRTY_INFO_1(USEM, 0, 0x3, 0x1f, 0x1f),
  245. BLOCK_PRTY_INFO_0(CSEM, 0, 0xffffffff, 0xffffffff, 0xffffffff),
  246. BLOCK_PRTY_INFO_1(CSEM, 0, 0x3, 0x1f, 0x1f),
  247. BLOCK_PRTY_INFO_0(XSEM, 0, 0xffffffff, 0xffffffff, 0xffffffff),
  248. BLOCK_PRTY_INFO_1(XSEM, 0, 0x3, 0x1f, 0x3f),
  249. };
  250. /* [28] MCP Latched rom_parity
  251. * [29] MCP Latched ump_rx_parity
  252. * [30] MCP Latched ump_tx_parity
  253. * [31] MCP Latched scpad_parity
  254. */
  255. #define MISC_AEU_ENABLE_MCP_PRTY_BITS \
  256. (AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \
  257. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \
  258. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY | \
  259. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY)
  260. /* Below registers control the MCP parity attention output. When
  261. * MISC_AEU_ENABLE_MCP_PRTY_BITS are set - attentions are
  262. * enabled, when cleared - disabled.
  263. */
  264. static const u32 mcp_attn_ctl_regs[] = {
  265. MISC_REG_AEU_ENABLE4_FUNC_0_OUT_0,
  266. MISC_REG_AEU_ENABLE4_NIG_0,
  267. MISC_REG_AEU_ENABLE4_PXP_0,
  268. MISC_REG_AEU_ENABLE4_FUNC_1_OUT_0,
  269. MISC_REG_AEU_ENABLE4_NIG_1,
  270. MISC_REG_AEU_ENABLE4_PXP_1
  271. };
  272. static inline void bnx2x_set_mcp_parity(struct bnx2x *bp, u8 enable)
  273. {
  274. int i;
  275. u32 reg_val;
  276. for (i = 0; i < ARRAY_SIZE(mcp_attn_ctl_regs); i++) {
  277. reg_val = REG_RD(bp, mcp_attn_ctl_regs[i]);
  278. if (enable)
  279. reg_val |= MISC_AEU_ENABLE_MCP_PRTY_BITS;
  280. else
  281. reg_val &= ~MISC_AEU_ENABLE_MCP_PRTY_BITS;
  282. REG_WR(bp, mcp_attn_ctl_regs[i], reg_val);
  283. }
  284. }
  285. static inline u32 bnx2x_parity_reg_mask(struct bnx2x *bp, int idx)
  286. {
  287. if (CHIP_IS_E1(bp))
  288. return bnx2x_blocks_parity_data[idx].reg_mask.e1;
  289. else if (CHIP_IS_E1H(bp))
  290. return bnx2x_blocks_parity_data[idx].reg_mask.e1h;
  291. else
  292. return bnx2x_blocks_parity_data[idx].reg_mask.e2;
  293. }
  294. static inline void bnx2x_disable_blocks_parity(struct bnx2x *bp)
  295. {
  296. int i;
  297. for (i = 0; i < ARRAY_SIZE(bnx2x_blocks_parity_data); i++) {
  298. u32 dis_mask = bnx2x_parity_reg_mask(bp, i);
  299. if (dis_mask) {
  300. REG_WR(bp, bnx2x_blocks_parity_data[i].mask_addr,
  301. dis_mask);
  302. DP(NETIF_MSG_HW, "Setting parity mask "
  303. "for %s to\t\t0x%x\n",
  304. bnx2x_blocks_parity_data[i].name, dis_mask);
  305. }
  306. }
  307. /* Disable MCP parity attentions */
  308. bnx2x_set_mcp_parity(bp, false);
  309. }
  310. /**
  311. * Clear the parity error status registers.
  312. */
  313. static inline void bnx2x_clear_blocks_parity(struct bnx2x *bp)
  314. {
  315. int i;
  316. u32 reg_val, mcp_aeu_bits =
  317. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY |
  318. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY |
  319. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY |
  320. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY;
  321. /* Clear SEM_FAST parities */
  322. REG_WR(bp, XSEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
  323. REG_WR(bp, TSEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
  324. REG_WR(bp, USEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
  325. REG_WR(bp, CSEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
  326. for (i = 0; i < ARRAY_SIZE(bnx2x_blocks_parity_data); i++) {
  327. u32 reg_mask = bnx2x_parity_reg_mask(bp, i);
  328. if (reg_mask) {
  329. reg_val = REG_RD(bp, bnx2x_blocks_parity_data[i].
  330. sts_clr_addr);
  331. if (reg_val & reg_mask)
  332. DP(NETIF_MSG_HW,
  333. "Parity errors in %s: 0x%x\n",
  334. bnx2x_blocks_parity_data[i].name,
  335. reg_val & reg_mask);
  336. }
  337. }
  338. /* Check if there were parity attentions in MCP */
  339. reg_val = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_4_MCP);
  340. if (reg_val & mcp_aeu_bits)
  341. DP(NETIF_MSG_HW, "Parity error in MCP: 0x%x\n",
  342. reg_val & mcp_aeu_bits);
  343. /* Clear parity attentions in MCP:
  344. * [7] clears Latched rom_parity
  345. * [8] clears Latched ump_rx_parity
  346. * [9] clears Latched ump_tx_parity
  347. * [10] clears Latched scpad_parity (both ports)
  348. */
  349. REG_WR(bp, MISC_REG_AEU_CLR_LATCH_SIGNAL, 0x780);
  350. }
  351. static inline void bnx2x_enable_blocks_parity(struct bnx2x *bp)
  352. {
  353. int i;
  354. for (i = 0; i < ARRAY_SIZE(bnx2x_blocks_parity_data); i++) {
  355. u32 reg_mask = bnx2x_parity_reg_mask(bp, i);
  356. if (reg_mask)
  357. REG_WR(bp, bnx2x_blocks_parity_data[i].mask_addr,
  358. bnx2x_blocks_parity_data[i].en_mask & reg_mask);
  359. }
  360. /* Enable MCP parity attentions */
  361. bnx2x_set_mcp_parity(bp, true);
  362. }
  363. #endif /* BNX2X_INIT_H */