diff options
Diffstat (limited to 'drivers/net/bnx2x_init.h')
-rw-r--r-- | drivers/net/bnx2x_init.h | 605 |
1 files changed, 69 insertions, 536 deletions
diff --git a/drivers/net/bnx2x_init.h b/drivers/net/bnx2x_init.h index 39ba2936c0c2..3ba4d888068f 100644 --- a/drivers/net/bnx2x_init.h +++ b/drivers/net/bnx2x_init.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* bnx2x_init.h: Broadcom Everest network driver. | 1 | /* bnx2x_init.h: Broadcom Everest network driver. |
2 | * Structures and macroes needed during the initialization. | ||
2 | * | 3 | * |
3 | * Copyright (c) 2007-2009 Broadcom Corporation | 4 | * Copyright (c) 2007-2009 Broadcom Corporation |
4 | * | 5 | * |
@@ -8,6 +9,7 @@ | |||
8 | * | 9 | * |
9 | * Maintained by: Eilon Greenstein <eilong@broadcom.com> | 10 | * Maintained by: Eilon Greenstein <eilong@broadcom.com> |
10 | * Written by: Eliezer Tamir | 11 | * Written by: Eliezer Tamir |
12 | * Modified by: Vladislav Zolotarov <vladz@broadcom.com> | ||
11 | */ | 13 | */ |
12 | 14 | ||
13 | #ifndef BNX2X_INIT_H | 15 | #ifndef BNX2X_INIT_H |
@@ -45,33 +47,71 @@ | |||
45 | #define OP_WR_64 0x8 /* write 64 bit pattern */ | 47 | #define OP_WR_64 0x8 /* write 64 bit pattern */ |
46 | #define OP_WB 0x9 /* copy a string using DMAE */ | 48 | #define OP_WB 0x9 /* copy a string using DMAE */ |
47 | 49 | ||
48 | /* Operation specific for E1 */ | ||
49 | #define OP_RD_E1 0xa /* read single register */ | ||
50 | #define OP_WR_E1 0xb /* write single register */ | ||
51 | #define OP_IW_E1 0xc /* write single register using mailbox */ | ||
52 | #define OP_SW_E1 0xd /* copy a string to the device */ | ||
53 | #define OP_SI_E1 0xe /* copy a string using mailbox */ | ||
54 | #define OP_ZR_E1 0xf /* clear memory */ | ||
55 | #define OP_ZP_E1 0x10 /* unzip then copy with DMAE */ | ||
56 | #define OP_WR_64_E1 0x11 /* write 64 bit pattern on E1 */ | ||
57 | #define OP_WB_E1 0x12 /* copy a string using DMAE */ | ||
58 | |||
59 | /* Operation specific for E1H */ | ||
60 | #define OP_RD_E1H 0x13 /* read single register */ | ||
61 | #define OP_WR_E1H 0x14 /* write single register */ | ||
62 | #define OP_IW_E1H 0x15 /* write single register using mailbox */ | ||
63 | #define OP_SW_E1H 0x16 /* copy a string to the device */ | ||
64 | #define OP_SI_E1H 0x17 /* copy a string using mailbox */ | ||
65 | #define OP_ZR_E1H 0x18 /* clear memory */ | ||
66 | #define OP_ZP_E1H 0x19 /* unzip then copy with DMAE */ | ||
67 | #define OP_WR_64_E1H 0x1a /* write 64 bit pattern on E1H */ | ||
68 | #define OP_WB_E1H 0x1b /* copy a string using DMAE */ | ||
69 | |||
70 | /* FPGA and EMUL specific operations */ | 50 | /* FPGA and EMUL specific operations */ |
71 | #define OP_WR_EMUL_E1H 0x1c /* write single register on E1H Emul */ | 51 | #define OP_WR_EMUL 0xa /* write single register on Emulation */ |
72 | #define OP_WR_EMUL 0x1d /* write single register on Emulation */ | 52 | #define OP_WR_FPGA 0xb /* write single register on FPGA */ |
73 | #define OP_WR_FPGA 0x1e /* write single register on FPGA */ | 53 | #define OP_WR_ASIC 0xc /* write single register on ASIC */ |
74 | #define OP_WR_ASIC 0x1f /* write single register on ASIC */ | 54 | |
55 | /* Init stages */ | ||
56 | #define COMMON_STAGE 0 | ||
57 | #define PORT0_STAGE 1 | ||
58 | #define PORT1_STAGE 2 | ||
59 | /* Never reorder FUNCx stages !!! */ | ||
60 | #define FUNC0_STAGE 3 | ||
61 | #define FUNC1_STAGE 4 | ||
62 | #define FUNC2_STAGE 5 | ||
63 | #define FUNC3_STAGE 6 | ||
64 | #define FUNC4_STAGE 7 | ||
65 | #define FUNC5_STAGE 8 | ||
66 | #define FUNC6_STAGE 9 | ||
67 | #define FUNC7_STAGE 10 | ||
68 | #define STAGE_IDX_MAX 11 | ||
69 | |||
70 | #define STAGE_START 0 | ||
71 | #define STAGE_END 1 | ||
72 | |||
73 | |||
74 | /* Indices of blocks */ | ||
75 | #define PRS_BLOCK 0 | ||
76 | #define SRCH_BLOCK 1 | ||
77 | #define TSDM_BLOCK 2 | ||
78 | #define TCM_BLOCK 3 | ||
79 | #define BRB1_BLOCK 4 | ||
80 | #define TSEM_BLOCK 5 | ||
81 | #define PXPCS_BLOCK 6 | ||
82 | #define EMAC0_BLOCK 7 | ||
83 | #define EMAC1_BLOCK 8 | ||
84 | #define DBU_BLOCK 9 | ||
85 | #define MISC_BLOCK 10 | ||
86 | #define DBG_BLOCK 11 | ||
87 | #define NIG_BLOCK 12 | ||
88 | #define MCP_BLOCK 13 | ||
89 | #define UPB_BLOCK 14 | ||
90 | #define CSDM_BLOCK 15 | ||
91 | #define USDM_BLOCK 16 | ||
92 | #define CCM_BLOCK 17 | ||
93 | #define UCM_BLOCK 18 | ||
94 | #define USEM_BLOCK 19 | ||
95 | #define CSEM_BLOCK 20 | ||
96 | #define XPB_BLOCK 21 | ||
97 | #define DQ_BLOCK 22 | ||
98 | #define TIMERS_BLOCK 23 | ||
99 | #define XSDM_BLOCK 24 | ||
100 | #define QM_BLOCK 25 | ||
101 | #define PBF_BLOCK 26 | ||
102 | #define XCM_BLOCK 27 | ||
103 | #define XSEM_BLOCK 28 | ||
104 | #define CDU_BLOCK 29 | ||
105 | #define DMAE_BLOCK 30 | ||
106 | #define PXP_BLOCK 31 | ||
107 | #define CFC_BLOCK 32 | ||
108 | #define HC_BLOCK 33 | ||
109 | #define PXP2_BLOCK 34 | ||
110 | #define MISC_AEU_BLOCK 35 | ||
111 | |||
112 | /* Returns the index of start or end of a specific block stage in ops array*/ | ||
113 | #define BLOCK_OPS_IDX(block, stage, end) \ | ||
114 | (2*(((block)*STAGE_IDX_MAX) + (stage)) + (end)) | ||
75 | 115 | ||
76 | 116 | ||
77 | struct raw_op { | 117 | struct raw_op { |
@@ -118,292 +158,6 @@ union init_op { | |||
118 | struct raw_op raw; | 158 | struct raw_op raw; |
119 | }; | 159 | }; |
120 | 160 | ||
121 | #include "bnx2x_init_values.h" | ||
122 | |||
123 | static void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val); | ||
124 | static int bnx2x_gunzip(struct bnx2x *bp, u8 *zbuf, int len); | ||
125 | |||
126 | static void bnx2x_init_str_wr(struct bnx2x *bp, u32 addr, const u32 *data, | ||
127 | u32 len) | ||
128 | { | ||
129 | int i; | ||
130 | |||
131 | for (i = 0; i < len; i++) { | ||
132 | REG_WR(bp, addr + i*4, data[i]); | ||
133 | if (!(i % 10000)) { | ||
134 | touch_softlockup_watchdog(); | ||
135 | cpu_relax(); | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | |||
140 | static void bnx2x_init_ind_wr(struct bnx2x *bp, u32 addr, const u32 *data, | ||
141 | u16 len) | ||
142 | { | ||
143 | int i; | ||
144 | |||
145 | for (i = 0; i < len; i++) { | ||
146 | REG_WR_IND(bp, addr + i*4, data[i]); | ||
147 | if (!(i % 10000)) { | ||
148 | touch_softlockup_watchdog(); | ||
149 | cpu_relax(); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | static void bnx2x_write_big_buf(struct bnx2x *bp, u32 addr, u32 len) | ||
155 | { | ||
156 | int offset = 0; | ||
157 | |||
158 | if (bp->dmae_ready) { | ||
159 | while (len > DMAE_LEN32_WR_MAX) { | ||
160 | bnx2x_write_dmae(bp, bp->gunzip_mapping + offset, | ||
161 | addr + offset, DMAE_LEN32_WR_MAX); | ||
162 | offset += DMAE_LEN32_WR_MAX * 4; | ||
163 | len -= DMAE_LEN32_WR_MAX; | ||
164 | } | ||
165 | bnx2x_write_dmae(bp, bp->gunzip_mapping + offset, | ||
166 | addr + offset, len); | ||
167 | } else | ||
168 | bnx2x_init_str_wr(bp, addr, bp->gunzip_buf, len); | ||
169 | } | ||
170 | |||
171 | static void bnx2x_init_fill(struct bnx2x *bp, u32 addr, int fill, u32 len) | ||
172 | { | ||
173 | u32 buf_len = (((len * 4) > FW_BUF_SIZE) ? FW_BUF_SIZE : (len * 4)); | ||
174 | u32 buf_len32 = buf_len / 4; | ||
175 | int i; | ||
176 | |||
177 | memset(bp->gunzip_buf, fill, buf_len); | ||
178 | |||
179 | for (i = 0; i < len; i += buf_len32) { | ||
180 | u32 cur_len = min(buf_len32, len - i); | ||
181 | |||
182 | bnx2x_write_big_buf(bp, addr + i * 4, cur_len); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | static void bnx2x_init_wr_64(struct bnx2x *bp, u32 addr, const u32 *data, | ||
187 | u32 len64) | ||
188 | { | ||
189 | u32 buf_len32 = FW_BUF_SIZE / 4; | ||
190 | u32 len = len64 * 2; | ||
191 | u64 data64 = 0; | ||
192 | int i; | ||
193 | |||
194 | /* 64 bit value is in a blob: first low DWORD, then high DWORD */ | ||
195 | data64 = HILO_U64((*(data + 1)), (*data)); | ||
196 | len64 = min((u32)(FW_BUF_SIZE/8), len64); | ||
197 | for (i = 0; i < len64; i++) { | ||
198 | u64 *pdata = ((u64 *)(bp->gunzip_buf)) + i; | ||
199 | |||
200 | *pdata = data64; | ||
201 | } | ||
202 | |||
203 | for (i = 0; i < len; i += buf_len32) { | ||
204 | u32 cur_len = min(buf_len32, len - i); | ||
205 | |||
206 | bnx2x_write_big_buf(bp, addr + i * 4, cur_len); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /********************************************************* | ||
211 | There are different blobs for each PRAM section. | ||
212 | In addition, each blob write operation is divided into a few operations | ||
213 | in order to decrease the amount of phys. contiguous buffer needed. | ||
214 | Thus, when we select a blob the address may be with some offset | ||
215 | from the beginning of PRAM section. | ||
216 | The same holds for the INT_TABLE sections. | ||
217 | **********************************************************/ | ||
218 | #define IF_IS_INT_TABLE_ADDR(base, addr) \ | ||
219 | if (((base) <= (addr)) && ((base) + 0x400 >= (addr))) | ||
220 | |||
221 | #define IF_IS_PRAM_ADDR(base, addr) \ | ||
222 | if (((base) <= (addr)) && ((base) + 0x40000 >= (addr))) | ||
223 | |||
224 | static const u32 *bnx2x_sel_blob(u32 addr, const u32 *data, int is_e1) | ||
225 | { | ||
226 | IF_IS_INT_TABLE_ADDR(TSEM_REG_INT_TABLE, addr) | ||
227 | data = is_e1 ? tsem_int_table_data_e1 : | ||
228 | tsem_int_table_data_e1h; | ||
229 | else | ||
230 | IF_IS_INT_TABLE_ADDR(CSEM_REG_INT_TABLE, addr) | ||
231 | data = is_e1 ? csem_int_table_data_e1 : | ||
232 | csem_int_table_data_e1h; | ||
233 | else | ||
234 | IF_IS_INT_TABLE_ADDR(USEM_REG_INT_TABLE, addr) | ||
235 | data = is_e1 ? usem_int_table_data_e1 : | ||
236 | usem_int_table_data_e1h; | ||
237 | else | ||
238 | IF_IS_INT_TABLE_ADDR(XSEM_REG_INT_TABLE, addr) | ||
239 | data = is_e1 ? xsem_int_table_data_e1 : | ||
240 | xsem_int_table_data_e1h; | ||
241 | else | ||
242 | IF_IS_PRAM_ADDR(TSEM_REG_PRAM, addr) | ||
243 | data = is_e1 ? tsem_pram_data_e1 : tsem_pram_data_e1h; | ||
244 | else | ||
245 | IF_IS_PRAM_ADDR(CSEM_REG_PRAM, addr) | ||
246 | data = is_e1 ? csem_pram_data_e1 : csem_pram_data_e1h; | ||
247 | else | ||
248 | IF_IS_PRAM_ADDR(USEM_REG_PRAM, addr) | ||
249 | data = is_e1 ? usem_pram_data_e1 : usem_pram_data_e1h; | ||
250 | else | ||
251 | IF_IS_PRAM_ADDR(XSEM_REG_PRAM, addr) | ||
252 | data = is_e1 ? xsem_pram_data_e1 : xsem_pram_data_e1h; | ||
253 | |||
254 | return data; | ||
255 | } | ||
256 | |||
257 | static void bnx2x_init_wr_wb(struct bnx2x *bp, u32 addr, const u32 *data, | ||
258 | u32 len, int gunzip, int is_e1, u32 blob_off) | ||
259 | { | ||
260 | int offset = 0; | ||
261 | |||
262 | data = bnx2x_sel_blob(addr, data, is_e1) + blob_off; | ||
263 | |||
264 | if (gunzip) { | ||
265 | int rc; | ||
266 | #ifdef __BIG_ENDIAN | ||
267 | int i, size; | ||
268 | u32 *temp; | ||
269 | |||
270 | temp = kmalloc(len, GFP_KERNEL); | ||
271 | size = (len / 4) + ((len % 4) ? 1 : 0); | ||
272 | for (i = 0; i < size; i++) | ||
273 | temp[i] = swab32(data[i]); | ||
274 | data = temp; | ||
275 | #endif | ||
276 | rc = bnx2x_gunzip(bp, (u8 *)data, len); | ||
277 | if (rc) { | ||
278 | BNX2X_ERR("gunzip failed ! rc %d\n", rc); | ||
279 | #ifdef __BIG_ENDIAN | ||
280 | kfree(temp); | ||
281 | #endif | ||
282 | return; | ||
283 | } | ||
284 | len = bp->gunzip_outlen; | ||
285 | #ifdef __BIG_ENDIAN | ||
286 | kfree(temp); | ||
287 | for (i = 0; i < len; i++) | ||
288 | ((u32 *)bp->gunzip_buf)[i] = | ||
289 | swab32(((u32 *)bp->gunzip_buf)[i]); | ||
290 | #endif | ||
291 | } else { | ||
292 | if ((len * 4) > FW_BUF_SIZE) { | ||
293 | BNX2X_ERR("LARGE DMAE OPERATION ! " | ||
294 | "addr 0x%x len 0x%x\n", addr, len*4); | ||
295 | return; | ||
296 | } | ||
297 | memcpy(bp->gunzip_buf, data, len * 4); | ||
298 | } | ||
299 | |||
300 | if (bp->dmae_ready) { | ||
301 | while (len > DMAE_LEN32_WR_MAX) { | ||
302 | bnx2x_write_dmae(bp, bp->gunzip_mapping + offset, | ||
303 | addr + offset, DMAE_LEN32_WR_MAX); | ||
304 | offset += DMAE_LEN32_WR_MAX * 4; | ||
305 | len -= DMAE_LEN32_WR_MAX; | ||
306 | } | ||
307 | bnx2x_write_dmae(bp, bp->gunzip_mapping + offset, | ||
308 | addr + offset, len); | ||
309 | } else | ||
310 | bnx2x_init_ind_wr(bp, addr, bp->gunzip_buf, len); | ||
311 | } | ||
312 | |||
313 | static void bnx2x_init_block(struct bnx2x *bp, u32 op_start, u32 op_end) | ||
314 | { | ||
315 | int is_e1 = CHIP_IS_E1(bp); | ||
316 | int is_e1h = CHIP_IS_E1H(bp); | ||
317 | int is_emul_e1h = (CHIP_REV_IS_EMUL(bp) && is_e1h); | ||
318 | int hw_wr, i; | ||
319 | union init_op *op; | ||
320 | u32 op_type, addr, len; | ||
321 | const u32 *data, *data_base; | ||
322 | |||
323 | if (CHIP_REV_IS_FPGA(bp)) | ||
324 | hw_wr = OP_WR_FPGA; | ||
325 | else if (CHIP_REV_IS_EMUL(bp)) | ||
326 | hw_wr = OP_WR_EMUL; | ||
327 | else | ||
328 | hw_wr = OP_WR_ASIC; | ||
329 | |||
330 | if (is_e1) | ||
331 | data_base = init_data_e1; | ||
332 | else /* CHIP_IS_E1H(bp) */ | ||
333 | data_base = init_data_e1h; | ||
334 | |||
335 | for (i = op_start; i < op_end; i++) { | ||
336 | |||
337 | op = (union init_op *)&(init_ops[i]); | ||
338 | |||
339 | op_type = op->str_wr.op; | ||
340 | addr = op->str_wr.offset; | ||
341 | len = op->str_wr.data_len; | ||
342 | data = data_base + op->str_wr.data_off; | ||
343 | |||
344 | /* careful! it must be in order */ | ||
345 | if (unlikely(op_type > OP_WB)) { | ||
346 | |||
347 | /* If E1 only */ | ||
348 | if (op_type <= OP_WB_E1) { | ||
349 | if (is_e1) | ||
350 | op_type -= (OP_RD_E1 - OP_RD); | ||
351 | |||
352 | /* If E1H only */ | ||
353 | } else if (op_type <= OP_WB_E1H) { | ||
354 | if (is_e1h) | ||
355 | op_type -= (OP_RD_E1H - OP_RD); | ||
356 | } | ||
357 | |||
358 | /* HW/EMUL specific */ | ||
359 | if (op_type == hw_wr) | ||
360 | op_type = OP_WR; | ||
361 | |||
362 | /* EMUL on E1H is special */ | ||
363 | if ((op_type == OP_WR_EMUL_E1H) && is_emul_e1h) | ||
364 | op_type = OP_WR; | ||
365 | } | ||
366 | |||
367 | switch (op_type) { | ||
368 | case OP_RD: | ||
369 | REG_RD(bp, addr); | ||
370 | break; | ||
371 | case OP_WR: | ||
372 | REG_WR(bp, addr, op->write.val); | ||
373 | break; | ||
374 | case OP_SW: | ||
375 | bnx2x_init_str_wr(bp, addr, data, len); | ||
376 | break; | ||
377 | case OP_WB: | ||
378 | bnx2x_init_wr_wb(bp, addr, data, len, 0, is_e1, 0); | ||
379 | break; | ||
380 | case OP_SI: | ||
381 | bnx2x_init_ind_wr(bp, addr, data, len); | ||
382 | break; | ||
383 | case OP_ZR: | ||
384 | bnx2x_init_fill(bp, addr, 0, op->zero.len); | ||
385 | break; | ||
386 | case OP_ZP: | ||
387 | bnx2x_init_wr_wb(bp, addr, data, len, 1, is_e1, | ||
388 | op->str_wr.data_off); | ||
389 | break; | ||
390 | case OP_WR_64: | ||
391 | bnx2x_init_wr_64(bp, addr, data, len); | ||
392 | break; | ||
393 | default: | ||
394 | /* happens whenever an op is of a diff HW */ | ||
395 | #if 0 | ||
396 | DP(NETIF_MSG_HW, "skipping init operation " | ||
397 | "index %d[%d:%d]: type %d addr 0x%x " | ||
398 | "len %d(0x%x)\n", | ||
399 | i, op_start, op_end, op_type, addr, len, len); | ||
400 | #endif | ||
401 | break; | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | |||
406 | |||
407 | /**************************************************************************** | 161 | /**************************************************************************** |
408 | * PXP | 162 | * PXP |
409 | ****************************************************************************/ | 163 | ****************************************************************************/ |
@@ -567,111 +321,6 @@ static const struct arb_line write_arb_addr[NUM_WR_Q-1] = { | |||
567 | PXP2_REG_RQ_BW_WR_UBOUND30} | 321 | PXP2_REG_RQ_BW_WR_UBOUND30} |
568 | }; | 322 | }; |
569 | 323 | ||
570 | static void bnx2x_init_pxp(struct bnx2x *bp) | ||
571 | { | ||
572 | u16 devctl; | ||
573 | int r_order, w_order; | ||
574 | u32 val, i; | ||
575 | |||
576 | pci_read_config_word(bp->pdev, | ||
577 | bp->pcie_cap + PCI_EXP_DEVCTL, &devctl); | ||
578 | DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl); | ||
579 | w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5); | ||
580 | if (bp->mrrs == -1) | ||
581 | r_order = ((devctl & PCI_EXP_DEVCTL_READRQ) >> 12); | ||
582 | else { | ||
583 | DP(NETIF_MSG_HW, "force read order to %d\n", bp->mrrs); | ||
584 | r_order = bp->mrrs; | ||
585 | } | ||
586 | |||
587 | if (r_order > MAX_RD_ORD) { | ||
588 | DP(NETIF_MSG_HW, "read order of %d order adjusted to %d\n", | ||
589 | r_order, MAX_RD_ORD); | ||
590 | r_order = MAX_RD_ORD; | ||
591 | } | ||
592 | if (w_order > MAX_WR_ORD) { | ||
593 | DP(NETIF_MSG_HW, "write order of %d order adjusted to %d\n", | ||
594 | w_order, MAX_WR_ORD); | ||
595 | w_order = MAX_WR_ORD; | ||
596 | } | ||
597 | if (CHIP_REV_IS_FPGA(bp)) { | ||
598 | DP(NETIF_MSG_HW, "write order adjusted to 1 for FPGA\n"); | ||
599 | w_order = 0; | ||
600 | } | ||
601 | DP(NETIF_MSG_HW, "read order %d write order %d\n", r_order, w_order); | ||
602 | |||
603 | for (i = 0; i < NUM_RD_Q-1; i++) { | ||
604 | REG_WR(bp, read_arb_addr[i].l, read_arb_data[i][r_order].l); | ||
605 | REG_WR(bp, read_arb_addr[i].add, | ||
606 | read_arb_data[i][r_order].add); | ||
607 | REG_WR(bp, read_arb_addr[i].ubound, | ||
608 | read_arb_data[i][r_order].ubound); | ||
609 | } | ||
610 | |||
611 | for (i = 0; i < NUM_WR_Q-1; i++) { | ||
612 | if ((write_arb_addr[i].l == PXP2_REG_RQ_BW_WR_L29) || | ||
613 | (write_arb_addr[i].l == PXP2_REG_RQ_BW_WR_L30)) { | ||
614 | |||
615 | REG_WR(bp, write_arb_addr[i].l, | ||
616 | write_arb_data[i][w_order].l); | ||
617 | |||
618 | REG_WR(bp, write_arb_addr[i].add, | ||
619 | write_arb_data[i][w_order].add); | ||
620 | |||
621 | REG_WR(bp, write_arb_addr[i].ubound, | ||
622 | write_arb_data[i][w_order].ubound); | ||
623 | } else { | ||
624 | |||
625 | val = REG_RD(bp, write_arb_addr[i].l); | ||
626 | REG_WR(bp, write_arb_addr[i].l, | ||
627 | val | (write_arb_data[i][w_order].l << 10)); | ||
628 | |||
629 | val = REG_RD(bp, write_arb_addr[i].add); | ||
630 | REG_WR(bp, write_arb_addr[i].add, | ||
631 | val | (write_arb_data[i][w_order].add << 10)); | ||
632 | |||
633 | val = REG_RD(bp, write_arb_addr[i].ubound); | ||
634 | REG_WR(bp, write_arb_addr[i].ubound, | ||
635 | val | (write_arb_data[i][w_order].ubound << 7)); | ||
636 | } | ||
637 | } | ||
638 | |||
639 | val = write_arb_data[NUM_WR_Q-1][w_order].add; | ||
640 | val += write_arb_data[NUM_WR_Q-1][w_order].ubound << 10; | ||
641 | val += write_arb_data[NUM_WR_Q-1][w_order].l << 17; | ||
642 | REG_WR(bp, PXP2_REG_PSWRQ_BW_RD, val); | ||
643 | |||
644 | val = read_arb_data[NUM_RD_Q-1][r_order].add; | ||
645 | val += read_arb_data[NUM_RD_Q-1][r_order].ubound << 10; | ||
646 | val += read_arb_data[NUM_RD_Q-1][r_order].l << 17; | ||
647 | REG_WR(bp, PXP2_REG_PSWRQ_BW_WR, val); | ||
648 | |||
649 | REG_WR(bp, PXP2_REG_RQ_WR_MBS0, w_order); | ||
650 | REG_WR(bp, PXP2_REG_RQ_WR_MBS1, w_order); | ||
651 | REG_WR(bp, PXP2_REG_RQ_RD_MBS0, r_order); | ||
652 | REG_WR(bp, PXP2_REG_RQ_RD_MBS1, r_order); | ||
653 | |||
654 | if (r_order == MAX_RD_ORD) | ||
655 | REG_WR(bp, PXP2_REG_RQ_PDR_LIMIT, 0xe00); | ||
656 | |||
657 | REG_WR(bp, PXP2_REG_WR_USDMDP_TH, (0x18 << w_order)); | ||
658 | |||
659 | if (CHIP_IS_E1H(bp)) { | ||
660 | val = ((w_order == 0) ? 2 : 3); | ||
661 | REG_WR(bp, PXP2_REG_WR_HC_MPS, val); | ||
662 | REG_WR(bp, PXP2_REG_WR_USDM_MPS, val); | ||
663 | REG_WR(bp, PXP2_REG_WR_CSDM_MPS, val); | ||
664 | REG_WR(bp, PXP2_REG_WR_TSDM_MPS, val); | ||
665 | REG_WR(bp, PXP2_REG_WR_XSDM_MPS, val); | ||
666 | REG_WR(bp, PXP2_REG_WR_QM_MPS, val); | ||
667 | REG_WR(bp, PXP2_REG_WR_TM_MPS, val); | ||
668 | REG_WR(bp, PXP2_REG_WR_SRC_MPS, val); | ||
669 | REG_WR(bp, PXP2_REG_WR_DBG_MPS, val); | ||
670 | REG_WR(bp, PXP2_REG_WR_DMAE_MPS, 2); /* DMAE is special */ | ||
671 | REG_WR(bp, PXP2_REG_WR_CDU_MPS, val); | ||
672 | } | ||
673 | } | ||
674 | |||
675 | 324 | ||
676 | /**************************************************************************** | 325 | /**************************************************************************** |
677 | * CDU | 326 | * CDU |
@@ -695,128 +344,12 @@ static void bnx2x_init_pxp(struct bnx2x *bp) | |||
695 | (0x80 | ((_type) & 0xf << 3) | (CDU_CRC8(_cid, _region, _type) & 0x7)) | 344 | (0x80 | ((_type) & 0xf << 3) | (CDU_CRC8(_cid, _region, _type) & 0x7)) |
696 | #define CDU_RSRVD_INVALIDATE_CONTEXT_VALUE(_val) ((_val) & ~0x80) | 345 | #define CDU_RSRVD_INVALIDATE_CONTEXT_VALUE(_val) ((_val) & ~0x80) |
697 | 346 | ||
698 | /***************************************************************************** | ||
699 | * Description: | ||
700 | * Calculates crc 8 on a word value: polynomial 0-1-2-8 | ||
701 | * Code was translated from Verilog. | ||
702 | ****************************************************************************/ | ||
703 | static u8 calc_crc8(u32 data, u8 crc) | ||
704 | { | ||
705 | u8 D[32]; | ||
706 | u8 NewCRC[8]; | ||
707 | u8 C[8]; | ||
708 | u8 crc_res; | ||
709 | u8 i; | ||
710 | |||
711 | /* split the data into 31 bits */ | ||
712 | for (i = 0; i < 32; i++) { | ||
713 | D[i] = data & 1; | ||
714 | data = data >> 1; | ||
715 | } | ||
716 | |||
717 | /* split the crc into 8 bits */ | ||
718 | for (i = 0; i < 8; i++) { | ||
719 | C[i] = crc & 1; | ||
720 | crc = crc >> 1; | ||
721 | } | ||
722 | |||
723 | NewCRC[0] = D[31] ^ D[30] ^ D[28] ^ D[23] ^ D[21] ^ D[19] ^ D[18] ^ | ||
724 | D[16] ^ D[14] ^ D[12] ^ D[8] ^ D[7] ^ D[6] ^ D[0] ^ C[4] ^ | ||
725 | C[6] ^ C[7]; | ||
726 | NewCRC[1] = D[30] ^ D[29] ^ D[28] ^ D[24] ^ D[23] ^ D[22] ^ D[21] ^ | ||
727 | D[20] ^ D[18] ^ D[17] ^ D[16] ^ D[15] ^ D[14] ^ D[13] ^ | ||
728 | D[12] ^ D[9] ^ D[6] ^ D[1] ^ D[0] ^ C[0] ^ C[4] ^ C[5] ^ C[6]; | ||
729 | NewCRC[2] = D[29] ^ D[28] ^ D[25] ^ D[24] ^ D[22] ^ D[17] ^ D[15] ^ | ||
730 | D[13] ^ D[12] ^ D[10] ^ D[8] ^ D[6] ^ D[2] ^ D[1] ^ D[0] ^ | ||
731 | C[0] ^ C[1] ^ C[4] ^ C[5]; | ||
732 | NewCRC[3] = D[30] ^ D[29] ^ D[26] ^ D[25] ^ D[23] ^ D[18] ^ D[16] ^ | ||
733 | D[14] ^ D[13] ^ D[11] ^ D[9] ^ D[7] ^ D[3] ^ D[2] ^ D[1] ^ | ||
734 | C[1] ^ C[2] ^ C[5] ^ C[6]; | ||
735 | NewCRC[4] = D[31] ^ D[30] ^ D[27] ^ D[26] ^ D[24] ^ D[19] ^ D[17] ^ | ||
736 | D[15] ^ D[14] ^ D[12] ^ D[10] ^ D[8] ^ D[4] ^ D[3] ^ D[2] ^ | ||
737 | C[0] ^ C[2] ^ C[3] ^ C[6] ^ C[7]; | ||
738 | NewCRC[5] = D[31] ^ D[28] ^ D[27] ^ D[25] ^ D[20] ^ D[18] ^ D[16] ^ | ||
739 | D[15] ^ D[13] ^ D[11] ^ D[9] ^ D[5] ^ D[4] ^ D[3] ^ C[1] ^ | ||
740 | C[3] ^ C[4] ^ C[7]; | ||
741 | NewCRC[6] = D[29] ^ D[28] ^ D[26] ^ D[21] ^ D[19] ^ D[17] ^ D[16] ^ | ||
742 | D[14] ^ D[12] ^ D[10] ^ D[6] ^ D[5] ^ D[4] ^ C[2] ^ C[4] ^ | ||
743 | C[5]; | ||
744 | NewCRC[7] = D[30] ^ D[29] ^ D[27] ^ D[22] ^ D[20] ^ D[18] ^ D[17] ^ | ||
745 | D[15] ^ D[13] ^ D[11] ^ D[7] ^ D[6] ^ D[5] ^ C[3] ^ C[5] ^ | ||
746 | C[6]; | ||
747 | |||
748 | crc_res = 0; | ||
749 | for (i = 0; i < 8; i++) | ||
750 | crc_res |= (NewCRC[i] << i); | ||
751 | |||
752 | return crc_res; | ||
753 | } | ||
754 | 347 | ||
755 | /* registers addresses are not in order | 348 | /* registers addresses are not in order |
756 | so these arrays help simplify the code */ | 349 | so these arrays help simplify the code */ |
757 | static const int cm_start[E1H_FUNC_MAX][9] = { | 350 | static const int cm_blocks[9] = { |
758 | {MISC_FUNC0_START, TCM_FUNC0_START, UCM_FUNC0_START, CCM_FUNC0_START, | 351 | MISC_BLOCK, TCM_BLOCK, UCM_BLOCK, CCM_BLOCK, XCM_BLOCK, |
759 | XCM_FUNC0_START, TSEM_FUNC0_START, USEM_FUNC0_START, CSEM_FUNC0_START, | 352 | TSEM_BLOCK, USEM_BLOCK, CSEM_BLOCK, XSEM_BLOCK |
760 | XSEM_FUNC0_START}, | ||
761 | {MISC_FUNC1_START, TCM_FUNC1_START, UCM_FUNC1_START, CCM_FUNC1_START, | ||
762 | XCM_FUNC1_START, TSEM_FUNC1_START, USEM_FUNC1_START, CSEM_FUNC1_START, | ||
763 | XSEM_FUNC1_START}, | ||
764 | {MISC_FUNC2_START, TCM_FUNC2_START, UCM_FUNC2_START, CCM_FUNC2_START, | ||
765 | XCM_FUNC2_START, TSEM_FUNC2_START, USEM_FUNC2_START, CSEM_FUNC2_START, | ||
766 | XSEM_FUNC2_START}, | ||
767 | {MISC_FUNC3_START, TCM_FUNC3_START, UCM_FUNC3_START, CCM_FUNC3_START, | ||
768 | XCM_FUNC3_START, TSEM_FUNC3_START, USEM_FUNC3_START, CSEM_FUNC3_START, | ||
769 | XSEM_FUNC3_START}, | ||
770 | {MISC_FUNC4_START, TCM_FUNC4_START, UCM_FUNC4_START, CCM_FUNC4_START, | ||
771 | XCM_FUNC4_START, TSEM_FUNC4_START, USEM_FUNC4_START, CSEM_FUNC4_START, | ||
772 | XSEM_FUNC4_START}, | ||
773 | {MISC_FUNC5_START, TCM_FUNC5_START, UCM_FUNC5_START, CCM_FUNC5_START, | ||
774 | XCM_FUNC5_START, TSEM_FUNC5_START, USEM_FUNC5_START, CSEM_FUNC5_START, | ||
775 | XSEM_FUNC5_START}, | ||
776 | {MISC_FUNC6_START, TCM_FUNC6_START, UCM_FUNC6_START, CCM_FUNC6_START, | ||
777 | XCM_FUNC6_START, TSEM_FUNC6_START, USEM_FUNC6_START, CSEM_FUNC6_START, | ||
778 | XSEM_FUNC6_START}, | ||
779 | {MISC_FUNC7_START, TCM_FUNC7_START, UCM_FUNC7_START, CCM_FUNC7_START, | ||
780 | XCM_FUNC7_START, TSEM_FUNC7_START, USEM_FUNC7_START, CSEM_FUNC7_START, | ||
781 | XSEM_FUNC7_START} | ||
782 | }; | ||
783 | |||
784 | static const int cm_end[E1H_FUNC_MAX][9] = { | ||
785 | {MISC_FUNC0_END, TCM_FUNC0_END, UCM_FUNC0_END, CCM_FUNC0_END, | ||
786 | XCM_FUNC0_END, TSEM_FUNC0_END, USEM_FUNC0_END, CSEM_FUNC0_END, | ||
787 | XSEM_FUNC0_END}, | ||
788 | {MISC_FUNC1_END, TCM_FUNC1_END, UCM_FUNC1_END, CCM_FUNC1_END, | ||
789 | XCM_FUNC1_END, TSEM_FUNC1_END, USEM_FUNC1_END, CSEM_FUNC1_END, | ||
790 | XSEM_FUNC1_END}, | ||
791 | {MISC_FUNC2_END, TCM_FUNC2_END, UCM_FUNC2_END, CCM_FUNC2_END, | ||
792 | XCM_FUNC2_END, TSEM_FUNC2_END, USEM_FUNC2_END, CSEM_FUNC2_END, | ||
793 | XSEM_FUNC2_END}, | ||
794 | {MISC_FUNC3_END, TCM_FUNC3_END, UCM_FUNC3_END, CCM_FUNC3_END, | ||
795 | XCM_FUNC3_END, TSEM_FUNC3_END, USEM_FUNC3_END, CSEM_FUNC3_END, | ||
796 | XSEM_FUNC3_END}, | ||
797 | {MISC_FUNC4_END, TCM_FUNC4_END, UCM_FUNC4_END, CCM_FUNC4_END, | ||
798 | XCM_FUNC4_END, TSEM_FUNC4_END, USEM_FUNC4_END, CSEM_FUNC4_END, | ||
799 | XSEM_FUNC4_END}, | ||
800 | {MISC_FUNC5_END, TCM_FUNC5_END, UCM_FUNC5_END, CCM_FUNC5_END, | ||
801 | XCM_FUNC5_END, TSEM_FUNC5_END, USEM_FUNC5_END, CSEM_FUNC5_END, | ||
802 | XSEM_FUNC5_END}, | ||
803 | {MISC_FUNC6_END, TCM_FUNC6_END, UCM_FUNC6_END, CCM_FUNC6_END, | ||
804 | XCM_FUNC6_END, TSEM_FUNC6_END, USEM_FUNC6_END, CSEM_FUNC6_END, | ||
805 | XSEM_FUNC6_END}, | ||
806 | {MISC_FUNC7_END, TCM_FUNC7_END, UCM_FUNC7_END, CCM_FUNC7_END, | ||
807 | XCM_FUNC7_END, TSEM_FUNC7_END, USEM_FUNC7_END, CSEM_FUNC7_END, | ||
808 | XSEM_FUNC7_END}, | ||
809 | }; | ||
810 | |||
811 | static const int hc_limits[E1H_FUNC_MAX][2] = { | ||
812 | {HC_FUNC0_START, HC_FUNC0_END}, | ||
813 | {HC_FUNC1_START, HC_FUNC1_END}, | ||
814 | {HC_FUNC2_START, HC_FUNC2_END}, | ||
815 | {HC_FUNC3_START, HC_FUNC3_END}, | ||
816 | {HC_FUNC4_START, HC_FUNC4_END}, | ||
817 | {HC_FUNC5_START, HC_FUNC5_END}, | ||
818 | {HC_FUNC6_START, HC_FUNC6_END}, | ||
819 | {HC_FUNC7_START, HC_FUNC7_END} | ||
820 | }; | 353 | }; |
821 | 354 | ||
822 | #endif /* BNX2X_INIT_H */ | 355 | #endif /* BNX2X_INIT_H */ |