blob: f278549cbf65d0d1f84af30f1326048c80f2f7e2 [file] [log] [blame]
Kumar Galabd29be82010-06-01 10:29:11 -05001/*
2 * Copyright 2010-2011 Freescale Semiconductor, Inc.
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Kumar Galabd29be82010-06-01 10:29:11 -05005 */
6
7#include <common.h>
8#include <asm/fsl_serdes.h>
9#include <asm/processor.h>
10#include <asm/io.h>
11#include "fsl_corenet_serdes.h"
12
13static u8 serdes_cfg_tbl[][SRDS_MAX_LANES] = {
14 [0x2] = {NONE, NONE, PCIE1, PCIE1, SRIO1, SRIO1, SRIO1, SRIO1,
15 NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
16 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, },
17 [0x5] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, PCIE2, PCIE2,
18 NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
19 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, },
20 [0x8] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
21 PCIE2, PCIE2, PCIE2, NONE, NONE, NONE, NONE, SATA1,
22 SATA2, NONE, NONE, NONE, NONE, },
Mingkai Hu4a75bb32011-04-15 15:18:03 +080023 [0x9] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
Kumar Galae9f98392011-07-21 00:20:20 -050024 PCIE2, PCIE2, PCIE2, NONE, NONE, XAUI_FM1, XAUI_FM1,
25 XAUI_FM1, XAUI_FM1, NONE, NONE, NONE, NONE, },
Kumar Galabd29be82010-06-01 10:29:11 -050026 [0xa] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
27 PCIE2, PCIE2, PCIE2, NONE, NONE, PCIE3, PCIE3, PCIE3,
28 PCIE3, NONE, NONE, NONE, NONE, },
29 [0xf] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, SRIO2,
30 SRIO2, SRIO1, SRIO1, NONE, NONE, PCIE3, SGMII_FM1_DTSEC5,
31 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, },
32 [0x14] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
33 PCIE2, SRIO1, SRIO1, NONE, NONE, AURORA,
34 SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE,
35 NONE, NONE, NONE, },
36 [0x16] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, SGMII_FM1_DTSEC3,
37 SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, SATA1, SATA2, NONE,
38 NONE, NONE, NONE, },
Mingkai Hu4a75bb32011-04-15 15:18:03 +080039 [0x17] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, SGMII_FM1_DTSEC3,
Kumar Galae9f98392011-07-21 00:20:20 -050040 SGMII_FM1_DTSEC4, NONE, NONE, XAUI_FM1, XAUI_FM1, XAUI_FM1,
41 XAUI_FM1, NONE, NONE, NONE, NONE, },
Mingkai Hu4a75bb32011-04-15 15:18:03 +080042 [0x19] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
43 PCIE2, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE,
44 NONE, NONE, SATA1, SATA2, NONE, NONE, NONE, NONE, },
Kumar Galabd29be82010-06-01 10:29:11 -050045 [0x1a] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, SRIO2,
46 SRIO2, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE,
47 NONE, NONE, SATA1, SATA2, NONE, NONE, NONE, NONE, },
48 [0x1c] = {NONE, NONE, PCIE1, SGMII_FM1_DTSEC2, PCIE2, PCIE2,
49 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, AURORA,
50 SGMII_FM1_DTSEC5, NONE, NONE, NONE, NONE, NONE, NONE, },
51};
52
53enum srds_prtcl serdes_get_prtcl(int cfg, int lane)
54{
Kumar Galae9f98392011-07-21 00:20:20 -050055 enum srds_prtcl prtcl;
56 u32 svr = get_svr();
57 u32 ver = SVR_SOC_VER(svr);
58
Kumar Galabd29be82010-06-01 10:29:11 -050059 if (!serdes_lane_enabled(lane))
60 return NONE;
61
Kumar Galae9f98392011-07-21 00:20:20 -050062 prtcl = serdes_cfg_tbl[cfg][lane];
63
64 /* P2040[e] does not support XAUI */
York Sun8cb65482012-07-06 17:10:33 -050065 if (ver == SVR_P2040 && prtcl == XAUI_FM1)
Kumar Galae9f98392011-07-21 00:20:20 -050066 prtcl = NONE;
67
68 return prtcl;
Kumar Galabd29be82010-06-01 10:29:11 -050069}
Mingkai Hu4a75bb32011-04-15 15:18:03 +080070
71int is_serdes_prtcl_valid(u32 prtcl)
72{
73 int i;
Kumar Galae9f98392011-07-21 00:20:20 -050074 u32 svr = get_svr();
75 u32 ver = SVR_SOC_VER(svr);
Mingkai Hu4a75bb32011-04-15 15:18:03 +080076
Axel Linab95b092013-05-26 15:00:30 +080077 if (prtcl >= ARRAY_SIZE(serdes_cfg_tbl))
Mingkai Hu4a75bb32011-04-15 15:18:03 +080078 return 0;
79
Kumar Galae9f98392011-07-21 00:20:20 -050080 /* P2040[e] does not support XAUI */
York Sun8cb65482012-07-06 17:10:33 -050081 if (ver == SVR_P2040 && prtcl == XAUI_FM1)
Kumar Galae9f98392011-07-21 00:20:20 -050082 return 0;
83
Mingkai Hu4a75bb32011-04-15 15:18:03 +080084 for (i = 0; i < SRDS_MAX_LANES; i++) {
85 if (serdes_cfg_tbl[prtcl][i] != NONE)
86 return 1;
87 }
88
89 return 0;
90}