1 /* Copyright 2014 Freescale Semiconductor, Inc.
3 * Shengzhou Liu <Shengzhou.Liu@freescale.com>
5 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm/immap_85xx.h>
12 #include <asm/fsl_serdes.h>
14 u32 port_to_devdisr[] = {
15 [FM1_DTSEC1] = FSL_CORENET_DEVDISR2_DTSEC1_1,
16 [FM1_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC1_2,
17 [FM1_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC1_3,
18 [FM1_DTSEC4] = FSL_CORENET_DEVDISR2_DTSEC1_4,
19 [FM1_10GEC1] = FSL_CORENET_DEVDISR2_10GEC1_1, /* MAC1 */
22 static int is_device_disabled(enum fm_port port)
24 ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
25 u32 devdisr2 = in_be32(&gur->devdisr2);
27 return port_to_devdisr[port] & devdisr2;
30 void fman_disable_port(enum fm_port port)
32 ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
34 setbits_be32(&gur->devdisr2, port_to_devdisr[port]);
37 phy_interface_t fman_port_enet_if(enum fm_port port)
39 ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
40 u32 rcwsr13 = in_be32(&gur->rcwsr[13]);
42 if (is_device_disabled(port))
43 return PHY_INTERFACE_MODE_NONE;
45 if ((port == FM1_10GEC1) && (is_serdes_configured(XFI_FM1_MAC1)))
46 return PHY_INTERFACE_MODE_XGMII;
48 if ((port == FM1_DTSEC3) && ((rcwsr13 & FSL_CORENET_RCWSR13_EC2) ==
49 FSL_CORENET_RCWSR13_EC2_RGMII) &&
50 (!is_serdes_configured(QSGMII_FM1_A)))
51 return PHY_INTERFACE_MODE_RGMII;
53 if ((port == FM1_DTSEC4) && ((rcwsr13 & FSL_CORENET_RCWSR13_EC1) ==
54 FSL_CORENET_RCWSR13_EC1_RGMII) &&
55 (!is_serdes_configured(QSGMII_FM1_A)))
56 return PHY_INTERFACE_MODE_RGMII;
63 if (is_serdes_configured(SGMII_FM1_DTSEC1 + port - FM1_DTSEC1))
64 return PHY_INTERFACE_MODE_SGMII;
65 else if (is_serdes_configured(SGMII_2500_FM1_DTSEC1
67 return PHY_INTERFACE_MODE_SGMII_2500;
79 /* check lane A on SerDes1 */
80 if (is_serdes_configured(QSGMII_FM1_A))
81 return PHY_INTERFACE_MODE_QSGMII;
87 return PHY_INTERFACE_MODE_NONE;