1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
21eda59ffSKumar Gala /*
31eda59ffSKumar Gala * Copyright 2009-2011 Freescale Semiconductor, Inc.
41eda59ffSKumar Gala */
51eda59ffSKumar Gala
61eda59ffSKumar Gala #include <common.h>
71eda59ffSKumar Gala #include <asm/fsl_serdes.h>
81eda59ffSKumar Gala #include <asm/processor.h>
91eda59ffSKumar Gala #include <asm/io.h>
101eda59ffSKumar Gala #include "fsl_corenet_serdes.h"
111eda59ffSKumar Gala
121eda59ffSKumar Gala static u8 serdes_cfg_tbl[][SRDS_MAX_LANES] = {
131eda59ffSKumar Gala [0x2] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE2, PCIE2, PCIE2, PCIE2,
141eda59ffSKumar Gala PCIE4, AURORA, PCIE3, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC3,
151eda59ffSKumar Gala SGMII_FM1_DTSEC4, NONE, NONE, SATA1, SATA2, },
161eda59ffSKumar Gala [0x4] = {SRIO2, SRIO2, SRIO2, SRIO2, SRIO1, SRIO1, SRIO1, SRIO1,
171eda59ffSKumar Gala PCIE2, AURORA, PCIE3, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC3,
181eda59ffSKumar Gala SGMII_FM1_DTSEC4, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1, },
191eda59ffSKumar Gala [0xb] = {PCIE1, PCIE1, PCIE1, PCIE1, SRIO2, SRIO2, SRIO1, SRIO1,
201eda59ffSKumar Gala PCIE2, AURORA, PCIE3, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC3,
211eda59ffSKumar Gala SGMII_FM1_DTSEC4, NONE, NONE, SATA1, SATA2, },
221eda59ffSKumar Gala [0x10] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE1, PCIE1, PCIE1, PCIE1,
231eda59ffSKumar Gala AURORA, AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1,
241eda59ffSKumar Gala NONE, NONE, SATA1, SATA2, },
251eda59ffSKumar Gala [0x11] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE2, PCIE2, PCIE2, PCIE2,
261eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
271eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, SATA1, SATA2, },
281eda59ffSKumar Gala [0x13] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE2, PCIE2, PCIE2, PCIE2,
291eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
301eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, XAUI_FM1, XAUI_FM1,
311eda59ffSKumar Gala XAUI_FM1, XAUI_FM1, },
321eda59ffSKumar Gala [0x14] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE2, PCIE2, PCIE2, PCIE2,
331eda59ffSKumar Gala AURORA, AURORA, PCIE3, PCIE3, PCIE3, PCIE3,
341eda59ffSKumar Gala SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC3,
351eda59ffSKumar Gala SGMII_FM1_DTSEC4, },
361eda59ffSKumar Gala [0x15] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE2, PCIE2, PCIE2, PCIE2,
371eda59ffSKumar Gala AURORA, AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1,
381eda59ffSKumar Gala NONE, NONE, SATA1, SATA2, },
391eda59ffSKumar Gala [0x16] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE2, PCIE2, PCIE2, PCIE2,
401eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
411eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, SRIO1, SRIO1, SRIO1,
421eda59ffSKumar Gala SRIO1, },
431eda59ffSKumar Gala [0x17] = {SRIO2, SRIO2, SRIO2, SRIO2, SRIO1, SRIO1, SRIO1, SRIO1,
441eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
451eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, SATA1, SATA2, },
461eda59ffSKumar Gala [0x18] = {SRIO2, SRIO2, SRIO2, SRIO2, SRIO1, SRIO1, SRIO1, SRIO1,
471eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
481eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5, NONE,
491eda59ffSKumar Gala NONE, NONE, },
501eda59ffSKumar Gala [0x1b] = {SRIO2, SRIO2, SRIO2, SRIO2, SRIO1, SRIO1, SRIO1, SRIO1,
511eda59ffSKumar Gala AURORA, AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1,
521eda59ffSKumar Gala NONE, NONE, SATA1, SATA2, },
531eda59ffSKumar Gala [0x1d] = {SRIO2, SRIO2, SRIO2, SRIO2, SRIO1, SRIO1, SRIO1, SRIO1,
541eda59ffSKumar Gala AURORA, AURORA, PCIE3, PCIE3, PCIE3, PCIE3, NONE, NONE,
551eda59ffSKumar Gala SATA1, SATA2, },
561eda59ffSKumar Gala [0x20] = {PCIE1, PCIE1, PCIE1, PCIE1, SRIO1, SRIO1, SRIO1, SRIO1,
571eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
581eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, XAUI_FM1, XAUI_FM1,
591eda59ffSKumar Gala XAUI_FM1, XAUI_FM1, },
601eda59ffSKumar Gala [0x21] = {PCIE1, PCIE1, PCIE1, PCIE1, SRIO1, SRIO1, SRIO1, SRIO1,
611eda59ffSKumar Gala AURORA, AURORA, PCIE3, PCIE3, PCIE3, PCIE3,
621eda59ffSKumar Gala SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC3,
631eda59ffSKumar Gala SGMII_FM1_DTSEC4, },
641eda59ffSKumar Gala [0x22] = {PCIE1, PCIE1, PCIE1, PCIE1, SRIO1, SRIO1, SRIO1, SRIO1,
651eda59ffSKumar Gala AURORA, AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1,
661eda59ffSKumar Gala NONE, NONE, SATA1, SATA2, },
671eda59ffSKumar Gala [0x23] = {PCIE1, PCIE1, PCIE1, PCIE1, SRIO2, SRIO2, SRIO1, SRIO1,
681eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
691eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, SATA1, SATA2, },
701eda59ffSKumar Gala [0x24] = {PCIE1, PCIE1, PCIE1, PCIE1, SRIO2, SRIO2, SRIO1, SRIO1,
711eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
721eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5, NONE,
731eda59ffSKumar Gala NONE, NONE, },
741eda59ffSKumar Gala [0x28] = {PCIE1, PCIE1, PCIE3, PCIE3, PCIE2, PCIE2, PCIE2, PCIE2,
751eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
761eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, SATA1, SATA2, },
771eda59ffSKumar Gala [0x29] = {PCIE1, PCIE1, PCIE3, PCIE3, PCIE2, PCIE2, PCIE2, PCIE2,
781eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
791eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5, NONE,
801eda59ffSKumar Gala NONE, NONE, },
811eda59ffSKumar Gala [0x2a] = {PCIE1, PCIE1, PCIE3, PCIE3, PCIE2, PCIE2, PCIE2, PCIE2,
821eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
831eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, XAUI_FM1, XAUI_FM1,
841eda59ffSKumar Gala XAUI_FM1, XAUI_FM1, },
851eda59ffSKumar Gala [0x2b] = {PCIE1, PCIE1, PCIE3, PCIE3, PCIE2, PCIE2, PCIE2, PCIE2,
861eda59ffSKumar Gala AURORA, AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1,
871eda59ffSKumar Gala NONE, NONE, SATA1, SATA2, },
881eda59ffSKumar Gala [0x2f] = {PCIE1, PCIE1, PCIE3, PCIE3, SRIO2, SRIO2, SRIO1, SRIO1,
891eda59ffSKumar Gala AURORA, AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1,
901eda59ffSKumar Gala NONE, NONE, SATA1, SATA2, },
911eda59ffSKumar Gala [0x31] = {PCIE1, PCIE1, PCIE3, PCIE3, SRIO1, SRIO1, SRIO1, SRIO1,
921eda59ffSKumar Gala AURORA, AURORA, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
931eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5, NONE,
941eda59ffSKumar Gala NONE, NONE, },
951eda59ffSKumar Gala [0x33] = {PCIE1, PCIE1, PCIE3, PCIE3, SRIO1, SRIO1, SRIO1, SRIO1,
961eda59ffSKumar Gala AURORA, AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1,
971eda59ffSKumar Gala NONE, NONE, SATA1, SATA2, },
981eda59ffSKumar Gala [0x34] = {PCIE1, PCIE1, PCIE1, PCIE1, SGMII_FM1_DTSEC1,
991eda59ffSKumar Gala SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, AURORA,
1001eda59ffSKumar Gala AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1, NONE,
1011eda59ffSKumar Gala NONE, SATA1, SATA2, },
1021eda59ffSKumar Gala [0x35] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE2, PCIE2,
1031eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, AURORA, AURORA, XAUI_FM1,
1041eda59ffSKumar Gala XAUI_FM1, XAUI_FM1, XAUI_FM1, NONE, NONE, SATA1, SATA2, },
1051eda59ffSKumar Gala [0x36] = {PCIE1, PCIE1, PCIE3, PCIE3, SGMII_FM1_DTSEC1,
1061eda59ffSKumar Gala SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, AURORA,
1071eda59ffSKumar Gala AURORA, XAUI_FM1, XAUI_FM1, XAUI_FM1, XAUI_FM1, NONE,
1081eda59ffSKumar Gala NONE, SATA1, SATA2, },
1091eda59ffSKumar Gala [0x37] = {PCIE1, PCIE1, PCIE3, PCIE3, PCIE2, PCIE2,
1101eda59ffSKumar Gala SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, AURORA, AURORA, XAUI_FM1,
1111eda59ffSKumar Gala XAUI_FM1, XAUI_FM1, XAUI_FM1, NONE, NONE, SATA1, SATA2, },
1121eda59ffSKumar Gala };
1131eda59ffSKumar Gala
serdes_get_prtcl(int cfg,int lane)1141eda59ffSKumar Gala enum srds_prtcl serdes_get_prtcl(int cfg, int lane)
1151eda59ffSKumar Gala {
1161eda59ffSKumar Gala if (!serdes_lane_enabled(lane))
1171eda59ffSKumar Gala return NONE;
1181eda59ffSKumar Gala
1191eda59ffSKumar Gala return serdes_cfg_tbl[cfg][lane];
1201eda59ffSKumar Gala }
1211eda59ffSKumar Gala
is_serdes_prtcl_valid(u32 prtcl)1221eda59ffSKumar Gala int is_serdes_prtcl_valid(u32 prtcl) {
1231eda59ffSKumar Gala int i;
1241eda59ffSKumar Gala
125e51e47d3SAxel Lin if (prtcl >= ARRAY_SIZE(serdes_cfg_tbl))
1261eda59ffSKumar Gala return 0;
1271eda59ffSKumar Gala
1281eda59ffSKumar Gala for (i = 0; i < SRDS_MAX_LANES; i++) {
1291eda59ffSKumar Gala if (serdes_cfg_tbl[prtcl][i] != NONE)
1301eda59ffSKumar Gala return 1;
1311eda59ffSKumar Gala }
1321eda59ffSKumar Gala
1331eda59ffSKumar Gala return 0;
1341eda59ffSKumar Gala }
135