1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
28d67c368SShengzhou Liu /*
38d67c368SShengzhou Liu * Copyright 2014 Freescale Semiconductor, Inc.
48d67c368SShengzhou Liu *
58d67c368SShengzhou Liu * Shengzhou Liu <Shengzhou.Liu@freescale.com>
68d67c368SShengzhou Liu */
78d67c368SShengzhou Liu
88d67c368SShengzhou Liu #include <common.h>
98d67c368SShengzhou Liu #include <command.h>
108d67c368SShengzhou Liu #include <netdev.h>
118d67c368SShengzhou Liu #include <asm/mmu.h>
128d67c368SShengzhou Liu #include <asm/processor.h>
138d67c368SShengzhou Liu #include <asm/immap_85xx.h>
148d67c368SShengzhou Liu #include <asm/fsl_law.h>
158d67c368SShengzhou Liu #include <asm/fsl_serdes.h>
168d67c368SShengzhou Liu #include <asm/fsl_portals.h>
178d67c368SShengzhou Liu #include <asm/fsl_liodn.h>
188d67c368SShengzhou Liu #include <malloc.h>
198d67c368SShengzhou Liu #include <fm_eth.h>
208d67c368SShengzhou Liu #include <fsl_mdio.h>
218d67c368SShengzhou Liu #include <miiphy.h>
228d67c368SShengzhou Liu #include <phy.h>
238225b2fdSShaohui Xie #include <fsl_dtsec.h>
248d67c368SShengzhou Liu #include <asm/fsl_serdes.h>
258d67c368SShengzhou Liu
board_eth_init(bd_t * bis)268d67c368SShengzhou Liu int board_eth_init(bd_t *bis)
278d67c368SShengzhou Liu {
288d67c368SShengzhou Liu #if defined(CONFIG_FMAN_ENET)
298d67c368SShengzhou Liu int i, interface;
308d67c368SShengzhou Liu struct memac_mdio_info dtsec_mdio_info;
318d67c368SShengzhou Liu struct memac_mdio_info tgec_mdio_info;
328d67c368SShengzhou Liu struct mii_dev *dev;
338d67c368SShengzhou Liu ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
348d67c368SShengzhou Liu u32 srds_s1;
358d67c368SShengzhou Liu
368d67c368SShengzhou Liu srds_s1 = in_be32(&gur->rcwsr[4]) &
378d67c368SShengzhou Liu FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
388d67c368SShengzhou Liu srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
398d67c368SShengzhou Liu
408d67c368SShengzhou Liu dtsec_mdio_info.regs =
418d67c368SShengzhou Liu (struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR;
428d67c368SShengzhou Liu
438d67c368SShengzhou Liu dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
448d67c368SShengzhou Liu
458d67c368SShengzhou Liu /* Register the 1G MDIO bus */
468d67c368SShengzhou Liu fm_memac_mdio_init(bis, &dtsec_mdio_info);
478d67c368SShengzhou Liu
488d67c368SShengzhou Liu tgec_mdio_info.regs =
498d67c368SShengzhou Liu (struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR;
508d67c368SShengzhou Liu tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
518d67c368SShengzhou Liu
528d67c368SShengzhou Liu /* Register the 10G MDIO bus */
538d67c368SShengzhou Liu fm_memac_mdio_init(bis, &tgec_mdio_info);
548d67c368SShengzhou Liu
558d67c368SShengzhou Liu /* Set the two on-board RGMII PHY address */
568d67c368SShengzhou Liu fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY1_ADDR);
578d67c368SShengzhou Liu fm_info_set_phy_address(FM1_DTSEC4, RGMII_PHY2_ADDR);
588d67c368SShengzhou Liu
598d67c368SShengzhou Liu switch (srds_s1) {
608d67c368SShengzhou Liu case 0x66:
618d67c368SShengzhou Liu case 0x6b:
628d67c368SShengzhou Liu fm_info_set_phy_address(FM1_10GEC1, CORTINA_PHY_ADDR1);
638d67c368SShengzhou Liu fm_info_set_phy_address(FM1_10GEC2, CORTINA_PHY_ADDR2);
648d67c368SShengzhou Liu fm_info_set_phy_address(FM1_10GEC3, FM1_10GEC3_PHY_ADDR);
658d67c368SShengzhou Liu fm_info_set_phy_address(FM1_10GEC4, FM1_10GEC4_PHY_ADDR);
668d67c368SShengzhou Liu break;
678d67c368SShengzhou Liu default:
688d67c368SShengzhou Liu printf("SerDes1 protocol 0x%x is not supported on T208xRDB\n",
698d67c368SShengzhou Liu srds_s1);
708d67c368SShengzhou Liu break;
718d67c368SShengzhou Liu }
728d67c368SShengzhou Liu
738d67c368SShengzhou Liu for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
748d67c368SShengzhou Liu interface = fm_info_get_enet_if(i);
758d67c368SShengzhou Liu switch (interface) {
768d67c368SShengzhou Liu case PHY_INTERFACE_MODE_RGMII:
778d67c368SShengzhou Liu dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
788d67c368SShengzhou Liu fm_info_set_mdio(i, dev);
798d67c368SShengzhou Liu break;
808d67c368SShengzhou Liu default:
818d67c368SShengzhou Liu break;
828d67c368SShengzhou Liu }
838d67c368SShengzhou Liu }
848d67c368SShengzhou Liu
858d67c368SShengzhou Liu for (i = FM1_10GEC1; i < FM1_10GEC1 + CONFIG_SYS_NUM_FM1_10GEC; i++) {
868d67c368SShengzhou Liu switch (fm_info_get_enet_if(i)) {
878d67c368SShengzhou Liu case PHY_INTERFACE_MODE_XGMII:
888d67c368SShengzhou Liu dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME);
898d67c368SShengzhou Liu fm_info_set_mdio(i, dev);
908d67c368SShengzhou Liu break;
918d67c368SShengzhou Liu default:
928d67c368SShengzhou Liu break;
938d67c368SShengzhou Liu }
948d67c368SShengzhou Liu }
958d67c368SShengzhou Liu
968d67c368SShengzhou Liu cpu_eth_init(bis);
978d67c368SShengzhou Liu #endif /* CONFIG_FMAN_ENET */
988d67c368SShengzhou Liu
998d67c368SShengzhou Liu return pci_eth_init(bis);
1008d67c368SShengzhou Liu }
1018d67c368SShengzhou Liu
fdt_fixup_board_enet(void * fdt)1028d67c368SShengzhou Liu void fdt_fixup_board_enet(void *fdt)
1038d67c368SShengzhou Liu {
1048d67c368SShengzhou Liu return;
1058d67c368SShengzhou Liu }
106