This source file includes following definitions.
- csio_t5_set_mem_win
- csio_t5_pcie_intr_handler
- csio_t5_flash_cfg_addr
- csio_t5_mc_read
- csio_t5_edc_read
- csio_t5_memory_rw
- csio_t5_dfs_create_ext_mem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #include "csio_hw.h"
35 #include "csio_init.h"
36
37 static int
38 csio_t5_set_mem_win(struct csio_hw *hw, uint32_t win)
39 {
40 u32 mem_win_base;
41
42
43
44
45
46
47
48
49
50
51
52 mem_win_base = MEMWIN_BASE;
53
54
55
56
57
58
59 csio_wr_reg32(hw, mem_win_base | BIR_V(0) |
60 WINDOW_V(ilog2(MEMWIN_APERTURE) - 10),
61 PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN_A, win));
62 csio_rd_reg32(hw,
63 PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN_A, win));
64
65 return 0;
66 }
67
68
69
70
71 static void
72 csio_t5_pcie_intr_handler(struct csio_hw *hw)
73 {
74 static struct intr_info pcie_intr_info[] = {
75 { MSTGRPPERR_F, "Master Response Read Queue parity error",
76 -1, 1 },
77 { MSTTIMEOUTPERR_F, "Master Timeout FIFO parity error", -1, 1 },
78 { MSIXSTIPERR_F, "MSI-X STI SRAM parity error", -1, 1 },
79 { MSIXADDRLPERR_F, "MSI-X AddrL parity error", -1, 1 },
80 { MSIXADDRHPERR_F, "MSI-X AddrH parity error", -1, 1 },
81 { MSIXDATAPERR_F, "MSI-X data parity error", -1, 1 },
82 { MSIXDIPERR_F, "MSI-X DI parity error", -1, 1 },
83 { PIOCPLGRPPERR_F, "PCI PIO completion Group FIFO parity error",
84 -1, 1 },
85 { PIOREQGRPPERR_F, "PCI PIO request Group FIFO parity error",
86 -1, 1 },
87 { TARTAGPERR_F, "PCI PCI target tag FIFO parity error", -1, 1 },
88 { MSTTAGQPERR_F, "PCI master tag queue parity error", -1, 1 },
89 { CREQPERR_F, "PCI CMD channel request parity error", -1, 1 },
90 { CRSPPERR_F, "PCI CMD channel response parity error", -1, 1 },
91 { DREQWRPERR_F, "PCI DMA channel write request parity error",
92 -1, 1 },
93 { DREQPERR_F, "PCI DMA channel request parity error", -1, 1 },
94 { DRSPPERR_F, "PCI DMA channel response parity error", -1, 1 },
95 { HREQWRPERR_F, "PCI HMA channel count parity error", -1, 1 },
96 { HREQPERR_F, "PCI HMA channel request parity error", -1, 1 },
97 { HRSPPERR_F, "PCI HMA channel response parity error", -1, 1 },
98 { CFGSNPPERR_F, "PCI config snoop FIFO parity error", -1, 1 },
99 { FIDPERR_F, "PCI FID parity error", -1, 1 },
100 { VFIDPERR_F, "PCI INTx clear parity error", -1, 1 },
101 { MAGRPPERR_F, "PCI MA group FIFO parity error", -1, 1 },
102 { PIOTAGPERR_F, "PCI PIO tag parity error", -1, 1 },
103 { IPRXHDRGRPPERR_F, "PCI IP Rx header group parity error",
104 -1, 1 },
105 { IPRXDATAGRPPERR_F, "PCI IP Rx data group parity error",
106 -1, 1 },
107 { RPLPERR_F, "PCI IP replay buffer parity error", -1, 1 },
108 { IPSOTPERR_F, "PCI IP SOT buffer parity error", -1, 1 },
109 { TRGT1GRPPERR_F, "PCI TRGT1 group FIFOs parity error", -1, 1 },
110 { READRSPERR_F, "Outbound read error", -1, 0 },
111 { 0, NULL, 0, 0 }
112 };
113
114 int fat;
115 fat = csio_handle_intr_status(hw, PCIE_INT_CAUSE_A, pcie_intr_info);
116 if (fat)
117 csio_hw_fatal_err(hw);
118 }
119
120
121
122
123
124
125
126
127 static unsigned int
128 csio_t5_flash_cfg_addr(struct csio_hw *hw)
129 {
130 return FLASH_CFG_START;
131 }
132
133
134
135
136
137
138
139
140
141
142
143
144
145 static int
146 csio_t5_mc_read(struct csio_hw *hw, int idx, uint32_t addr, __be32 *data,
147 uint64_t *ecc)
148 {
149 int i;
150 uint32_t mc_bist_cmd_reg, mc_bist_cmd_addr_reg, mc_bist_cmd_len_reg;
151 uint32_t mc_bist_status_rdata_reg, mc_bist_data_pattern_reg;
152
153 mc_bist_cmd_reg = MC_REG(MC_P_BIST_CMD_A, idx);
154 mc_bist_cmd_addr_reg = MC_REG(MC_P_BIST_CMD_ADDR_A, idx);
155 mc_bist_cmd_len_reg = MC_REG(MC_P_BIST_CMD_LEN_A, idx);
156 mc_bist_status_rdata_reg = MC_REG(MC_P_BIST_STATUS_RDATA_A, idx);
157 mc_bist_data_pattern_reg = MC_REG(MC_P_BIST_DATA_PATTERN_A, idx);
158
159 if (csio_rd_reg32(hw, mc_bist_cmd_reg) & START_BIST_F)
160 return -EBUSY;
161 csio_wr_reg32(hw, addr & ~0x3fU, mc_bist_cmd_addr_reg);
162 csio_wr_reg32(hw, 64, mc_bist_cmd_len_reg);
163 csio_wr_reg32(hw, 0xc, mc_bist_data_pattern_reg);
164 csio_wr_reg32(hw, BIST_OPCODE_V(1) | START_BIST_F | BIST_CMD_GAP_V(1),
165 mc_bist_cmd_reg);
166 i = csio_hw_wait_op_done_val(hw, mc_bist_cmd_reg, START_BIST_F,
167 0, 10, 1, NULL);
168 if (i)
169 return i;
170
171 #define MC_DATA(i) MC_BIST_STATUS_REG(MC_BIST_STATUS_RDATA_A, i)
172
173 for (i = 15; i >= 0; i--)
174 *data++ = htonl(csio_rd_reg32(hw, MC_DATA(i)));
175 if (ecc)
176 *ecc = csio_rd_reg64(hw, MC_DATA(16));
177 #undef MC_DATA
178 return 0;
179 }
180
181
182
183
184
185
186
187
188
189
190
191
192
193 static int
194 csio_t5_edc_read(struct csio_hw *hw, int idx, uint32_t addr, __be32 *data,
195 uint64_t *ecc)
196 {
197 int i;
198 uint32_t edc_bist_cmd_reg, edc_bist_cmd_addr_reg, edc_bist_cmd_len_reg;
199 uint32_t edc_bist_cmd_data_pattern, edc_bist_status_rdata_reg;
200
201
202
203
204 #define EDC_STRIDE_T5 (EDC_T51_BASE_ADDR - EDC_T50_BASE_ADDR)
205 #define EDC_REG_T5(reg, idx) (reg + EDC_STRIDE_T5 * idx)
206
207 edc_bist_cmd_reg = EDC_REG_T5(EDC_H_BIST_CMD_A, idx);
208 edc_bist_cmd_addr_reg = EDC_REG_T5(EDC_H_BIST_CMD_ADDR_A, idx);
209 edc_bist_cmd_len_reg = EDC_REG_T5(EDC_H_BIST_CMD_LEN_A, idx);
210 edc_bist_cmd_data_pattern = EDC_REG_T5(EDC_H_BIST_DATA_PATTERN_A, idx);
211 edc_bist_status_rdata_reg = EDC_REG_T5(EDC_H_BIST_STATUS_RDATA_A, idx);
212 #undef EDC_REG_T5
213 #undef EDC_STRIDE_T5
214
215 if (csio_rd_reg32(hw, edc_bist_cmd_reg) & START_BIST_F)
216 return -EBUSY;
217 csio_wr_reg32(hw, addr & ~0x3fU, edc_bist_cmd_addr_reg);
218 csio_wr_reg32(hw, 64, edc_bist_cmd_len_reg);
219 csio_wr_reg32(hw, 0xc, edc_bist_cmd_data_pattern);
220 csio_wr_reg32(hw, BIST_OPCODE_V(1) | START_BIST_F | BIST_CMD_GAP_V(1),
221 edc_bist_cmd_reg);
222 i = csio_hw_wait_op_done_val(hw, edc_bist_cmd_reg, START_BIST_F,
223 0, 10, 1, NULL);
224 if (i)
225 return i;
226
227 #define EDC_DATA(i) (EDC_BIST_STATUS_REG(EDC_BIST_STATUS_RDATA_A, i) + idx)
228
229 for (i = 15; i >= 0; i--)
230 *data++ = htonl(csio_rd_reg32(hw, EDC_DATA(i)));
231 if (ecc)
232 *ecc = csio_rd_reg64(hw, EDC_DATA(16));
233 #undef EDC_DATA
234 return 0;
235 }
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254 static int
255 csio_t5_memory_rw(struct csio_hw *hw, u32 win, int mtype, u32 addr,
256 u32 len, uint32_t *buf, int dir)
257 {
258 u32 pos, start, offset, memoffset;
259 u32 edc_size, mc_size, win_pf, mem_reg, mem_aperture, mem_base;
260
261
262
263
264 if ((addr & 0x3) || (len & 0x3))
265 return -EINVAL;
266
267
268
269
270
271
272
273
274 edc_size = EDRAM0_SIZE_G(csio_rd_reg32(hw, MA_EDRAM0_BAR_A));
275 if (mtype != MEM_MC1)
276 memoffset = (mtype * (edc_size * 1024 * 1024));
277 else {
278 mc_size = EXT_MEM_SIZE_G(csio_rd_reg32(hw,
279 MA_EXT_MEMORY_BAR_A));
280 memoffset = (MEM_MC0 * edc_size + mc_size) * 1024 * 1024;
281 }
282
283
284 addr = addr + memoffset;
285
286
287
288
289
290
291
292
293
294
295 mem_reg = csio_rd_reg32(hw,
296 PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN_A, win));
297 mem_aperture = 1 << (WINDOW_V(mem_reg) + 10);
298 mem_base = PCIEOFST_G(mem_reg) << 10;
299
300 start = addr & ~(mem_aperture-1);
301 offset = addr - start;
302 win_pf = PFNUM_V(hw->pfn);
303
304 csio_dbg(hw, "csio_t5_memory_rw: mem_reg: 0x%x, mem_aperture: 0x%x\n",
305 mem_reg, mem_aperture);
306 csio_dbg(hw, "csio_t5_memory_rw: mem_base: 0x%x, mem_offset: 0x%x\n",
307 mem_base, memoffset);
308 csio_dbg(hw, "csio_t5_memory_rw: start:0x%x, offset:0x%x, win_pf:%d\n",
309 start, offset, win_pf);
310 csio_dbg(hw, "csio_t5_memory_rw: mtype: %d, addr: 0x%x, len: %d\n",
311 mtype, addr, len);
312
313 for (pos = start; len > 0; pos += mem_aperture, offset = 0) {
314
315
316
317
318
319 csio_wr_reg32(hw, pos | win_pf,
320 PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_OFFSET_A, win));
321 csio_rd_reg32(hw,
322 PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_OFFSET_A, win));
323
324 while (offset < mem_aperture && len > 0) {
325 if (dir)
326 *buf++ = csio_rd_reg32(hw, mem_base + offset);
327 else
328 csio_wr_reg32(hw, *buf++, mem_base + offset);
329
330 offset += sizeof(__be32);
331 len -= sizeof(__be32);
332 }
333 }
334 return 0;
335 }
336
337
338
339
340
341
342
343
344 static void
345 csio_t5_dfs_create_ext_mem(struct csio_hw *hw)
346 {
347 u32 size;
348 int i = csio_rd_reg32(hw, MA_TARGET_MEM_ENABLE_A);
349
350 if (i & EXT_MEM_ENABLE_F) {
351 size = csio_rd_reg32(hw, MA_EXT_MEMORY_BAR_A);
352 csio_add_debugfs_mem(hw, "mc0", MEM_MC0,
353 EXT_MEM_SIZE_G(size));
354 }
355 if (i & EXT_MEM1_ENABLE_F) {
356 size = csio_rd_reg32(hw, MA_EXT_MEMORY1_BAR_A);
357 csio_add_debugfs_mem(hw, "mc1", MEM_MC1,
358 EXT_MEM_SIZE_G(size));
359 }
360 }
361
362
363 struct csio_hw_chip_ops t5_ops = {
364 .chip_set_mem_win = csio_t5_set_mem_win,
365 .chip_pcie_intr_handler = csio_t5_pcie_intr_handler,
366 .chip_flash_cfg_addr = csio_t5_flash_cfg_addr,
367 .chip_mc_read = csio_t5_mc_read,
368 .chip_edc_read = csio_t5_edc_read,
369 .chip_memory_rw = csio_t5_memory_rw,
370 .chip_dfs_create_ext_mem = csio_t5_dfs_create_ext_mem,
371 };