Debian Codegraph @

src/vendorcode/cavium/bdk/libbdk-hal/qlm/bdk-qlm-errata-cn8xxx.c

raw symbols SCIP
1 /***********************license start***********************************
2 * Copyright (c) 2003-2017 Cavium Inc. ([email protected]). All rights
3 * reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 *
18 * * Neither the name of Cavium Inc. nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
21 * permission.
22 *
23 * This Software, including technical data, may be subject to U.S. export
24 * control laws, including the U.S. Export Administration Act and its
25 * associated regulations, and may be subject to export or import
26 * regulations in other countries.
27 *
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT
31 * TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
32 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
33 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
34 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
35 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT,
36 * QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK
37 * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
39 #include <bdk.h>
40 #include "libbdk-arch/bdk-csrs-gser.h"
41 #include "libbdk-arch/bdk-csrs-rst.h"
42 #include "libbdk-hal/qlm/bdk-qlm-errata-cn8xxx.h"
43
44 /**
45 * Delay for the specified microseconds. When this code runs on secondary nodes
46 * before full init, the normal bdk-clock functions do not work. This function
47 * serves as a replacement that runs everywhere.
48 *
49 * @param usec Microseconds to wait
50 */
51 static void wait_usec(bdk_node_t node, uint64_t usec)
52 {
53 const uint64_t REF_CLOCK = 50000000; /* This is currently defined to be 50Mhz */
54 uint64_t refclock = BDK_CSR_READ(node, BDK_RST_REF_CNTR);
55 uint64_t timeout = refclock + REF_CLOCK * usec / 1000000;
56 while (refclock < timeout)
57 {
58 refclock = BDK_CSR_READ(node, BDK_RST_REF_CNTR);
59 }
60 }
61
62 /**
63 * Errata GSER-25992 - RX EQ Default Settings Update<p>
64 * For all GSER and all lanes when not PCIe EP:
65 * set GSER()_LANE()_RX_CFG_4[CFG_RX_ERRDET_CTRL<13:8>] = 13 (decimal)
66 * set GSER()_LANE()_RX_CTLE_CTRL[PCS_SDS_RX_CTLE_BIAS_CTRL] = 3
67 * Applied when SERDES are configured for 8G and 10G.<p>
68 * Applies to:
69 * CN88XX pass 1.x
70 * Fixed in hardware:
71 * CN88XX pass 2.x
72 * CN81XX
73 * CN83XX
74 *
75 * @param node Node to apply errata fix for
76 * @param qlm QLM to apply errata fix to
77 * @param baud_mhz QLM speed in Mhz
78 *
79 * @return Zero on success, negative on failure
80 */
81 int __bdk_qlm_errata_gser_25992(bdk_node_t node, int qlm, int baud_mhz)
82 {
83 if (!CAVIUM_IS_MODEL(CAVIUM_CN88XX_PASS1_X))
84 return 0;
85 if (baud_mhz < 8000)
86 return 0;
87
88 int num_lanes = 4; /* Only applies to CN88XX, where always 4 lanes */
89 for (int lane = 0; lane < num_lanes; lane++)
90 {
91 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_RX_CTLE_CTRL(qlm, lane),
92 c.s.pcs_sds_rx_ctle_bias_ctrl = 3);
93 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_RX_CFG_4(qlm, lane),
94 c.s.cfg_rx_errdet_ctrl = 0xcd6f);
95 }
96 return 0;
97 }
98
99 /**
100 * (GSER-26150) 10G PHY PLL Temperature Failure
101 *
102 * 10 Gb temperature excursions can cause lock failure. Change
103 * the calibration point of the VCO at start up to shift some
104 * available range of the VCO from -deltaT direction to the
105 * +deltaT ramp direction allowing a greater range of VCO
106 * temperatures before experiencing the failure.
107 *
108 * Applies to:
109 * CN88XX pass 1.x
110 * Fix in hardware:
111 * CN88XX pass 2.x
112 * CN81XX
113 * CN83XX
114 *
115 * Only applies to QLMs running 8G and 10G
116 *
117 * @param node Node to apply errata to
118 * @param qlm QLM to apply errata fix to
119 *
120 * @return Zero on success, negative on failure
121 */
122 int __bdk_qlm_errata_gser_26150(bdk_node_t node, int qlm, int baud_mhz)
123 {
124 if (!CAVIUM_IS_MODEL(CAVIUM_CN88XX_PASS1_X))
125 return 0;
126 if (baud_mhz < 8000)
127 return 0;
128
129 int num_lanes = 4; /* Only applies to CN88XX, where always 4 lanes */
130
131 BDK_CSR_INIT(gserx_cfg, node, BDK_GSERX_CFG(qlm));
132 if (gserx_cfg.s.pcie)
133 {
134 /* Update PLL parameters */
135 /* Step 1: Set GSER()_GLBL_PLL_CFG_3[PLL_VCTRL_SEL_LCVCO_VAL] = 0x2, and
136 GSER()_GLBL_PLL_CFG_3[PCS_SDS_PLL_VCO_AMP] = 0 */
137 BDK_CSR_MODIFY(c, node, BDK_GSERX_GLBL_PLL_CFG_3(qlm),
138 c.s.pll_vctrl_sel_lcvco_val = 0x2;
139 c.s.pcs_sds_pll_vco_amp = 0);
140 /* Step 2: Set GSER()_GLBL_MISC_CONFIG_1[PCS_SDS_TRIM_CHP_REG] = 0x2. */
141 BDK_CSR_MODIFY(c, node, BDK_GSERX_GLBL_MISC_CONFIG_1(qlm),
142 c.s.pcs_sds_trim_chp_reg = 0x2);
143 return 0;
144 }
145
146 /* Applying this errata twice causes problems */
147 BDK_CSR_INIT(pll_cfg_3, node, BDK_GSERX_GLBL_PLL_CFG_3(qlm));
148 if (pll_cfg_3.s.pll_vctrl_sel_lcvco_val == 0x2)
149 return 0;
150
151 /* Put PHY in P2 Power-down state Need to Power down all lanes in a
152 QLM/DLM to force PHY to P2 state */
153 for (int i=0; i<num_lanes; i++)
154 {
155 /* Step 1: Set GSER()_LANE(lane_n)_PCS_CTLIFC_0[CFG_TX_PSTATE_REQ_OVERRD_VAL] = 0x3
156 Select P2 power state for Tx lane */
157 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_0(qlm, i),
158 c.s.cfg_tx_pstate_req_ovrrd_val = 0x3);
159 /* Step 2: Set GSER()_LANE(lane_n)_PCS_CTLIFC_1[CFG_RX_PSTATE_REQ_OVERRD_VAL] = 0x3
160 Select P2 power state for Rx lane */
161 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_1(qlm, i),
162 c.s.cfg_rx_pstate_req_ovrrd_val = 0x3);
163 /* Step 3: Set GSER()_LANE(lane_n)_PCS_CTLIFC_2[CFG_TX_PSTATE_REQ_OVRRD_EN] = 1
164 Enable Tx power state override and Set
165 GSER()_LANE(lane_n)_PCS_CTLIFC_2[CFG_RX_PSTATE_REQ_OVRRD_EN] = 1
166 Enable Rx power state override */
167 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, i),
168 c.s.cfg_tx_pstate_req_ovrrd_en = 0x1;
169 c.s.cfg_rx_pstate_req_ovrrd_en = 0x1);
170 /* Step 4: Set GSER()_LANE(lane_n)_PCS_CTLIFC_2[CTLIFC_OVRRD_REQ] = 1
171 Start the CTLIFC override state machine */
172 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, i),
173 c.s.ctlifc_ovrrd_req = 0x1);
174 }
175
176 /* Update PLL parameters */
177 /* Step 5: Set GSER()_GLBL_PLL_CFG_3[PLL_VCTRL_SEL_LCVCO_VAL] = 0x2, and
178 GSER()_GLBL_PLL_CFG_3[PCS_SDS_PLL_VCO_AMP] = 0 */
179 BDK_CSR_MODIFY(c, node, BDK_GSERX_GLBL_PLL_CFG_3(qlm),
180 c.s.pll_vctrl_sel_lcvco_val = 0x2;
181 c.s.pcs_sds_pll_vco_amp = 0);
182 /* Step 6: Set GSER()_GLBL_MISC_CONFIG_1[PCS_SDS_TRIM_CHP_REG] = 0x2. */
183 BDK_CSR_MODIFY(c, node, BDK_GSERX_GLBL_MISC_CONFIG_1(qlm),
184 c.s.pcs_sds_trim_chp_reg = 0x2);
185 /* Wake up PHY and transition to P0 Power-up state to bring-up the lanes,
186 need to wake up all PHY lanes */
187 for (int i=0; i<num_lanes; i++)
188 {
189 /* Step 7: Set GSER()_LANE(lane_n)_PCS_CTLIFC_0[CFG_TX_PSTATE_REQ_OVERRD_VAL] = 0x0
190 Select P0 power state for Tx lane */
191 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_0(qlm, i),
192 c.s.cfg_tx_pstate_req_ovrrd_val = 0x0);
193 /* Step 8: Set GSER()_LANE(lane_n)_PCS_CTLIFC_1[CFG_RX_PSTATE_REQ_OVERRD_VAL] = 0x0
194 Select P0 power state for Rx lane */
195 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_1(qlm, i),
196 c.s.cfg_rx_pstate_req_ovrrd_val = 0x0);
197 /* Step 9: Set GSER()_LANE(lane_n)_PCS_CTLIFC_2[CFG_TX_PSTATE_REQ_OVRRD_EN] = 1
198 Enable Tx power state override and Set
199 GSER()_LANE(lane_n)_PCS_CTLIFC_2[CFG_RX_PSTATE_REQ_OVRRD_EN] = 1
200 Enable Rx power state override */
201 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, i),
202 c.s.cfg_tx_pstate_req_ovrrd_en = 0x1;
203 c.s.cfg_rx_pstate_req_ovrrd_en = 0x1);
204 /* Step 10: Set GSER()_LANE(lane_n)_PCS_CTLIFC_2[CTLIFC_OVRRD_REQ] = 1
205 Start the CTLIFC override state machine */
206 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, i),
207 c.s.ctlifc_ovrrd_req = 0x1);
208 }
209
210 /* Step 11: Wait 10 msec */
211 wait_usec(node, 10000);
212
213 /* Release Lane Tx/Rx Power state override enables. */
214 for (int i=0; i<num_lanes; i++)
215 {
216 /* Step 12: Set GSER()_LANE(lane_n)_PCS_CTLIFC_2[CFG_TX_PSTATE_REQ_OVRRD_EN] = 0
217 Disable Tx power state override and Set
218 GSER()_LANE(lane_n)_PCS_CTLIFC_2[CFG_RX_PSTATE_REQ_OVRRD_EN] = 0
219 Disable Rx power state override */
220 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, i),
221 c.s.cfg_tx_pstate_req_ovrrd_en = 0x0;
222 c.s.cfg_rx_pstate_req_ovrrd_en = 0x0);
223 }
224 /* Step 13: Poll GSER()_PLL_STAT.[PLL_LOCK] = 1
225 Poll and check that PLL is locked */
226 if (BDK_CSR_WAIT_FOR_FIELD(node, BDK_GSERX_PLL_STAT(qlm), pll_lock, ==, 1, 10000))
227 {
228 bdk_error("QLM%d: Timeout waiting for GSERX_PLL_STAT[pll_lock]\n", qlm);
229 return -1;
230 }
231
232 /* Step 14: Poll GSER()_QLM_STAT.[RST_RDY] = 1
233 Poll and check that QLM/DLM is Ready */
234 if (BDK_CSR_WAIT_FOR_FIELD(node, BDK_GSERX_QLM_STAT(qlm), rst_rdy, ==, 1, 10000))
235 {
236 bdk_error("QLM%d: Timeout waiting for GSERX_QLM_STAT[rst_rdy]\n", qlm);
237 return -1;
238 }
239 return 0;
240 }
241
242 /**
243 * Errata (GSER-26636) 10G-KR/40G-KR - Inverted Tx Coefficient Direction Change
244 * Applied to all 10G standards (required for KR) but also applied to other
245 * standards in case software training is used.
246 * Applies to:
247 * CN88XX pass 1.x
248 * Fixed in hardware:
249 * CN88XX pass 2.x
250 * CN81XX
251 * CN83XX
252 *
253 * @param node Node to apply errata fix for
254 * @param qlm QLM to apply errata fix to
255 * @param baud_mhz QLM speed in Mhz
256 *
257 * @return Zero on success, negative on failure
258 */
259 int __bdk_qlm_errata_gser_26636(bdk_node_t node, int qlm, int baud_mhz)
260 {
261 if (!CAVIUM_IS_MODEL(CAVIUM_CN88XX_PASS1_X))
262 return 0;
263
264 BDK_CSR_MODIFY(c, node, BDK_GSERX_RX_TXDIR_CTRL_1(qlm),
265 c.s.rx_precorr_chg_dir = 1;
266 c.s.rx_tap1_chg_dir = 1);
267 return 0;
268 }
269
270 /**
271 * (GSER-27140) SERDES has temperature drift sensitivity in the RX EQ<p>
272 * SERDES temperature drift sensitivity in receiver. Issues have
273 * been found with the Bit Error Rate (BER) reliability of
274 * 10GBASE-KR links over the commercial temperature range (0 to 100C),
275 * especially when subjected to rapid thermal ramp stress testing.
276 * (See HRM for corresponding case temperature requirements for each speed grade.)<p>
277 * Applies to:
278 * CN88XX pass 1.x
279 * CN88XX pass 2.x
280 * CN83XX pass 1.x
281 * CN81XX pass 1.x
282 * Fixed in hardware:
283 * TBD<p>
284 * Only applies to QLMs running 10G
285 *
286 * @param node Note to apply errata fix to
287 * @param qlm QLM to apply errata fix to
288 * @param baud_mhz QLM baud rate in Mhz
289 * @param channel_loss
290 * Insertion loss at Nyquist rate (e.g. 5.125Ghz for XFI/XLAUI) in dB
291 *
292 * @return Zero on success, negative on failure
293 */
294 int __bdk_qlm_errata_gser_27140(bdk_node_t node, int qlm, int baud_mhz, int channel_loss)
295 {
296 if (baud_mhz != 10312)
297 return 0;
298
299 /* A channel loss of -1 means the loss is unknown. A short channel is
300 considered to have loss between 0 and 10 dB */
301 bool short_channel = (channel_loss >= 0) && (channel_loss <= 10);
302
303 /* I. For each GSER QLM: */
304 /* Workaround GSER-27140: */
305 /* (1) GSER-26150 = Applied by the caller */
306 /* (2) Write GSER()_LANE_VMA_FINE_CTRL_0[RX_SDLL_IQ_MAX_FINE] = 0xE */
307 /* (3) Write GSER()_LANE_VMA_FINE_CTRL_0[RX_SDLL_IQ_MIN_FINE] = 0x8 */
308 /* (4) Write GSER()_LANE_VMA_FINE_CTRL_0[RX_SDLL_IQ_STEP_FINE] = 0x2 */
309 /* (5) Write GSER()_LANE_VMA_FINE_CTRL_0[VMA_WINDOW_WAIT_FINE] = 0x5 */
310 /* (6) Write GSER()_LANE_VMA_FINE_CTRL_0[LMS_WAIT_TIME_FINE] = 0x5 */
311 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANE_VMA_FINE_CTRL_0(qlm),
312 c.s.rx_sdll_iq_max_fine = 0xE;
313 c.s.rx_sdll_iq_min_fine = 0x8;
314 c.s.rx_sdll_iq_step_fine = 0x2;
315 c.s.vma_window_wait_fine = 0x5;
316 c.s.lms_wait_time_fine = 0x5);
317 /* (7) Write GSER()_LANE_VMA_FINE_CTRL_2[RX_PRECTLE_GAIN_MAX_FINE] = 0xB */
318 /* (8) Write GSER()_LANE_VMA_FINE_CTRL_2[RX_PRECTLE_GAIN_MIN_FINE] = 0x6(long) or 0x0(short) */
319 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANE_VMA_FINE_CTRL_2(qlm),
320 c.s.rx_prectle_gain_max_fine = 0xB;
321 c.s.rx_prectle_gain_min_fine = short_channel ? 0x0 : 0x6);
322 /* (9) Write GSER()_RX_TXDIR_CTRL_0[RX_BOOST_LO_THRES] = 0x4 */
323 /* (10) Write GSER()_RX_TXDIR_CTRL_0[RX_BOOST_HI_THRES] = 0xB */
324 /* (11) Write GSER()_RX_TXDIR_CTRL_0[RX_BOOST_HI_VAL] = 0xF */
325 BDK_CSR_MODIFY(c, node, BDK_GSERX_RX_TXDIR_CTRL_0(qlm),
326 c.s.rx_boost_lo_thrs = 0x4;
327 c.s.rx_boost_hi_thrs = 0xB;
328 c.s.rx_boost_hi_val = 0xF);
329 /* (12) Write GSER()_RX_TXDIR_CTRL_1[RX_TAP1_LO_THRS] = 0x8 */
330 /* (13) Write GSER()_RX_TXDIR_CTRL_1[RX_TAP1_HI_THRS] = 0x17 */
331 BDK_CSR_MODIFY(c, node, BDK_GSERX_RX_TXDIR_CTRL_1(qlm),
332 c.s.rx_tap1_lo_thrs = 0x8;
333 c.s.rx_tap1_hi_thrs = 0x17);
334
335 /* (14) Write GSER()_EQ_WAIT_TIME[RXEQ_WAIT_CNT] = 0x6 */
336 BDK_CSR_MODIFY(c, node, BDK_GSERX_EQ_WAIT_TIME(qlm),
337 c.s.rxeq_wait_cnt = 0x6);
338 /* (15) Write GSER()_RX_TXDIR_CTRL_2[RX_PRECORR_HI_THRS] = 0xC0 */
339 /* (16) Write GSER()_RX_TXDIR_CTRL_2[RX_PRECORR_LO_THRS] = 0x40 */
340 BDK_CSR_MODIFY(c, node, BDK_GSERX_RX_TXDIR_CTRL_2(qlm),
341 c.s.rx_precorr_hi_thrs = 0xc0;
342 c.s.rx_precorr_lo_thrs = 0x40);
343
344 /* We can't call the normal bdk-qlm function as it uses pointers that
345 don't work when running in secondary nodes before CCPI is up */
346 int num_lanes = 4;
347 if (CAVIUM_IS_MODEL(CAVIUM_CN81XX) || (CAVIUM_IS_MODEL(CAVIUM_CN83XX) && (qlm >= 4)))
348 num_lanes = 2;
349
350 /* II. For each GSER QLM SerDes lane: */
351 /* Establish typical values, which are already reset values in pass 2: */
352 for (int lane = 0; lane < num_lanes; lane++)
353 {
354 /* (17) For each GSER lane in the 10GBASE-KR link: */
355 /* (a) Write GSER()_LANE()_RX_VALBBD_CTRL_0[AGC_GAIN] = 0x3 */
356 /* (b) Write GSER()_LANE()_RX_VALBBD_CTRL_0[DFE_GAIN] = 0x2 */
357 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_RX_VALBBD_CTRL_0(qlm, lane),
358 c.s.agc_gain = 0x3;
359 c.s.dfe_gain = 0x2);
360 }
361
362 /* III. The GSER QLM SerDes Lanes are now ready. */
363 return 0;
364 }
365
366 /**
367 * Errata GSER-27882 -GSER 10GBASE-KR Transmit Equalizer
368 * Training may not update PHY Tx Taps. This function is not static
369 * so we can share it with BGX KR
370 * Applies to:
371 * CN88XX pass 1.x, 2.0, 2.1
372 * Fixed in hardware:
373 * CN88XX pass 2.2 and higher
374 * CN81XX
375 * CN83XX
376 *
377 * @param node Node to apply errata fix for
378 * @param qlm QLM to apply errata fix to
379 * @param lane
380 *
381 * @return Zero on success, negative on failure
382 */
383 int __bdk_qlm_errata_gser_27882(bdk_node_t node, int qlm, int lane)
384 {
385 /* Toggle Toggle Tx Coeff Req override to force an update */
386 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_0(qlm, lane),
387 c.s.cfg_tx_coeff_req_ovrrd_val = 1);
388 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, lane),
389 c.s.cfg_tx_coeff_req_ovrrd_en = 1);
390 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, lane),
391 c.s.ctlifc_ovrrd_req = 1);
392 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, lane),
393 c.s.cfg_tx_coeff_req_ovrrd_en = 0);
394 BDK_CSR_MODIFY(c, node, BDK_GSERX_LANEX_PCS_CTLIFC_2(qlm, lane),
395 c.s.ctlifc_ovrrd_req = 1);
396 return 0;
397 }
398