1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2011 Freescale Semiconductor, Inc.
9 #include <asm/immap_85xx.h>
10 #include <asm/fsl_serdes.h>
12 static u32 port_to_devdisr[] = {
13 [FM1_DTSEC1] = FSL_CORENET_DEVDISR2_DTSEC1_1,
14 [FM1_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC1_2,
15 [FM1_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC1_3,
16 [FM1_DTSEC4] = FSL_CORENET_DEVDISR2_DTSEC1_4,
17 [FM1_10GEC1] = FSL_CORENET_DEVDISR2_10GEC1,
18 [FM2_DTSEC1] = FSL_CORENET_DEVDISR2_DTSEC2_1,
19 [FM2_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC2_2,
20 [FM2_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC2_3,
21 [FM2_DTSEC4] = FSL_CORENET_DEVDISR2_DTSEC2_4,
22 [FM2_10GEC1] = FSL_CORENET_DEVDISR2_10GEC2,
25 static int is_device_disabled(enum fm_port port)
27 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
28 u32 devdisr2 = in_be32(&gur->devdisr2);
30 return port_to_devdisr[port] & devdisr2;
33 void fman_disable_port(enum fm_port port)
35 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
37 /* don't allow disabling of DTSEC1 as its needed for MDIO */
38 if (port == FM1_DTSEC1)
41 setbits_be32(&gur->devdisr2, port_to_devdisr[port]);
44 void fman_enable_port(enum fm_port port)
46 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
48 clrbits_be32(&gur->devdisr2, port_to_devdisr[port]);
51 phy_interface_t fman_port_enet_if(enum fm_port port)
53 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
54 u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
56 if (is_device_disabled(port))
57 return PHY_INTERFACE_MODE_NA;
59 if ((port == FM1_10GEC1) && (is_serdes_configured(XAUI_FM1)))
60 return PHY_INTERFACE_MODE_XGMII;
62 if ((port == FM2_10GEC1) && (is_serdes_configured(XAUI_FM2)))
63 return PHY_INTERFACE_MODE_XGMII;
65 /* handle RGMII first */
66 if ((port == FM1_DTSEC1) && ((rcwsr11 & FSL_CORENET_RCWSR11_EC1) ==
67 FSL_CORENET_RCWSR11_EC1_FM1_DTSEC1))
68 return PHY_INTERFACE_MODE_RGMII;
70 if ((port == FM1_DTSEC2) && ((rcwsr11 & FSL_CORENET_RCWSR11_EC2) ==
71 FSL_CORENET_RCWSR11_EC2_FM1_DTSEC2))
72 return PHY_INTERFACE_MODE_RGMII;
74 if ((port == FM2_DTSEC1) && ((rcwsr11 & FSL_CORENET_RCWSR11_EC2) ==
75 FSL_CORENET_RCWSR11_EC2_FM2_DTSEC1))
76 return PHY_INTERFACE_MODE_RGMII;
83 if (is_serdes_configured(SGMII_FM1_DTSEC1 + port - FM1_DTSEC1))
84 return PHY_INTERFACE_MODE_SGMII;
90 if (is_serdes_configured(SGMII_FM2_DTSEC1 + port - FM2_DTSEC1))
91 return PHY_INTERFACE_MODE_SGMII;
94 return PHY_INTERFACE_MODE_NA;
97 return PHY_INTERFACE_MODE_NA;