]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
Merge remote-tracking branch 'u-boot/master'
[people/ms/u-boot.git] / arch / powerpc / cpu / mpc85xx / fsl_corenet_serdes.c
1 /*
2 * Copyright 2009-2011 Freescale Semiconductor, Inc.
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23 #include <common.h>
24 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
25 #include <hwconfig.h>
26 #endif
27 #include <asm/fsl_serdes.h>
28 #include <asm/immap_85xx.h>
29 #include <asm/io.h>
30 #include <asm/processor.h>
31 #include <asm/fsl_law.h>
32 #include <asm/errno.h>
33 #include "fsl_corenet_serdes.h"
34
35 /*
36 * The work-arounds for erratum SERDES8 and SERDES-A001 are linked together.
37 * The code is already very complicated as it is, and separating the two
38 * completely would just make things worse. We try to keep them as separate
39 * as possible, but for now we require SERDES8 if SERDES_A001 is defined.
40 */
41 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES_A001
42 #ifndef CONFIG_SYS_P4080_ERRATUM_SERDES8
43 #error "CONFIG_SYS_P4080_ERRATUM_SERDES_A001 requires CONFIG_SYS_P4080_ERRATUM_SERDES8"
44 #endif
45 #endif
46
47 static u32 serdes_prtcl_map;
48
49 #ifdef DEBUG
50 static const char *serdes_prtcl_str[] = {
51 [NONE] = "NA",
52 [PCIE1] = "PCIE1",
53 [PCIE2] = "PCIE2",
54 [PCIE3] = "PCIE3",
55 [PCIE4] = "PCIE4",
56 [SATA1] = "SATA1",
57 [SATA2] = "SATA2",
58 [SRIO1] = "SRIO1",
59 [SRIO2] = "SRIO2",
60 [SGMII_FM1_DTSEC1] = "SGMII_FM1_DTSEC1",
61 [SGMII_FM1_DTSEC2] = "SGMII_FM1_DTSEC2",
62 [SGMII_FM1_DTSEC3] = "SGMII_FM1_DTSEC3",
63 [SGMII_FM1_DTSEC4] = "SGMII_FM1_DTSEC4",
64 [SGMII_FM1_DTSEC5] = "SGMII_FM1_DTSEC5",
65 [SGMII_FM2_DTSEC1] = "SGMII_FM2_DTSEC1",
66 [SGMII_FM2_DTSEC2] = "SGMII_FM2_DTSEC2",
67 [SGMII_FM2_DTSEC3] = "SGMII_FM2_DTSEC3",
68 [SGMII_FM2_DTSEC4] = "SGMII_FM2_DTSEC4",
69 [SGMII_FM2_DTSEC5] = "SGMII_FM2_DTSEC5",
70 [XAUI_FM1] = "XAUI_FM1",
71 [XAUI_FM2] = "XAUI_FM2",
72 [AURORA] = "DEBUG",
73 };
74 #endif
75
76 static const struct {
77 int idx;
78 unsigned int lpd; /* RCW lane powerdown bit */
79 int bank;
80 } lanes[SRDS_MAX_LANES] = {
81 { 0, 152, FSL_SRDS_BANK_1 },
82 { 1, 153, FSL_SRDS_BANK_1 },
83 { 2, 154, FSL_SRDS_BANK_1 },
84 { 3, 155, FSL_SRDS_BANK_1 },
85 { 4, 156, FSL_SRDS_BANK_1 },
86 { 5, 157, FSL_SRDS_BANK_1 },
87 { 6, 158, FSL_SRDS_BANK_1 },
88 { 7, 159, FSL_SRDS_BANK_1 },
89 { 8, 160, FSL_SRDS_BANK_1 },
90 { 9, 161, FSL_SRDS_BANK_1 },
91 { 16, 162, FSL_SRDS_BANK_2 },
92 { 17, 163, FSL_SRDS_BANK_2 },
93 { 18, 164, FSL_SRDS_BANK_2 },
94 { 19, 165, FSL_SRDS_BANK_2 },
95 { 20, 170, FSL_SRDS_BANK_3 },
96 { 21, 171, FSL_SRDS_BANK_3 },
97 { 22, 172, FSL_SRDS_BANK_3 },
98 { 23, 173, FSL_SRDS_BANK_3 },
99 };
100
101 int serdes_get_lane_idx(int lane)
102 {
103 return lanes[lane].idx;
104 }
105
106 int serdes_get_bank_by_lane(int lane)
107 {
108 return lanes[lane].bank;
109 }
110
111 int serdes_lane_enabled(int lane)
112 {
113 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
114 serdes_corenet_t *regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
115
116 int bank = lanes[lane].bank;
117 int word = lanes[lane].lpd / 32;
118 int bit = lanes[lane].lpd % 32;
119
120 if (in_be32(&regs->bank[bank].rstctl) & SRDS_RSTCTL_SDPD)
121 return 0;
122
123 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
124 /*
125 * For banks two and three, use the srds_lpd_b[] array instead of the
126 * RCW, because this array contains the real values of SRDS_LPD_B2 and
127 * SRDS_LPD_B3.
128 */
129 if (bank > 0)
130 return !(srds_lpd_b[bank] & (8 >> (lane - (6 + 4 * bank))));
131 #endif
132
133 return !(in_be32(&gur->rcwsr[word]) & (0x80000000 >> bit));
134 }
135
136 int is_serdes_configured(enum srds_prtcl device)
137 {
138 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
139
140 /* Is serdes enabled at all? */
141 if (!(in_be32(&gur->rcwsr[5]) & FSL_CORENET_RCWSR5_SRDS_EN))
142 return 0;
143
144 return (1 << device) & serdes_prtcl_map;
145 }
146
147 static int __serdes_get_first_lane(uint32_t prtcl, enum srds_prtcl device)
148 {
149 int i;
150
151 for (i = 0; i < SRDS_MAX_LANES; i++) {
152 if (serdes_get_prtcl(prtcl, i) == device)
153 return i;
154 }
155
156 return -ENODEV;
157 }
158
159 /*
160 * Returns the SERDES lane (0..SRDS_MAX_LANES-1) that routes to the given
161 * device. This depends on the current SERDES protocol, as defined in the RCW.
162 *
163 * Returns a negative error code if SERDES is disabled or the given device is
164 * not supported in the current SERDES protocol.
165 */
166 int serdes_get_first_lane(enum srds_prtcl device)
167 {
168 u32 prtcl;
169 const ccsr_gur_t *gur;
170
171 gur = (typeof(gur))CONFIG_SYS_MPC85xx_GUTS_ADDR;
172
173 /* Is serdes enabled at all? */
174 if (unlikely((in_be32(&gur->rcwsr[5]) & 0x2000) == 0))
175 return -ENODEV;
176
177 prtcl = (in_be32(&gur->rcwsr[4]) & FSL_CORENET_RCWSR4_SRDS_PRTCL) >> 26;
178
179 return __serdes_get_first_lane(prtcl, device);
180 }
181
182 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES9
183 /*
184 * Returns the SERDES bank (1, 2, or 3) that a given device is on for a given
185 * SERDES protocol.
186 *
187 * Returns a negative error code if the given device is not supported for the
188 * given SERDES protocol.
189 */
190 static int serdes_get_bank_by_device(uint32_t prtcl, enum srds_prtcl device)
191 {
192 int lane;
193
194 lane = __serdes_get_first_lane(prtcl, device);
195 if (unlikely(lane < 0))
196 return lane;
197
198 return serdes_get_bank_by_lane(lane);
199 }
200
201 static uint32_t __serdes_get_lane_count(uint32_t prtcl, enum srds_prtcl device,
202 int first)
203 {
204 int lane;
205
206 for (lane = first; lane < SRDS_MAX_LANES; lane++) {
207 if (serdes_get_prtcl(prtcl, lane) != device)
208 break;
209 }
210
211 return lane - first;
212 }
213
214 static void __serdes_reset_rx(serdes_corenet_t *regs,
215 uint32_t prtcl,
216 enum srds_prtcl device)
217 {
218 int lane, idx, first, last;
219
220 lane = __serdes_get_first_lane(prtcl, device);
221 if (unlikely(lane < 0))
222 return;
223 first = serdes_get_lane_idx(lane);
224 last = first + __serdes_get_lane_count(prtcl, device, lane);
225
226 /*
227 * Set BnGCRy0[RRST] = 0 for each lane in the each bank that is
228 * selected as XAUI to place the lane into reset.
229 */
230 for (idx = first; idx < last; idx++)
231 clrbits_be32(&regs->lane[idx].gcr0, SRDS_GCR0_RRST);
232
233 /* Wait at least 250 ns */
234 udelay(1);
235
236 /*
237 * Set BnGCRy0[RRST] = 1 for each lane in the each bank that is
238 * selected as XAUI to bring the lane out of reset.
239 */
240 for (idx = first; idx < last; idx++)
241 setbits_be32(&regs->lane[idx].gcr0, SRDS_GCR0_RRST);
242 }
243
244 void serdes_reset_rx(enum srds_prtcl device)
245 {
246 u32 prtcl;
247 const ccsr_gur_t *gur;
248 serdes_corenet_t *regs;
249
250 if (unlikely(device == NONE))
251 return;
252
253 gur = (typeof(gur))CONFIG_SYS_MPC85xx_GUTS_ADDR;
254
255 /* Is serdes enabled at all? */
256 if (unlikely((in_be32(&gur->rcwsr[5]) & 0x2000) == 0))
257 return;
258
259 regs = (typeof(regs))CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
260 prtcl = (in_be32(&gur->rcwsr[4]) & FSL_CORENET_RCWSR4_SRDS_PRTCL) >> 26;
261
262 __serdes_reset_rx(regs, prtcl, device);
263 }
264 #endif
265
266 #ifndef CONFIG_SYS_DCSRBAR_PHYS
267 #define CONFIG_SYS_DCSRBAR_PHYS 0x80000000 /* Must be 1GB-aligned for rev1.0 */
268 #define CONFIG_SYS_DCSRBAR 0x80000000
269 #define __DCSR_NOT_DEFINED_BY_CONFIG
270 #endif
271
272 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
273 /*
274 * Enable a SERDES bank that was disabled via the RCW
275 *
276 * We only call this function for SERDES8 and SERDES-A001 in cases we really
277 * want to enable the bank, whether we actually want to use the lanes or not,
278 * so make sure at least one lane is enabled. We're only enabling this one
279 * lane to satisfy errata requirements that the bank be enabled.
280 *
281 * We use a local variable instead of srds_lpd_b[] because we want drivers to
282 * think that the lanes actually are disabled.
283 */
284 static void enable_bank(ccsr_gur_t *gur, int bank)
285 {
286 u32 rcw5;
287 u32 temp_lpd_b = srds_lpd_b[bank];
288
289 /*
290 * If we're asked to disable all lanes, just pretend we're doing
291 * that.
292 */
293 if (temp_lpd_b == 0xF)
294 temp_lpd_b = 0xE;
295
296 /*
297 * Enable the lanes SRDS_LPD_Bn. The RCW bits are read-only in
298 * CCSR, and read/write in DSCR.
299 */
300 rcw5 = in_be32(gur->rcwsr + 5);
301 if (bank == FSL_SRDS_BANK_2) {
302 rcw5 &= ~FSL_CORENET_RCWSRn_SRDS_LPD_B2;
303 rcw5 |= temp_lpd_b << 26;
304 } else if (bank == FSL_SRDS_BANK_3) {
305 rcw5 &= ~FSL_CORENET_RCWSRn_SRDS_LPD_B3;
306 rcw5 |= temp_lpd_b << 18;
307 } else {
308 printf("SERDES: enable_bank: bad bank %d\n", bank + 1);
309 return;
310 }
311
312 /* See similar code in cpu/mpc85xx/cpu_init.c for an explanation
313 * of the DCSR mapping.
314 */
315 {
316 #ifdef __DCSR_NOT_DEFINED_BY_CONFIG
317 struct law_entry law = find_law(CONFIG_SYS_DCSRBAR_PHYS);
318 int law_index;
319 if (law.index == -1)
320 law_index = set_next_law(CONFIG_SYS_DCSRBAR_PHYS,
321 LAW_SIZE_1M, LAW_TRGT_IF_DCSR);
322 else
323 set_law(law.index, CONFIG_SYS_DCSRBAR_PHYS, LAW_SIZE_1M,
324 LAW_TRGT_IF_DCSR);
325 #endif
326 u32 *p = (void *)CONFIG_SYS_DCSRBAR + 0x20114;
327 out_be32(p, rcw5);
328 #ifdef __DCSR_NOT_DEFINED_BY_CONFIG
329 if (law.index == -1)
330 disable_law(law_index);
331 else
332 set_law(law.index, law.addr, law.size, law.trgt_id);
333 #endif
334 }
335 }
336
337 /*
338 * To avoid problems with clock jitter, rev 2 p4080 uses the pll from
339 * bank 3 to clock banks 2 and 3, as well as a limited selection of
340 * protocol configurations. This requires that banks 2 and 3's lanes be
341 * disabled in the RCW, and enabled with some fixup here to re-enable
342 * them, and to configure bank 2's clock parameters in bank 3's pll in
343 * cases where they differ.
344 */
345 static void p4080_erratum_serdes8(serdes_corenet_t *regs, ccsr_gur_t *gur,
346 u32 devdisr, u32 devdisr2, int cfg)
347 {
348 int srds_ratio_b2;
349 int rfck_sel;
350
351 /*
352 * The disabled lanes of bank 2 will cause the associated
353 * logic blocks to be disabled in DEVDISR. We reverse that here.
354 *
355 * Note that normally it is not permitted to clear DEVDISR bits
356 * once the device has been disabled, but the hardware people
357 * say that this special case is OK.
358 */
359 clrbits_be32(&gur->devdisr, devdisr);
360 clrbits_be32(&gur->devdisr2, devdisr2);
361
362 /*
363 * Some protocols require special handling. There are a few
364 * additional protocol configurations that can be used, which are
365 * not listed here. See app note 4065 for supported protocol
366 * configurations.
367 */
368 switch (cfg) {
369 case 0x19:
370 /*
371 * Bank 2 has PCIe which wants BWSEL -- tell bank 3's PLL.
372 * SGMII on bank 3 should still be usable.
373 */
374 setbits_be32(&regs->bank[FSL_SRDS_BANK_3].pllcr1,
375 SRDS_PLLCR1_PLL_BWSEL);
376 break;
377
378 case 0x0f:
379 case 0x10:
380 /*
381 * Banks 2 (XAUI) and 3 (SGMII) have different clocking
382 * requirements in these configurations. Bank 3 cannot
383 * be used and should have its lanes (but not the bank
384 * itself) disabled in the RCW. We set up bank 3's pll
385 * for bank 2's needs here.
386 */
387 srds_ratio_b2 = (in_be32(&gur->rcwsr[4]) >> 13) & 7;
388
389 /* Determine refclock from XAUI ratio */
390 switch (srds_ratio_b2) {
391 case 1: /* 20:1 */
392 rfck_sel = SRDS_PLLCR0_RFCK_SEL_156_25;
393 break;
394 case 2: /* 25:1 */
395 rfck_sel = SRDS_PLLCR0_RFCK_SEL_125;
396 break;
397 default:
398 printf("SERDES: bad SRDS_RATIO_B2 %d\n",
399 srds_ratio_b2);
400 return;
401 }
402
403 clrsetbits_be32(&regs->bank[FSL_SRDS_BANK_3].pllcr0,
404 SRDS_PLLCR0_RFCK_SEL_MASK, rfck_sel);
405
406 clrsetbits_be32(&regs->bank[FSL_SRDS_BANK_3].pllcr0,
407 SRDS_PLLCR0_FRATE_SEL_MASK,
408 SRDS_PLLCR0_FRATE_SEL_6_25);
409 break;
410 }
411
412 enable_bank(gur, FSL_SRDS_BANK_3);
413 }
414 #endif
415
416 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES_A005
417 /*
418 * If PCIe is not selected as a protocol for any lanes driven by a given PLL,
419 * that PLL should have SRDSBnPLLCR1[PLLBW_SEL] = 0.
420 */
421 static void p4080_erratum_serdes_a005(serdes_corenet_t *regs, unsigned int cfg)
422 {
423 enum srds_prtcl device;
424
425 switch (cfg) {
426 case 0x13:
427 case 0x16:
428 /*
429 * If SRDS_PRTCL = 0x13 or 0x16, set SRDSB1PLLCR1[PLLBW_SEL]
430 * to 0.
431 */
432 clrbits_be32(&regs->bank[FSL_SRDS_BANK_1].pllcr1,
433 SRDS_PLLCR1_PLL_BWSEL);
434 break;
435 case 0x19:
436 /*
437 * If SRDS_PRTCL = 0x19, set SRDSB1PLLCR1[PLLBW_SEL] to 0 and
438 * SRDSB3PLLCR1[PLLBW_SEL] to 1.
439 */
440 clrbits_be32(&regs->bank[FSL_SRDS_BANK_1].pllcr1,
441 SRDS_PLLCR1_PLL_BWSEL);
442 setbits_be32(&regs->bank[FSL_SRDS_BANK_3].pllcr1,
443 SRDS_PLLCR1_PLL_BWSEL);
444 break;
445 }
446
447 /*
448 * Set SRDSBnPLLCR1[PLLBW_SEL] to 0 for each bank that selects XAUI
449 * before XAUI is initialized.
450 */
451 for (device = XAUI_FM1; device <= XAUI_FM2; device++) {
452 if (is_serdes_configured(device)) {
453 int bank = serdes_get_bank_by_device(cfg, device);
454
455 clrbits_be32(&regs->bank[bank].pllcr1,
456 SRDS_PLLCR1_PLL_BWSEL);
457 }
458 }
459 }
460 #endif
461
462 /*
463 * Wait for the RSTDONE bit to get set, or a one-second timeout.
464 */
465 static void wait_for_rstdone(unsigned int bank)
466 {
467 serdes_corenet_t *srds_regs =
468 (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
469 unsigned long long end_tick;
470 u32 rstctl;
471
472 /* wait for reset complete or 1-second timeout */
473 end_tick = usec2ticks(1000000) + get_ticks();
474 do {
475 rstctl = in_be32(&srds_regs->bank[bank].rstctl);
476 if (rstctl & SRDS_RSTCTL_RSTDONE)
477 break;
478 } while (end_tick > get_ticks());
479
480 if (!(rstctl & SRDS_RSTCTL_RSTDONE))
481 printf("SERDES: timeout resetting bank %u\n", bank + 1);
482 }
483
484
485 void __soc_serdes_init(void)
486 {
487 /* Allow for SoC-specific initialization in <SOC>_serdes.c */
488 };
489 void soc_serdes_init(void) __attribute__((weak, alias("__soc_serdes_init")));
490
491 void fsl_serdes_init(void)
492 {
493 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
494 int cfg;
495 serdes_corenet_t *srds_regs;
496 int lane, bank, idx;
497 int have_bank[SRDS_MAX_BANK] = {};
498 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
499 u32 serdes8_devdisr = 0;
500 u32 serdes8_devdisr2 = 0;
501 char srds_lpd_opt[16];
502 const char *srds_lpd_arg;
503 size_t arglen;
504 #endif
505 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES_A001
506 int need_serdes_a001; /* TRUE == need work-around for SERDES A001 */
507 #endif
508 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
509 char buffer[HWCONFIG_BUFFER_SIZE];
510 char *buf = NULL;
511
512 /*
513 * Extract hwconfig from environment since we have not properly setup
514 * the environment but need it for ddr config params
515 */
516 if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
517 buf = buffer;
518 #endif
519
520 /* Is serdes enabled at all? */
521 if (!(in_be32(&gur->rcwsr[5]) & FSL_CORENET_RCWSR5_SRDS_EN))
522 return;
523
524 srds_regs = (void *)(CONFIG_SYS_FSL_CORENET_SERDES_ADDR);
525 cfg = (in_be32(&gur->rcwsr[4]) & FSL_CORENET_RCWSR4_SRDS_PRTCL) >> 26;
526 debug("Using SERDES configuration 0x%x, lane settings:\n", cfg);
527
528 if (!is_serdes_prtcl_valid(cfg)) {
529 printf("SERDES[PRTCL] = 0x%x is not valid\n", cfg);
530 return;
531 }
532
533 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
534 /*
535 * Display a warning if banks two and three are not disabled in the RCW,
536 * since our work-around for SERDES8 depends on these banks being
537 * disabled at power-on.
538 */
539 #define B2_B3 (FSL_CORENET_RCWSRn_SRDS_LPD_B2 | FSL_CORENET_RCWSRn_SRDS_LPD_B3)
540 if ((in_be32(&gur->rcwsr[5]) & B2_B3) != B2_B3) {
541 printf("Warning: SERDES8 requires banks two and "
542 "three to be disabled in the RCW\n");
543 }
544
545 /*
546 * Store the values of the fsl_srds_lpd_b2 and fsl_srds_lpd_b3
547 * hwconfig options into the srds_lpd_b[] array. See README.p4080ds
548 * for a description of these options.
549 */
550 for (bank = 1; bank < ARRAY_SIZE(srds_lpd_b); bank++) {
551 sprintf(srds_lpd_opt, "fsl_srds_lpd_b%u", bank + 1);
552 srds_lpd_arg =
553 hwconfig_subarg_f("serdes", srds_lpd_opt, &arglen, buf);
554 if (srds_lpd_arg)
555 srds_lpd_b[bank] =
556 simple_strtoul(srds_lpd_arg, NULL, 0) & 0xf;
557 }
558
559 if ((cfg == 0xf) || (cfg == 0x10)) {
560 /*
561 * For SERDES protocols 0xF and 0x10, force bank 3 to be
562 * disabled, because it is not supported.
563 */
564 srds_lpd_b[FSL_SRDS_BANK_3] = 0xF;
565 }
566 #endif
567
568 /* Look for banks with all lanes disabled, and power down the bank. */
569 for (lane = 0; lane < SRDS_MAX_LANES; lane++) {
570 enum srds_prtcl lane_prtcl = serdes_get_prtcl(cfg, lane);
571 if (serdes_lane_enabled(lane)) {
572 have_bank[serdes_get_bank_by_lane(lane)] = 1;
573 serdes_prtcl_map |= (1 << lane_prtcl);
574 }
575 }
576
577 soc_serdes_init();
578
579 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
580 /*
581 * Bank two uses the clock from bank three, so if bank two is enabled,
582 * then bank three must also be enabled.
583 */
584 if (have_bank[FSL_SRDS_BANK_2])
585 have_bank[FSL_SRDS_BANK_3] = 1;
586 #endif
587
588 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES_A001
589 /*
590 * The work-aroud for erratum SERDES-A001 is needed only if bank two
591 * is disabled and bank three is enabled. The converse is also true,
592 * but SERDES8 ensures that bank 3 is always enabled if bank 2 is
593 * enabled, so there's no point in complicating the code to handle
594 * that situation.
595 */
596 need_serdes_a001 =
597 !have_bank[FSL_SRDS_BANK_2] && have_bank[FSL_SRDS_BANK_3];
598 #endif
599
600 /* Power down the banks we're not interested in */
601 for (bank = 0; bank < SRDS_MAX_BANK; bank++) {
602 if (!have_bank[bank]) {
603 printf("SERDES: bank %d disabled\n", bank + 1);
604 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES_A001
605 /*
606 * Erratum SERDES-A001 says bank two needs to be powered
607 * down after bank three is powered up, so don't power
608 * down bank two here.
609 */
610 if (!need_serdes_a001 || (bank != FSL_SRDS_BANK_2))
611 setbits_be32(&srds_regs->bank[bank].rstctl,
612 SRDS_RSTCTL_SDPD);
613 #else
614 setbits_be32(&srds_regs->bank[bank].rstctl,
615 SRDS_RSTCTL_SDPD);
616 #endif
617 }
618 }
619
620 #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES8) || defined (CONFIG_SYS_P4080_ERRATUM_SERDES9)
621 for (lane = 0; lane < SRDS_MAX_LANES; lane++) {
622 enum srds_prtcl lane_prtcl;
623
624 idx = serdes_get_lane_idx(lane);
625 lane_prtcl = serdes_get_prtcl(cfg, lane);
626
627 #ifdef DEBUG
628 switch (lane) {
629 case 0:
630 puts("Bank1: ");
631 break;
632 case 10:
633 puts("\nBank2: ");
634 break;
635 case 14:
636 puts("\nBank3: ");
637 break;
638 default:
639 break;
640 }
641
642 printf("%s ", serdes_prtcl_str[lane_prtcl]);
643 #endif
644
645 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES9
646 /*
647 * Set BnTTLCRy0[FLT_SEL] = 000011 and set BnTTLCRy0[17] = 1 for
648 * each of the SerDes lanes selected as SGMII, XAUI, SRIO, or
649 * AURORA before the device is initialized.
650 */
651 switch (lane_prtcl) {
652 case SGMII_FM1_DTSEC1:
653 case SGMII_FM1_DTSEC2:
654 case SGMII_FM1_DTSEC3:
655 case SGMII_FM1_DTSEC4:
656 case SGMII_FM2_DTSEC1:
657 case SGMII_FM2_DTSEC2:
658 case SGMII_FM2_DTSEC3:
659 case SGMII_FM2_DTSEC4:
660 case SGMII_FM2_DTSEC5:
661 case XAUI_FM1:
662 case XAUI_FM2:
663 case SRIO1:
664 case SRIO2:
665 case AURORA:
666 clrsetbits_be32(&srds_regs->lane[idx].ttlcr0,
667 SRDS_TTLCR0_FLT_SEL_MASK,
668 SRDS_TTLCR0_FLT_SEL_750PPM |
669 SRDS_TTLCR0_PM_DIS);
670 default:
671 break;
672 }
673 #endif
674
675 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
676 switch (lane_prtcl) {
677 case PCIE1:
678 case PCIE2:
679 case PCIE3:
680 serdes8_devdisr |= FSL_CORENET_DEVDISR_PCIE1 >>
681 (lane_prtcl - PCIE1);
682 break;
683 case SRIO1:
684 case SRIO2:
685 serdes8_devdisr |= FSL_CORENET_DEVDISR_SRIO1 >>
686 (lane_prtcl - SRIO1);
687 break;
688 case SGMII_FM1_DTSEC1:
689 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM1 |
690 FSL_CORENET_DEVDISR2_DTSEC1_1;
691 break;
692 case SGMII_FM1_DTSEC2:
693 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM1 |
694 FSL_CORENET_DEVDISR2_DTSEC1_2;
695 break;
696 case SGMII_FM1_DTSEC3:
697 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM1 |
698 FSL_CORENET_DEVDISR2_DTSEC1_3;
699 break;
700 case SGMII_FM1_DTSEC4:
701 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM1 |
702 FSL_CORENET_DEVDISR2_DTSEC1_4;
703 break;
704 case SGMII_FM2_DTSEC1:
705 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM2 |
706 FSL_CORENET_DEVDISR2_DTSEC2_1;
707 break;
708 case SGMII_FM2_DTSEC2:
709 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM2 |
710 FSL_CORENET_DEVDISR2_DTSEC2_2;
711 break;
712 case SGMII_FM2_DTSEC3:
713 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM2 |
714 FSL_CORENET_DEVDISR2_DTSEC2_3;
715 break;
716 case SGMII_FM2_DTSEC4:
717 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM2 |
718 FSL_CORENET_DEVDISR2_DTSEC2_4;
719 break;
720 case SGMII_FM2_DTSEC5:
721 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM2 |
722 FSL_CORENET_DEVDISR2_DTSEC2_5;
723 break;
724 case XAUI_FM1:
725 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM1 |
726 FSL_CORENET_DEVDISR2_10GEC1;
727 break;
728 case XAUI_FM2:
729 serdes8_devdisr2 |= FSL_CORENET_DEVDISR2_FM2 |
730 FSL_CORENET_DEVDISR2_10GEC2;
731 break;
732 case AURORA:
733 break;
734 default:
735 break;
736 }
737
738 #endif
739 }
740 #endif
741
742 #ifdef DEBUG
743 puts("\n");
744 #endif
745
746 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES_A005
747 p4080_erratum_serdes_a005(srds_regs, cfg);
748 #endif
749
750 for (idx = 0; idx < SRDS_MAX_BANK; idx++) {
751 bank = idx;
752
753 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
754 /*
755 * Change bank init order to 0, 2, 1, so that the third bank's
756 * PLL is established before we start the second bank. The
757 * second bank uses the third bank's PLL.
758 */
759
760 if (idx == 1)
761 bank = FSL_SRDS_BANK_3;
762 else if (idx == 2)
763 bank = FSL_SRDS_BANK_2;
764 #endif
765
766 /* Skip disabled banks */
767 if (!have_bank[bank])
768 continue;
769
770 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
771 if (idx == 1) {
772 /*
773 * Re-enable devices on banks two and three that were
774 * disabled by the RCW, and then enable bank three. The
775 * devices need to be enabled before either bank is
776 * powered up.
777 */
778 p4080_erratum_serdes8(srds_regs, gur, serdes8_devdisr,
779 serdes8_devdisr2, cfg);
780 } else if (idx == 2) {
781 /* Enable bank two now that bank three is enabled. */
782 enable_bank(gur, FSL_SRDS_BANK_2);
783 }
784 #endif
785
786 wait_for_rstdone(bank);
787 }
788
789 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES_A001
790 if (need_serdes_a001) {
791 /* Bank 3 has been enabled, so now we can disable bank 2 */
792 setbits_be32(&srds_regs->bank[FSL_SRDS_BANK_2].rstctl,
793 SRDS_RSTCTL_SDPD);
794 }
795 #endif
796 }