Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / arch / powerpc / cpu / mpc85xx / bsc9132_serdes.c
index 300a4dbcf659b08fab22833d1bab80a8bd1cc043..8604f4a8e8fe04ec4cc3379a2c7fcd5b3ad58d35 100644 (file)
@@ -1,11 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  * Author: Prabhakar Kushwaha <prabhakar@freescale.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
  */
 
 #include <config.h>
@@ -71,6 +67,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;
 }
 
@@ -82,6 +81,9 @@ void fsl_serdes_init(void)
                                MPC85xx_PORDEVSR_IO_SEL_SHIFT;
        int lane;
 
+       if (serdes1_prtcl_map & (1 << NONE))
+               return;
+
        debug("PORDEVSR[IO_SEL_SRDS] = %x\n", srds_cfg);
 
        if (srds_cfg >= ARRAY_SIZE(serdes1_cfg_tbl)) {
@@ -93,4 +95,7 @@ void fsl_serdes_init(void)
                enum srds_prtcl lane_prtcl = serdes1_cfg_tbl[srds_cfg][lane];
                serdes1_prtcl_map |= (1 << lane_prtcl);
        }
+
+       /* Set the first bit to indicate serdes has been initialized */
+       serdes1_prtcl_map |= (1 << NONE);
 }