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
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/io.h>
|
2016-09-21 02:28:55 +00:00
|
|
|
#include <linux/errno.h>
|
2015-03-21 02:28:16 +00:00
|
|
|
#include <asm/arch/fsl_serdes.h>
|
2015-10-26 11:47:50 +00:00
|
|
|
#include <asm/arch/soc.h>
|
2015-03-21 02:28:22 +00:00
|
|
|
#include <fsl-mc/ldpaa_wriop.h>
|
2015-03-21 02:28:16 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_SRDS_1
|
|
|
|
static u8 serdes1_prtcl_map[SERDES_PRCTL_COUNT];
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SYS_FSL_SRDS_2
|
|
|
|
static u8 serdes2_prtcl_map[SERDES_PRCTL_COUNT];
|
|
|
|
#endif
|
|
|
|
|
2017-05-05 10:12:29 +00:00
|
|
|
#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
|
2015-11-04 06:55:52 +00:00
|
|
|
int xfi_dpmac[XFI8 + 1];
|
|
|
|
int sgmii_dpmac[SGMII16 + 1];
|
|
|
|
#endif
|
|
|
|
|
2017-02-15 15:10:00 +00:00
|
|
|
__weak void wriop_init_dpmac_qsgmii(int sd, int lane_prtcl)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
armv8: ls1088a: Add NXP LS1088A SoC support
LS1088A is compliant with the Layerscape Chassis Generation 3 with
eight ARM v8 Cortex-A53 cores in 2 cluster, CCI-400, one 64-bit DDR4
SDRAM memory controller with ECC, Data path acceleration architecture
2.0 (DPAA2), Ethernet interfaces (SGMIIs, RGMIIs, QSGMIIs, XFIs),
QSPI, IFC, PCIe, SATA, USB, SDXC, DUARTs etc.
Signed-off-by: Alison Wang <alison.wang@nxp.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Signed-off-by: Ashish Kumar <Ashish.Kumar@nxp.com>
Signed-off-by: Raghav Dogra <raghav.dogra@nxp.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
[YS: Revised commit message]
Reviewed-by: York Sun <york.sun@nxp.com>
2017-08-31 10:42:53 +00:00
|
|
|
/*
|
|
|
|
*The return value of this func is the serdes protocol used.
|
|
|
|
*Typically this function is called number of times depending
|
|
|
|
*upon the number of serdes blocks in the Silicon.
|
|
|
|
*Zero is used to denote that no serdes was enabled,
|
|
|
|
*this is the case when golden RCW was used where DPAA2 bring was
|
|
|
|
*intentionally removed to achieve boot to prompt
|
|
|
|
*/
|
|
|
|
|
|
|
|
__weak int serdes_get_number(int serdes, int cfg)
|
|
|
|
{
|
|
|
|
return cfg;
|
|
|
|
}
|
|
|
|
|
2015-03-21 02:28:16 +00:00
|
|
|
int is_serdes_configured(enum srds_prtcl device)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_SRDS_1
|
2016-08-02 11:03:22 +00:00
|
|
|
if (!serdes1_prtcl_map[NONE])
|
|
|
|
fsl_serdes_init();
|
|
|
|
|
2015-03-21 02:28:16 +00:00
|
|
|
ret |= serdes1_prtcl_map[device];
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SYS_FSL_SRDS_2
|
2016-08-02 11:03:22 +00:00
|
|
|
if (!serdes2_prtcl_map[NONE])
|
|
|
|
fsl_serdes_init();
|
|
|
|
|
2015-03-21 02:28:16 +00:00
|
|
|
ret |= serdes2_prtcl_map[device];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return !!ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int serdes_get_first_lane(u32 sd, enum srds_prtcl device)
|
|
|
|
{
|
|
|
|
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
|
2017-02-15 15:10:35 +00:00
|
|
|
u32 cfg = 0;
|
2015-03-21 02:28:16 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
switch (sd) {
|
|
|
|
#ifdef CONFIG_SYS_FSL_SRDS_1
|
|
|
|
case FSL_SRDS_1:
|
2017-02-15 15:10:35 +00:00
|
|
|
cfg = gur_in32(&gur->rcwsr[FSL_CHASSIS3_SRDS1_REGSR - 1]);
|
|
|
|
cfg &= FSL_CHASSIS3_SRDS1_PRTCL_MASK;
|
|
|
|
cfg >>= FSL_CHASSIS3_SRDS1_PRTCL_SHIFT;
|
2015-03-21 02:28:16 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SYS_FSL_SRDS_2
|
|
|
|
case FSL_SRDS_2:
|
2017-02-15 15:10:35 +00:00
|
|
|
cfg = gur_in32(&gur->rcwsr[FSL_CHASSIS3_SRDS2_REGSR - 1]);
|
|
|
|
cfg &= FSL_CHASSIS3_SRDS2_PRTCL_MASK;
|
|
|
|
cfg >>= FSL_CHASSIS3_SRDS2_PRTCL_SHIFT;
|
2015-03-21 02:28:16 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
printf("invalid SerDes%d\n", sd);
|
|
|
|
break;
|
|
|
|
}
|
armv8: ls1088a: Add NXP LS1088A SoC support
LS1088A is compliant with the Layerscape Chassis Generation 3 with
eight ARM v8 Cortex-A53 cores in 2 cluster, CCI-400, one 64-bit DDR4
SDRAM memory controller with ECC, Data path acceleration architecture
2.0 (DPAA2), Ethernet interfaces (SGMIIs, RGMIIs, QSGMIIs, XFIs),
QSPI, IFC, PCIe, SATA, USB, SDXC, DUARTs etc.
Signed-off-by: Alison Wang <alison.wang@nxp.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Signed-off-by: Ashish Kumar <Ashish.Kumar@nxp.com>
Signed-off-by: Raghav Dogra <raghav.dogra@nxp.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
[YS: Revised commit message]
Reviewed-by: York Sun <york.sun@nxp.com>
2017-08-31 10:42:53 +00:00
|
|
|
|
|
|
|
cfg = serdes_get_number(sd, cfg);
|
|
|
|
|
2015-03-21 02:28:16 +00:00
|
|
|
/* Is serdes enabled at all? */
|
|
|
|
if (cfg == 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
for (i = 0; i < SRDS_MAX_LANES; i++) {
|
|
|
|
if (serdes_get_prtcl(sd, cfg, i) == device)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2017-02-15 15:10:35 +00:00
|
|
|
void serdes_init(u32 sd, u32 sd_addr, u32 rcwsr, u32 sd_prctl_mask,
|
|
|
|
u32 sd_prctl_shift, u8 serdes_prtcl_map[SERDES_PRCTL_COUNT])
|
2015-03-21 02:28:16 +00:00
|
|
|
{
|
|
|
|
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
|
|
|
|
u32 cfg;
|
|
|
|
int lane;
|
|
|
|
|
2016-08-02 11:03:22 +00:00
|
|
|
if (serdes_prtcl_map[NONE])
|
|
|
|
return;
|
|
|
|
|
2015-11-28 13:04:41 +00:00
|
|
|
memset(serdes_prtcl_map, 0, sizeof(u8) * SERDES_PRCTL_COUNT);
|
2015-03-21 02:28:16 +00:00
|
|
|
|
2017-02-15 15:10:35 +00:00
|
|
|
cfg = gur_in32(&gur->rcwsr[rcwsr - 1]) & sd_prctl_mask;
|
2015-03-21 02:28:16 +00:00
|
|
|
cfg >>= sd_prctl_shift;
|
armv8: ls1088a: Add NXP LS1088A SoC support
LS1088A is compliant with the Layerscape Chassis Generation 3 with
eight ARM v8 Cortex-A53 cores in 2 cluster, CCI-400, one 64-bit DDR4
SDRAM memory controller with ECC, Data path acceleration architecture
2.0 (DPAA2), Ethernet interfaces (SGMIIs, RGMIIs, QSGMIIs, XFIs),
QSPI, IFC, PCIe, SATA, USB, SDXC, DUARTs etc.
Signed-off-by: Alison Wang <alison.wang@nxp.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Signed-off-by: Ashish Kumar <Ashish.Kumar@nxp.com>
Signed-off-by: Raghav Dogra <raghav.dogra@nxp.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
[YS: Revised commit message]
Reviewed-by: York Sun <york.sun@nxp.com>
2017-08-31 10:42:53 +00:00
|
|
|
|
|
|
|
cfg = serdes_get_number(sd, cfg);
|
2015-03-21 02:28:16 +00:00
|
|
|
printf("Using SERDES%d Protocol: %d (0x%x)\n", sd + 1, cfg, cfg);
|
|
|
|
|
|
|
|
if (!is_serdes_prtcl_valid(sd, cfg))
|
|
|
|
printf("SERDES%d[PRTCL] = 0x%x is not valid\n", sd + 1, cfg);
|
|
|
|
|
|
|
|
for (lane = 0; lane < SRDS_MAX_LANES; lane++) {
|
|
|
|
enum srds_prtcl lane_prtcl = serdes_get_prtcl(sd, cfg, lane);
|
|
|
|
if (unlikely(lane_prtcl >= SERDES_PRCTL_COUNT))
|
|
|
|
debug("Unknown SerDes lane protocol %d\n", lane_prtcl);
|
2015-03-21 02:28:22 +00:00
|
|
|
else {
|
2015-03-21 02:28:16 +00:00
|
|
|
serdes_prtcl_map[lane_prtcl] = 1;
|
2017-05-05 10:12:29 +00:00
|
|
|
#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
|
2015-08-07 12:31:26 +00:00
|
|
|
switch (lane_prtcl) {
|
|
|
|
case QSGMII_A:
|
|
|
|
case QSGMII_B:
|
|
|
|
case QSGMII_C:
|
|
|
|
case QSGMII_D:
|
2017-02-15 15:10:00 +00:00
|
|
|
wriop_init_dpmac_qsgmii(sd, (int)lane_prtcl);
|
2015-08-07 12:31:26 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-11-04 06:55:52 +00:00
|
|
|
if (lane_prtcl >= XFI1 && lane_prtcl <= XFI8)
|
|
|
|
wriop_init_dpmac(sd,
|
|
|
|
xfi_dpmac[lane_prtcl],
|
|
|
|
(int)lane_prtcl);
|
|
|
|
|
2015-08-07 12:31:26 +00:00
|
|
|
if (lane_prtcl >= SGMII1 &&
|
2015-11-04 06:55:52 +00:00
|
|
|
lane_prtcl <= SGMII16)
|
|
|
|
wriop_init_dpmac(sd, sgmii_dpmac[
|
|
|
|
lane_prtcl],
|
2015-08-07 12:31:26 +00:00
|
|
|
(int)lane_prtcl);
|
|
|
|
break;
|
|
|
|
}
|
2015-03-21 02:28:22 +00:00
|
|
|
#endif
|
|
|
|
}
|
2015-03-21 02:28:16 +00:00
|
|
|
}
|
2016-08-02 11:03:22 +00:00
|
|
|
|
|
|
|
/* Set the first element to indicate serdes has been initialized */
|
|
|
|
serdes_prtcl_map[NONE] = 1;
|
2015-03-21 02:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void fsl_serdes_init(void)
|
|
|
|
{
|
2017-05-05 10:12:29 +00:00
|
|
|
#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
|
2015-11-04 06:55:52 +00:00
|
|
|
int i , j;
|
|
|
|
|
|
|
|
for (i = XFI1, j = 1; i <= XFI8; i++, j++)
|
|
|
|
xfi_dpmac[i] = j;
|
|
|
|
|
|
|
|
for (i = SGMII1, j = 1; i <= SGMII16; i++, j++)
|
|
|
|
sgmii_dpmac[i] = j;
|
|
|
|
#endif
|
|
|
|
|
2015-03-21 02:28:16 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_SRDS_1
|
|
|
|
serdes_init(FSL_SRDS_1,
|
|
|
|
CONFIG_SYS_FSL_LSCH3_SERDES_ADDR,
|
2017-02-15 15:10:35 +00:00
|
|
|
FSL_CHASSIS3_SRDS1_REGSR,
|
|
|
|
FSL_CHASSIS3_SRDS1_PRTCL_MASK,
|
|
|
|
FSL_CHASSIS3_SRDS1_PRTCL_SHIFT,
|
2015-03-21 02:28:16 +00:00
|
|
|
serdes1_prtcl_map);
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SYS_FSL_SRDS_2
|
|
|
|
serdes_init(FSL_SRDS_2,
|
|
|
|
CONFIG_SYS_FSL_LSCH3_SERDES_ADDR + FSL_SRDS_2 * 0x10000,
|
2017-02-15 15:10:35 +00:00
|
|
|
FSL_CHASSIS3_SRDS2_REGSR,
|
|
|
|
FSL_CHASSIS3_SRDS2_PRTCL_MASK,
|
|
|
|
FSL_CHASSIS3_SRDS2_PRTCL_SHIFT,
|
2015-03-21 02:28:16 +00:00
|
|
|
serdes2_prtcl_map);
|
|
|
|
#endif
|
|
|
|
}
|