2 * Copyright 2014 Freescale Semiconductor, Inc.
4 * Chunhe Lan <Chunhe.Lan@freescale.com>
6 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/processor.h>
14 #include <asm/cache.h>
15 #include <asm/immap_85xx.h>
16 #include <asm/fsl_law.h>
17 #include <fsl_ddr_sdram.h>
18 #include <asm/fsl_serdes.h>
19 #include <asm/fsl_portals.h>
20 #include <asm/fsl_liodn.h>
26 #include <fsl_dtsec.h>
27 #include <asm/fsl_serdes.h>
30 #include "../common/fman.h"
33 void fdt_fixup_board_enet(void *fdt)
38 int board_eth_init(bd_t *bis)
40 #if defined(CONFIG_FMAN_ENET)
42 struct memac_mdio_info dtsec_mdio_info;
43 struct memac_mdio_info tgec_mdio_info;
45 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
46 u32 srds_prtcl_s1, srds_prtcl_s2;
48 srds_prtcl_s1 = in_be32(&gur->rcwsr[4]) &
49 FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
50 srds_prtcl_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
51 srds_prtcl_s2 = in_be32(&gur->rcwsr[4]) &
52 FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
53 srds_prtcl_s2 >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
55 dtsec_mdio_info.regs =
56 (struct memac_mdio_controller *)CONFIG_SYS_FM2_DTSEC_MDIO_ADDR;
58 dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
60 /* Register the 1G MDIO bus */
61 fm_memac_mdio_init(bis, &dtsec_mdio_info);
64 (struct memac_mdio_controller *)CONFIG_SYS_FM2_TGEC_MDIO_ADDR;
65 tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
67 /* Register the 10G MDIO bus */
68 fm_memac_mdio_init(bis, &tgec_mdio_info);
70 if ((srds_prtcl_s1 == 28) || (srds_prtcl_s1 == 27)) {
72 fm_info_set_phy_address(FM1_DTSEC1, SGMII_PHY_ADDR1);
73 fm_info_set_phy_address(FM1_DTSEC2, SGMII_PHY_ADDR2);
74 fm_info_set_phy_address(FM1_DTSEC3, SGMII_PHY_ADDR3);
75 fm_info_set_phy_address(FM1_DTSEC4, SGMII_PHY_ADDR4);
77 puts("Invalid SerDes1 protocol for T4240RDB\n");
80 fm_disable_port(FM1_DTSEC5);
81 fm_disable_port(FM1_DTSEC6);
83 for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
84 interface = fm_info_get_enet_if(i);
86 case PHY_INTERFACE_MODE_SGMII:
87 dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
88 fm_info_set_mdio(i, dev);
95 for (i = FM1_10GEC1; i < FM1_10GEC1 + CONFIG_SYS_NUM_FM1_10GEC; i++) {
96 switch (fm_info_get_enet_if(i)) {
97 case PHY_INTERFACE_MODE_XGMII:
98 dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME);
99 fm_info_set_mdio(i, dev);
106 #if (CONFIG_SYS_NUM_FMAN == 2)
107 if ((srds_prtcl_s2 == 56) || (srds_prtcl_s2 == 55)) {
109 fm_info_set_phy_address(FM2_DTSEC1, SGMII_PHY_ADDR5);
110 fm_info_set_phy_address(FM2_DTSEC2, SGMII_PHY_ADDR6);
111 fm_info_set_phy_address(FM2_DTSEC3, SGMII_PHY_ADDR7);
112 fm_info_set_phy_address(FM2_DTSEC4, SGMII_PHY_ADDR8);
113 fm_info_set_phy_address(FM1_10GEC1, FM1_10GEC1_PHY_ADDR);
114 fm_info_set_phy_address(FM1_10GEC2, FM1_10GEC2_PHY_ADDR);
115 fm_info_set_phy_address(FM2_10GEC1, FM2_10GEC2_PHY_ADDR);
116 fm_info_set_phy_address(FM2_10GEC2, FM2_10GEC1_PHY_ADDR);
118 puts("Invalid SerDes2 protocol for T4240RDB\n");
121 fm_disable_port(FM2_DTSEC5);
122 fm_disable_port(FM2_DTSEC6);
123 for (i = FM2_DTSEC1; i < FM2_DTSEC1 + CONFIG_SYS_NUM_FM2_DTSEC; i++) {
124 interface = fm_info_get_enet_if(i);
126 case PHY_INTERFACE_MODE_SGMII:
127 dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
128 fm_info_set_mdio(i, dev);
135 for (i = FM2_10GEC1; i < FM2_10GEC1 + CONFIG_SYS_NUM_FM2_10GEC; i++) {
136 switch (fm_info_get_enet_if(i)) {
137 case PHY_INTERFACE_MODE_XGMII:
138 dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME);
139 fm_info_set_mdio(i, dev);
145 #endif /* CONFIG_SYS_NUM_FMAN */
148 #endif /* CONFIG_FMAN_ENET */
150 return pci_eth_init(bis);