blob: 3943859a518831212e4441f4d0dce80fa30b5167 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kumar Galabd29be82010-06-01 10:29:11 -05002/*
3 * Copyright 2010-2011 Freescale Semiconductor, Inc.
Kumar Galabd29be82010-06-01 10:29:11 -05004 */
5
Kumar Galabd29be82010-06-01 10:29:11 -05006#include <asm/fsl_serdes.h>
7#include <asm/processor.h>
8#include <asm/io.h>
9#include "fsl_corenet_serdes.h"
10
11static u8 serdes_cfg_tbl[][SRDS_MAX_LANES] = {
12 [0x2] = {NONE, NONE, PCIE1, PCIE1, SRIO1, SRIO1, SRIO1, SRIO1,
13 NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
14 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, },
15 [0x5] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, PCIE2, PCIE2,
16 NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
17 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, },
18 [0x8] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
19 PCIE2, PCIE2, PCIE2, NONE, NONE, NONE, NONE, SATA1,
20 SATA2, NONE, NONE, NONE, NONE, },
Mingkai Hu4a75bb32011-04-15 15:18:03 +080021 [0x9] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
Kumar Galae9f98392011-07-21 00:20:20 -050022 PCIE2, PCIE2, PCIE2, NONE, NONE, XAUI_FM1, XAUI_FM1,
23 XAUI_FM1, XAUI_FM1, NONE, NONE, NONE, NONE, },
Kumar Galabd29be82010-06-01 10:29:11 -050024 [0xa] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
25 PCIE2, PCIE2, PCIE2, NONE, NONE, PCIE3, PCIE3, PCIE3,
26 PCIE3, NONE, NONE, NONE, NONE, },
27 [0xf] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, SRIO2,
28 SRIO2, SRIO1, SRIO1, NONE, NONE, PCIE3, SGMII_FM1_DTSEC5,
29 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, },
30 [0x14] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
31 PCIE2, SRIO1, SRIO1, NONE, NONE, AURORA,
32 SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE,
33 NONE, NONE, NONE, },
34 [0x16] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, SGMII_FM1_DTSEC3,
35 SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, SATA1, SATA2, NONE,
36 NONE, NONE, NONE, },
Mingkai Hu4a75bb32011-04-15 15:18:03 +080037 [0x17] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, SGMII_FM1_DTSEC3,
Kumar Galae9f98392011-07-21 00:20:20 -050038 SGMII_FM1_DTSEC4, NONE, NONE, XAUI_FM1, XAUI_FM1, XAUI_FM1,
39 XAUI_FM1, NONE, NONE, NONE, NONE, },
Mingkai Hu4a75bb32011-04-15 15:18:03 +080040 [0x19] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2,
41 PCIE2, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE,
42 NONE, NONE, SATA1, SATA2, NONE, NONE, NONE, NONE, },
Kumar Galabd29be82010-06-01 10:29:11 -050043 [0x1a] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, SRIO2,
44 SRIO2, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE,
45 NONE, NONE, SATA1, SATA2, NONE, NONE, NONE, NONE, },
46 [0x1c] = {NONE, NONE, PCIE1, SGMII_FM1_DTSEC2, PCIE2, PCIE2,
47 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, AURORA,
48 SGMII_FM1_DTSEC5, NONE, NONE, NONE, NONE, NONE, NONE, },
49};
50
51enum srds_prtcl serdes_get_prtcl(int cfg, int lane)
52{
Kumar Galae9f98392011-07-21 00:20:20 -050053 enum srds_prtcl prtcl;
54 u32 svr = get_svr();
55 u32 ver = SVR_SOC_VER(svr);
56
Kumar Galabd29be82010-06-01 10:29:11 -050057 if (!serdes_lane_enabled(lane))
58 return NONE;
59
Kumar Galae9f98392011-07-21 00:20:20 -050060 prtcl = serdes_cfg_tbl[cfg][lane];
61
62 /* P2040[e] does not support XAUI */
York Sun8cb65482012-07-06 17:10:33 -050063 if (ver == SVR_P2040 && prtcl == XAUI_FM1)
Kumar Galae9f98392011-07-21 00:20:20 -050064 prtcl = NONE;
65
66 return prtcl;
Kumar Galabd29be82010-06-01 10:29:11 -050067}
Mingkai Hu4a75bb32011-04-15 15:18:03 +080068
69int is_serdes_prtcl_valid(u32 prtcl)
70{
71 int i;
Kumar Galae9f98392011-07-21 00:20:20 -050072 u32 svr = get_svr();
73 u32 ver = SVR_SOC_VER(svr);
Mingkai Hu4a75bb32011-04-15 15:18:03 +080074
Axel Linab95b092013-05-26 15:00:30 +080075 if (prtcl >= ARRAY_SIZE(serdes_cfg_tbl))
Mingkai Hu4a75bb32011-04-15 15:18:03 +080076 return 0;
77
Kumar Galae9f98392011-07-21 00:20:20 -050078 /* P2040[e] does not support XAUI */
York Sun8cb65482012-07-06 17:10:33 -050079 if (ver == SVR_P2040 && prtcl == XAUI_FM1)
Kumar Galae9f98392011-07-21 00:20:20 -050080 return 0;
81
Mingkai Hu4a75bb32011-04-15 15:18:03 +080082 for (i = 0; i < SRDS_MAX_LANES; i++) {
83 if (serdes_cfg_tbl[prtcl][i] != NONE)
84 return 1;
85 }
86
87 return 0;
88}