1 /* bnx2x_init.h: Broadcom Everest network driver.
2 * Structures and macroes needed during the initialization.
4 * Copyright (c) 2007-2009 Broadcom Corporation
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.
10 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
11 * Written by: Eliezer Tamir
12 * Modified by: Vladislav Zolotarov <vladz@broadcom.com>
22 #define INIT_EMULATION 0x1
25 #define INIT_HARDWARE 0x7
27 #define TSTORM_INTMEM_ADDR TSEM_REG_FAST_MEMORY
28 #define CSTORM_INTMEM_ADDR CSEM_REG_FAST_MEMORY
29 #define XSTORM_INTMEM_ADDR XSEM_REG_FAST_MEMORY
30 #define USTORM_INTMEM_ADDR USEM_REG_FAST_MEMORY
31 /* RAM0 size in bytes */
32 #define STORM_INTMEM_SIZE_E1 0x5800
33 #define STORM_INTMEM_SIZE_E1H 0x10000
34 #define STORM_INTMEM_SIZE(bp) ((CHIP_IS_E1H(bp) ? STORM_INTMEM_SIZE_E1H : \
35 STORM_INTMEM_SIZE_E1) / 4)
38 /* Init operation types and structures */
39 /* Common for both E1 and E1H */
40 #define OP_RD 0x1 /* read single register */
41 #define OP_WR 0x2 /* write single register */
42 #define OP_IW 0x3 /* write single register using mailbox */
43 #define OP_SW 0x4 /* copy a string to the device */
44 #define OP_SI 0x5 /* copy a string using mailbox */
45 #define OP_ZR 0x6 /* clear memory */
46 #define OP_ZP 0x7 /* unzip then copy with DMAE */
47 #define OP_WR_64 0x8 /* write 64 bit pattern */
48 #define OP_WB 0x9 /* copy a string using DMAE */
50 /* FPGA and EMUL specific operations */
51 #define OP_WR_EMUL 0xa /* write single register on Emulation */
52 #define OP_WR_FPGA 0xb /* write single register on FPGA */
53 #define OP_WR_ASIC 0xc /* write single register on ASIC */
56 #define COMMON_STAGE 0
59 /* Never reorder FUNCx stages !!! */
67 #define FUNC7_STAGE 10
68 #define STAGE_IDX_MAX 11
74 /* Indices of blocks */
98 #define TIMERS_BLOCK 23
103 #define XSEM_BLOCK 28
105 #define DMAE_BLOCK 30
109 #define PXP2_BLOCK 34
110 #define MISC_AEU_BLOCK 35
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))
135 struct op_string_write {
138 #ifdef __LITTLE_ENDIAN
141 #else /* __BIG_ENDIAN */
155 struct op_write write;
156 struct op_string_write str_wr;
161 /****************************************************************************
163 ****************************************************************************/
165 * This code configures the PCI read/write arbiter
166 * which implements a weighted round robin
167 * between the virtual queues in the chip.
169 * The values were derived for each PCI max payload and max request size.
170 * since max payload and max request size are only known at run time,
171 * this is done as a separate init stage.
179 /* configuration for one arbiter queue */
186 /* derived configuration for each read queue for each max request size */
187 static const struct arb_line read_arb_data[NUM_RD_Q][MAX_RD_ORD + 1] = {
188 /* 1 */ { {8, 64, 25}, {16, 64, 25}, {32, 64, 25}, {64, 64, 41} },
189 { {4, 8, 4}, {4, 8, 4}, {4, 8, 4}, {4, 8, 4} },
190 { {4, 3, 3}, {4, 3, 3}, {4, 3, 3}, {4, 3, 3} },
191 { {8, 3, 6}, {16, 3, 11}, {16, 3, 11}, {16, 3, 11} },
192 { {8, 64, 25}, {16, 64, 25}, {32, 64, 25}, {64, 64, 41} },
193 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
194 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
195 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
196 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
197 /* 10 */{ {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
198 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
199 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
200 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
201 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
202 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
203 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
204 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
205 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
206 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
207 /* 20 */{ {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
208 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
209 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
210 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
211 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
212 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
213 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
214 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
215 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
216 { {8, 64, 25}, {16, 64, 41}, {32, 64, 81}, {64, 64, 120} }
219 /* derived configuration for each write queue for each max request size */
220 static const struct arb_line write_arb_data[NUM_WR_Q][MAX_WR_ORD + 1] = {
221 /* 1 */ { {4, 6, 3}, {4, 6, 3}, {4, 6, 3} },
222 { {4, 2, 3}, {4, 2, 3}, {4, 2, 3} },
223 { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
224 { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
225 { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
226 { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
227 { {8, 64, 25}, {16, 64, 25}, {32, 64, 25} },
228 { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
229 { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
230 /* 10 */{ {8, 9, 6}, {16, 9, 11}, {32, 9, 21} },
231 { {8, 47, 19}, {16, 47, 19}, {32, 47, 21} },
232 { {8, 9, 6}, {16, 9, 11}, {16, 9, 11} },
233 { {8, 64, 25}, {16, 64, 41}, {32, 64, 81} }
236 /* register addresses for read queues */
237 static const struct arb_line read_arb_addr[NUM_RD_Q-1] = {
238 /* 1 */ {PXP2_REG_RQ_BW_RD_L0, PXP2_REG_RQ_BW_RD_ADD0,
239 PXP2_REG_RQ_BW_RD_UBOUND0},
240 {PXP2_REG_PSWRQ_BW_L1, PXP2_REG_PSWRQ_BW_ADD1,
241 PXP2_REG_PSWRQ_BW_UB1},
242 {PXP2_REG_PSWRQ_BW_L2, PXP2_REG_PSWRQ_BW_ADD2,
243 PXP2_REG_PSWRQ_BW_UB2},
244 {PXP2_REG_PSWRQ_BW_L3, PXP2_REG_PSWRQ_BW_ADD3,
245 PXP2_REG_PSWRQ_BW_UB3},
246 {PXP2_REG_RQ_BW_RD_L4, PXP2_REG_RQ_BW_RD_ADD4,
247 PXP2_REG_RQ_BW_RD_UBOUND4},
248 {PXP2_REG_RQ_BW_RD_L5, PXP2_REG_RQ_BW_RD_ADD5,
249 PXP2_REG_RQ_BW_RD_UBOUND5},
250 {PXP2_REG_PSWRQ_BW_L6, PXP2_REG_PSWRQ_BW_ADD6,
251 PXP2_REG_PSWRQ_BW_UB6},
252 {PXP2_REG_PSWRQ_BW_L7, PXP2_REG_PSWRQ_BW_ADD7,
253 PXP2_REG_PSWRQ_BW_UB7},
254 {PXP2_REG_PSWRQ_BW_L8, PXP2_REG_PSWRQ_BW_ADD8,
255 PXP2_REG_PSWRQ_BW_UB8},
256 /* 10 */{PXP2_REG_PSWRQ_BW_L9, PXP2_REG_PSWRQ_BW_ADD9,
257 PXP2_REG_PSWRQ_BW_UB9},
258 {PXP2_REG_PSWRQ_BW_L10, PXP2_REG_PSWRQ_BW_ADD10,
259 PXP2_REG_PSWRQ_BW_UB10},
260 {PXP2_REG_PSWRQ_BW_L11, PXP2_REG_PSWRQ_BW_ADD11,
261 PXP2_REG_PSWRQ_BW_UB11},
262 {PXP2_REG_RQ_BW_RD_L12, PXP2_REG_RQ_BW_RD_ADD12,
263 PXP2_REG_RQ_BW_RD_UBOUND12},
264 {PXP2_REG_RQ_BW_RD_L13, PXP2_REG_RQ_BW_RD_ADD13,
265 PXP2_REG_RQ_BW_RD_UBOUND13},
266 {PXP2_REG_RQ_BW_RD_L14, PXP2_REG_RQ_BW_RD_ADD14,
267 PXP2_REG_RQ_BW_RD_UBOUND14},
268 {PXP2_REG_RQ_BW_RD_L15, PXP2_REG_RQ_BW_RD_ADD15,
269 PXP2_REG_RQ_BW_RD_UBOUND15},
270 {PXP2_REG_RQ_BW_RD_L16, PXP2_REG_RQ_BW_RD_ADD16,
271 PXP2_REG_RQ_BW_RD_UBOUND16},
272 {PXP2_REG_RQ_BW_RD_L17, PXP2_REG_RQ_BW_RD_ADD17,
273 PXP2_REG_RQ_BW_RD_UBOUND17},
274 {PXP2_REG_RQ_BW_RD_L18, PXP2_REG_RQ_BW_RD_ADD18,
275 PXP2_REG_RQ_BW_RD_UBOUND18},
276 /* 20 */{PXP2_REG_RQ_BW_RD_L19, PXP2_REG_RQ_BW_RD_ADD19,
277 PXP2_REG_RQ_BW_RD_UBOUND19},
278 {PXP2_REG_RQ_BW_RD_L20, PXP2_REG_RQ_BW_RD_ADD20,
279 PXP2_REG_RQ_BW_RD_UBOUND20},
280 {PXP2_REG_RQ_BW_RD_L22, PXP2_REG_RQ_BW_RD_ADD22,
281 PXP2_REG_RQ_BW_RD_UBOUND22},
282 {PXP2_REG_RQ_BW_RD_L23, PXP2_REG_RQ_BW_RD_ADD23,
283 PXP2_REG_RQ_BW_RD_UBOUND23},
284 {PXP2_REG_RQ_BW_RD_L24, PXP2_REG_RQ_BW_RD_ADD24,
285 PXP2_REG_RQ_BW_RD_UBOUND24},
286 {PXP2_REG_RQ_BW_RD_L25, PXP2_REG_RQ_BW_RD_ADD25,
287 PXP2_REG_RQ_BW_RD_UBOUND25},
288 {PXP2_REG_RQ_BW_RD_L26, PXP2_REG_RQ_BW_RD_ADD26,
289 PXP2_REG_RQ_BW_RD_UBOUND26},
290 {PXP2_REG_RQ_BW_RD_L27, PXP2_REG_RQ_BW_RD_ADD27,
291 PXP2_REG_RQ_BW_RD_UBOUND27},
292 {PXP2_REG_PSWRQ_BW_L28, PXP2_REG_PSWRQ_BW_ADD28,
293 PXP2_REG_PSWRQ_BW_UB28}
296 /* register addresses for write queues */
297 static const struct arb_line write_arb_addr[NUM_WR_Q-1] = {
298 /* 1 */ {PXP2_REG_PSWRQ_BW_L1, PXP2_REG_PSWRQ_BW_ADD1,
299 PXP2_REG_PSWRQ_BW_UB1},
300 {PXP2_REG_PSWRQ_BW_L2, PXP2_REG_PSWRQ_BW_ADD2,
301 PXP2_REG_PSWRQ_BW_UB2},
302 {PXP2_REG_PSWRQ_BW_L3, PXP2_REG_PSWRQ_BW_ADD3,
303 PXP2_REG_PSWRQ_BW_UB3},
304 {PXP2_REG_PSWRQ_BW_L6, PXP2_REG_PSWRQ_BW_ADD6,
305 PXP2_REG_PSWRQ_BW_UB6},
306 {PXP2_REG_PSWRQ_BW_L7, PXP2_REG_PSWRQ_BW_ADD7,
307 PXP2_REG_PSWRQ_BW_UB7},
308 {PXP2_REG_PSWRQ_BW_L8, PXP2_REG_PSWRQ_BW_ADD8,
309 PXP2_REG_PSWRQ_BW_UB8},
310 {PXP2_REG_PSWRQ_BW_L9, PXP2_REG_PSWRQ_BW_ADD9,
311 PXP2_REG_PSWRQ_BW_UB9},
312 {PXP2_REG_PSWRQ_BW_L10, PXP2_REG_PSWRQ_BW_ADD10,
313 PXP2_REG_PSWRQ_BW_UB10},
314 {PXP2_REG_PSWRQ_BW_L11, PXP2_REG_PSWRQ_BW_ADD11,
315 PXP2_REG_PSWRQ_BW_UB11},
316 /* 10 */{PXP2_REG_PSWRQ_BW_L28, PXP2_REG_PSWRQ_BW_ADD28,
317 PXP2_REG_PSWRQ_BW_UB28},
318 {PXP2_REG_RQ_BW_WR_L29, PXP2_REG_RQ_BW_WR_ADD29,
319 PXP2_REG_RQ_BW_WR_UBOUND29},
320 {PXP2_REG_RQ_BW_WR_L30, PXP2_REG_RQ_BW_WR_ADD30,
321 PXP2_REG_RQ_BW_WR_UBOUND30}
325 /****************************************************************************
327 ****************************************************************************/
329 #define CDU_REGION_NUMBER_XCM_AG 2
330 #define CDU_REGION_NUMBER_UCM_AG 4
333 * String-to-compress [31:8] = CID (all 24 bits)
334 * String-to-compress [7:4] = Region
335 * String-to-compress [3:0] = Type
337 #define CDU_VALID_DATA(_cid, _region, _type) \
338 (((_cid) << 8) | (((_region) & 0xf) << 4) | (((_type) & 0xf)))
339 #define CDU_CRC8(_cid, _region, _type) \
340 calc_crc8(CDU_VALID_DATA(_cid, _region, _type), 0xff)
341 #define CDU_RSRVD_VALUE_TYPE_A(_cid, _region, _type) \
342 (0x80 | (CDU_CRC8(_cid, _region, _type) & 0x7f))
343 #define CDU_RSRVD_VALUE_TYPE_B(_crc, _type) \
344 (0x80 | ((_type) & 0xf << 3) | (CDU_CRC8(_cid, _region, _type) & 0x7))
345 #define CDU_RSRVD_INVALIDATE_CONTEXT_VALUE(_val) ((_val) & ~0x80)
348 /* registers addresses are not in order
349 so these arrays help simplify the code */
350 static const int cm_blocks[9] = {
351 MISC_BLOCK, TCM_BLOCK, UCM_BLOCK, CCM_BLOCK, XCM_BLOCK,
352 TSEM_BLOCK, USEM_BLOCK, CSEM_BLOCK, XSEM_BLOCK
355 #endif /* BNX2X_INIT_H */