1 /* 2 * Copyright 2015 Freescale Semiconductor, Inc. 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #include <common.h> 8 #include <asm/arch/fsl_serdes.h> 9 #include <asm/arch/immap_lsch2.h> 10 11 struct serdes_config { 12 u32 protocol; 13 u8 lanes[SRDS_MAX_LANES]; 14 }; 15 16 static struct serdes_config serdes1_cfg_tbl[] = { 17 /* SerDes 1 */ 18 {0x1555, {XFI_FM1_MAC9, PCIE1, PCIE2, PCIE3} }, 19 {0x2555, {SGMII_2500_FM1_DTSEC9, PCIE1, PCIE2, PCIE3} }, 20 {0x4555, {QSGMII_FM1_A, PCIE1, PCIE2, PCIE3} }, 21 {0x4558, {QSGMII_FM1_A, PCIE1, PCIE2, SATA1} }, 22 {0x1355, {XFI_FM1_MAC9, SGMII_FM1_DTSEC2, PCIE2, PCIE3} }, 23 {0x2355, {SGMII_2500_FM1_DTSEC9, SGMII_FM1_DTSEC2, PCIE2, PCIE3} }, 24 {0x3335, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC5, 25 PCIE3} }, 26 {0x3355, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC2, PCIE2, PCIE3} }, 27 {0x3358, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC2, PCIE2, SATA1} }, 28 {0x3555, {SGMII_FM1_DTSEC9, PCIE1, PCIE2, PCIE3} }, 29 {0x3558, {SGMII_FM1_DTSEC9, PCIE1, PCIE2, SATA1} }, 30 {0x7000, {PCIE1, PCIE1, PCIE1, PCIE1} }, 31 {0x9998, {PCIE1, PCIE2, PCIE3, SATA1} }, 32 {0x6058, {PCIE1, PCIE1, PCIE2, SATA1} }, 33 {0x1455, {XFI_FM1_MAC9, QSGMII_FM1_A, PCIE2, PCIE3} }, 34 {0x2455, {SGMII_2500_FM1_DTSEC9, QSGMII_FM1_A, PCIE2, PCIE3} }, 35 {0x2255, {SGMII_2500_FM1_DTSEC9, SGMII_2500_FM1_DTSEC2, PCIE2, PCIE3} }, 36 {0x3333, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC5, 37 SGMII_FM1_DTSEC6} }, 38 {} 39 }; 40 41 static struct serdes_config *serdes_cfg_tbl[] = { 42 serdes1_cfg_tbl, 43 }; 44 45 enum srds_prtcl serdes_get_prtcl(int serdes, int cfg, int lane) 46 { 47 struct serdes_config *ptr; 48 49 if (serdes >= ARRAY_SIZE(serdes_cfg_tbl)) 50 return 0; 51 52 ptr = serdes_cfg_tbl[serdes]; 53 while (ptr->protocol) { 54 if (ptr->protocol == cfg) 55 return ptr->lanes[lane]; 56 ptr++; 57 } 58 59 return 0; 60 } 61 62 int is_serdes_prtcl_valid(int serdes, u32 prtcl) 63 { 64 int i; 65 struct serdes_config *ptr; 66 67 if (serdes >= ARRAY_SIZE(serdes_cfg_tbl)) 68 return 0; 69 70 ptr = serdes_cfg_tbl[serdes]; 71 while (ptr->protocol) { 72 if (ptr->protocol == prtcl) 73 break; 74 ptr++; 75 } 76 77 if (!ptr->protocol) 78 return 0; 79 80 for (i = 0; i < SRDS_MAX_LANES; i++) { 81 if (ptr->lanes[i] != NONE) 82 return 1; 83 } 84 85 return 0; 86 } 87