2 * Copyright 2016 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <asm/arch/fsl_serdes.h>
9 #include <asm/arch/immap_lsch2.h>
11 struct serdes_config {
13 u8 lanes[SRDS_MAX_LANES];
16 static struct serdes_config serdes1_cfg_tbl[] = {
18 {0x3333, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC10, SGMII_FM1_DTSEC5,
20 {0x1133, {XFI_FM1_MAC9, XFI_FM1_MAC10, SGMII_FM1_DTSEC5,
22 {0x1333, {XFI_FM1_MAC9, SGMII_FM1_DTSEC10, SGMII_FM1_DTSEC5,
24 {0x2333, {SGMII_2500_FM1_DTSEC9, SGMII_FM1_DTSEC10, SGMII_FM1_DTSEC5,
26 {0x2233, {SGMII_2500_FM1_DTSEC9, SGMII_2500_FM1_DTSEC10,
27 SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC6} },
28 {0x1040, {XFI_FM1_MAC9, NONE, QSGMII_FM1_A, NONE} },
29 {0x2040, {SGMII_2500_FM1_DTSEC9, NONE, QSGMII_FM1_A, NONE} },
30 {0x1163, {XFI_FM1_MAC9, XFI_FM1_MAC10, PCIE1, SGMII_FM1_DTSEC6} },
31 {0x2263, {SGMII_2500_FM1_DTSEC9, SGMII_2500_FM1_DTSEC10, PCIE1,
33 {0x3363, {SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC6, PCIE1,
35 {0x2223, {SGMII_2500_FM1_DTSEC9, SGMII_2500_FM1_DTSEC10,
36 SGMII_2500_FM1_DTSEC5, SGMII_FM1_DTSEC6} },
40 static struct serdes_config serdes2_cfg_tbl[] = {
42 {0x8888, {PCIE1, PCIE1, PCIE1, PCIE1} },
43 {0x5559, {PCIE1, PCIE2, PCIE3, SATA1} },
44 {0x5577, {PCIE1, PCIE2, PCIE3, PCIE3} },
45 {0x5506, {PCIE1, PCIE2, NONE, PCIE3} },
46 {0x0506, {NONE, PCIE2, NONE, PCIE3} },
47 {0x0559, {NONE, PCIE2, PCIE3, SATA1} },
48 {0x5A59, {PCIE1, SGMII_FM1_DTSEC2, PCIE3, SATA1} },
49 {0x5A06, {PCIE1, SGMII_FM1_DTSEC2, NONE, PCIE3} },
53 static struct serdes_config *serdes_cfg_tbl[] = {
58 enum srds_prtcl serdes_get_prtcl(int serdes, int cfg, int lane)
60 struct serdes_config *ptr;
62 if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
65 ptr = serdes_cfg_tbl[serdes];
66 while (ptr->protocol) {
67 if (ptr->protocol == cfg)
68 return ptr->lanes[lane];
75 int is_serdes_prtcl_valid(int serdes, u32 prtcl)
78 struct serdes_config *ptr;
80 if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
83 ptr = serdes_cfg_tbl[serdes];
84 while (ptr->protocol) {
85 if (ptr->protocol == prtcl)
93 for (i = 0; i < SRDS_MAX_LANES; i++) {
94 if (ptr->lanes[i] != NONE)