From 71fe22256cc9eb5decdd98842ec030ba921cd321 Mon Sep 17 00:00:00 2001 From: Hou Zhiqiang Date: Tue, 2 Aug 2016 19:03:22 +0800 Subject: fsl: serdes: ensure accessing the initialized maps of serdes protocol Up to now, the function is_serdes_configed() doesn't check if the map of serdes protocol is initialized before accessing it. The function is_serdes_configed() will get wrong result when it was called before the serdes protocol maps initialized. As the first element of the map isn't used for any device, so use it as the flag to indicate if the map has been initialized. Signed-off-by: Hou Zhiqiang Reviewed-by: York Sun --- arch/powerpc/cpu/mpc85xx/p1021_serdes.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'arch/powerpc/cpu/mpc85xx/p1021_serdes.c') diff --git a/arch/powerpc/cpu/mpc85xx/p1021_serdes.c b/arch/powerpc/cpu/mpc85xx/p1021_serdes.c index 99a77bd..77b9439 100644 --- a/arch/powerpc/cpu/mpc85xx/p1021_serdes.c +++ b/arch/powerpc/cpu/mpc85xx/p1021_serdes.c @@ -41,6 +41,9 @@ static u8 serdes1_cfg_tbl[][SRDS1_MAX_LANES] = { int is_serdes_configured(enum srds_prtcl prtcl) { + if (!(serdes1_prtcl_map & (1 << NONE))) + fsl_serdes_init(); + return (1 << prtcl) & serdes1_prtcl_map; } @@ -55,6 +58,9 @@ void fsl_serdes_init(void) int lane; u32 mask, val; + if (serdes1_prtcl_map & (1 << NONE)) + return; + debug("PORDEVSR[IO_SEL_SRDS] = %x\n", srds_cfg); if (srds_cfg >= ARRAY_SIZE(serdes1_cfg_tbl)) { @@ -67,6 +73,9 @@ void fsl_serdes_init(void) serdes1_prtcl_map |= (1 << lane_prtcl); } + /* Set the first bit to indicate serdes has been initialized */ + serdes1_prtcl_map |= (1 << NONE); + /* Init SERDES Receiver electrical idle detection control for PCIe */ /* Lane 0 is always PCIe 1 */ -- cgit v1.1