2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-03-21 02:28:16 +00:00
|
|
|
/*
|
2015-10-26 11:47:50 +00:00
|
|
|
* Copyright 2014-2015 Freescale Semiconductor, Inc.
|
2015-03-21 02:28:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/arch/fsl_serdes.h>
|
|
|
|
|
|
|
|
struct serdes_config {
|
|
|
|
u8 protocol;
|
|
|
|
u8 lanes[SRDS_MAX_LANES];
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct serdes_config serdes1_cfg_tbl[] = {
|
|
|
|
/* SerDes 1 */
|
2016-03-18 11:44:19 +00:00
|
|
|
{0x03, {PCIE2, PCIE2, PCIE2, PCIE2, PCIE1, PCIE1, PCIE1, PCIE1 } },
|
2015-03-21 02:28:16 +00:00
|
|
|
{0x05, {PCIE2, PCIE2, PCIE2, PCIE2, SGMII4, SGMII3, SGMII2, SGMII1 } },
|
|
|
|
{0x07, {SGMII8, SGMII7, SGMII6, SGMII5, SGMII4, SGMII3, SGMII2,
|
|
|
|
SGMII1 } },
|
|
|
|
{0x09, {SGMII8, SGMII7, SGMII6, SGMII5, SGMII4, SGMII3, SGMII2,
|
|
|
|
SGMII1 } },
|
|
|
|
{0x0A, {SGMII8, SGMII7, SGMII6, SGMII5, SGMII4, SGMII3, SGMII2,
|
|
|
|
SGMII1 } },
|
|
|
|
{0x0C, {SGMII8, SGMII7, SGMII6, SGMII5, SGMII4, SGMII3, SGMII2,
|
|
|
|
SGMII1 } },
|
|
|
|
{0x0E, {SGMII8, SGMII7, SGMII6, SGMII5, SGMII4, SGMII3, SGMII2,
|
|
|
|
SGMII1 } },
|
|
|
|
{0x26, {SGMII8, SGMII7, SGMII6, SGMII5, SGMII4, SGMII3, XFI2, XFI1 } },
|
|
|
|
{0x28, {SGMII8, SGMII7, SGMII6, SGMII5, XFI4, XFI3, XFI2, XFI1 } },
|
|
|
|
{0x2A, {XFI8, XFI7, XFI6, XFI5, XFI4, XFI3, XFI2, XFI1 } },
|
|
|
|
{0x2B, {SGMII8, SGMII7, SGMII6, SGMII5, XAUI1, XAUI1, XAUI1, XAUI1 } },
|
|
|
|
{0x32, {XAUI2, XAUI2, XAUI2, XAUI2, XAUI1, XAUI1, XAUI1, XAUI1 } },
|
2016-03-18 11:44:19 +00:00
|
|
|
{0x33, {PCIE2, PCIE2, PCIE2, PCIE2, QSGMII_D, QSGMII_C, QSGMII_B,
|
|
|
|
QSGMII_A} },
|
|
|
|
{0x35, {QSGMII_D, QSGMII_C, QSGMII_B, PCIE2, XFI4, XFI3, XFI2, XFI1 } },
|
2016-11-03 12:20:51 +00:00
|
|
|
{0x39, {SGMII8, SGMII7, SGMII6, PCIE2, SGMII4, SGMII3, SGMII2,
|
|
|
|
PCIE1 } },
|
2016-11-29 11:15:05 +00:00
|
|
|
{0x3B, {XFI8, XFI7, XFI6, PCIE2, XFI4, XFI3, XFI2, PCIE1 } },
|
2016-11-03 12:20:51 +00:00
|
|
|
{0x4B, {PCIE2, PCIE2, PCIE2, PCIE2, XFI4, XFI3, XFI2, XFI1 } },
|
|
|
|
{0x4C, {XFI8, XFI7, XFI6, XFI5, PCIE1, PCIE1, PCIE1, PCIE1 } },
|
|
|
|
{0x4D, {SGMII8, SGMII7, PCIE2, PCIE2, SGMII4, SGMII3, PCIE1, PCIE1 } },
|
2015-03-21 02:28:16 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
static struct serdes_config serdes2_cfg_tbl[] = {
|
|
|
|
/* SerDes 2 */
|
|
|
|
{0x07, {SGMII9, SGMII10, SGMII11, SGMII12, SGMII13, SGMII14, SGMII15,
|
|
|
|
SGMII16 } },
|
|
|
|
{0x09, {SGMII9, SGMII10, SGMII11, SGMII12, SGMII13, SGMII14, SGMII15,
|
|
|
|
SGMII16 } },
|
|
|
|
{0x0A, {SGMII9, SGMII10, SGMII11, SGMII12, SGMII13, SGMII14, SGMII15,
|
|
|
|
SGMII16 } },
|
|
|
|
{0x0C, {SGMII9, SGMII10, SGMII11, SGMII12, SGMII13, SGMII14, SGMII15,
|
|
|
|
SGMII16 } },
|
|
|
|
{0x0E, {SGMII9, SGMII10, SGMII11, SGMII12, SGMII13, SGMII14, SGMII15,
|
|
|
|
SGMII16 } },
|
|
|
|
{0x3D, {PCIE3, PCIE3, PCIE3, PCIE3, PCIE3, PCIE3, PCIE3, PCIE3 } },
|
|
|
|
{0x3E, {PCIE3, PCIE3, PCIE3, PCIE3, PCIE3, PCIE3, PCIE3, PCIE3 } },
|
|
|
|
{0x3F, {PCIE3, PCIE3, PCIE3, PCIE3, PCIE4, PCIE4, PCIE4, PCIE4 } },
|
|
|
|
{0x40, {PCIE3, PCIE3, PCIE3, PCIE3, PCIE4, PCIE4, PCIE4, PCIE4 } },
|
|
|
|
{0x41, {PCIE3, PCIE3, PCIE3, PCIE3, PCIE4, PCIE4, SATA1, SATA2 } },
|
|
|
|
{0x42, {PCIE3, PCIE3, PCIE3, PCIE3, PCIE4, PCIE4, SATA1, SATA2 } },
|
|
|
|
{0x43, {PCIE3, PCIE3, PCIE3, PCIE3, NONE, NONE, SATA1, SATA2 } },
|
|
|
|
{0x44, {PCIE3, PCIE3, PCIE3, PCIE3, NONE, NONE, SATA1, SATA2 } },
|
2016-03-18 11:44:19 +00:00
|
|
|
{0x45, {SGMII9, SGMII10, SGMII11, SGMII12, PCIE4, PCIE4, PCIE4,
|
2015-03-21 02:28:16 +00:00
|
|
|
PCIE4 } },
|
2016-03-18 11:44:19 +00:00
|
|
|
{0x47, {PCIE3, SGMII10, SGMII11, SGMII12, PCIE4, SGMII14, SGMII15,
|
|
|
|
SGMII16 } },
|
2015-03-21 02:28:16 +00:00
|
|
|
{0x49, {SGMII9, SGMII10, SGMII11, SGMII12, PCIE4, PCIE4, SATA1,
|
|
|
|
SATA2 } },
|
|
|
|
{0x4A, {SGMII9, SGMII10, SGMII11, SGMII12, PCIE4, PCIE4, SATA1,
|
|
|
|
SATA2 } },
|
2017-04-05 09:04:32 +00:00
|
|
|
{0x51, {PCIE3, PCIE3, PCIE3, PCIE3, PCIE4, PCIE4, PCIE4, PCIE4 } },
|
2016-11-03 12:20:51 +00:00
|
|
|
{0x57, {PCIE3, PCIE3, PCIE3, PCIE3, PCIE4, PCIE4, SGMII15, SGMII16 } },
|
2015-03-21 02:28:16 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct serdes_config *serdes_cfg_tbl[] = {
|
|
|
|
serdes1_cfg_tbl,
|
|
|
|
serdes2_cfg_tbl,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum srds_prtcl serdes_get_prtcl(int serdes, int cfg, int lane)
|
|
|
|
{
|
|
|
|
struct serdes_config *ptr;
|
|
|
|
|
|
|
|
if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ptr = serdes_cfg_tbl[serdes];
|
|
|
|
while (ptr->protocol) {
|
|
|
|
if (ptr->protocol == cfg)
|
|
|
|
return ptr->lanes[lane];
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int is_serdes_prtcl_valid(int serdes, u32 prtcl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct serdes_config *ptr;
|
|
|
|
|
|
|
|
if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ptr = serdes_cfg_tbl[serdes];
|
|
|
|
while (ptr->protocol) {
|
|
|
|
if (ptr->protocol == prtcl)
|
|
|
|
break;
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ptr->protocol)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = 0; i < SRDS_MAX_LANES; i++) {
|
|
|
|
if (ptr->lanes[i] != NONE)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|