Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * Shengzhou Liu <Shengzhou.Liu@freescale.com> |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 10 | #include <fdt_support.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 11 | #include <net.h> |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 12 | #include <netdev.h> |
| 13 | #include <asm/mmu.h> |
| 14 | #include <asm/processor.h> |
| 15 | #include <asm/immap_85xx.h> |
| 16 | #include <asm/fsl_law.h> |
| 17 | #include <asm/fsl_serdes.h> |
| 18 | #include <asm/fsl_portals.h> |
| 19 | #include <asm/fsl_liodn.h> |
| 20 | #include <malloc.h> |
| 21 | #include <fm_eth.h> |
| 22 | #include <fsl_mdio.h> |
| 23 | #include <miiphy.h> |
| 24 | #include <phy.h> |
Shaohui Xie | 513eaf2 | 2015-10-26 19:47:47 +0800 | [diff] [blame] | 25 | #include <fsl_dtsec.h> |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 26 | #include <asm/fsl_serdes.h> |
| 27 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 28 | int board_eth_init(struct bd_info *bis) |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 29 | { |
| 30 | #if defined(CONFIG_FMAN_ENET) |
| 31 | int i, interface; |
| 32 | struct memac_mdio_info dtsec_mdio_info; |
| 33 | struct memac_mdio_info tgec_mdio_info; |
| 34 | struct mii_dev *dev; |
| 35 | ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 36 | u32 srds_s1; |
| 37 | |
| 38 | srds_s1 = in_be32(&gur->rcwsr[4]) & |
| 39 | FSL_CORENET2_RCWSR4_SRDS1_PRTCL; |
| 40 | srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT; |
| 41 | |
| 42 | dtsec_mdio_info.regs = |
| 43 | (struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR; |
| 44 | |
| 45 | dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME; |
| 46 | |
| 47 | /* Register the 1G MDIO bus */ |
| 48 | fm_memac_mdio_init(bis, &dtsec_mdio_info); |
| 49 | |
| 50 | tgec_mdio_info.regs = |
| 51 | (struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR; |
| 52 | tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME; |
| 53 | |
| 54 | /* Register the 10G MDIO bus */ |
| 55 | fm_memac_mdio_init(bis, &tgec_mdio_info); |
| 56 | |
| 57 | /* Set the two on-board RGMII PHY address */ |
| 58 | fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY1_ADDR); |
| 59 | fm_info_set_phy_address(FM1_DTSEC4, RGMII_PHY2_ADDR); |
| 60 | |
| 61 | switch (srds_s1) { |
| 62 | case 0x66: |
| 63 | case 0x6b: |
| 64 | fm_info_set_phy_address(FM1_10GEC1, CORTINA_PHY_ADDR1); |
| 65 | fm_info_set_phy_address(FM1_10GEC2, CORTINA_PHY_ADDR2); |
| 66 | fm_info_set_phy_address(FM1_10GEC3, FM1_10GEC3_PHY_ADDR); |
| 67 | fm_info_set_phy_address(FM1_10GEC4, FM1_10GEC4_PHY_ADDR); |
| 68 | break; |
| 69 | default: |
| 70 | printf("SerDes1 protocol 0x%x is not supported on T208xRDB\n", |
| 71 | srds_s1); |
| 72 | break; |
| 73 | } |
| 74 | |
| 75 | for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) { |
| 76 | interface = fm_info_get_enet_if(i); |
| 77 | switch (interface) { |
| 78 | case PHY_INTERFACE_MODE_RGMII: |
| 79 | dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); |
| 80 | fm_info_set_mdio(i, dev); |
| 81 | break; |
| 82 | default: |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | for (i = FM1_10GEC1; i < FM1_10GEC1 + CONFIG_SYS_NUM_FM1_10GEC; i++) { |
| 88 | switch (fm_info_get_enet_if(i)) { |
| 89 | case PHY_INTERFACE_MODE_XGMII: |
| 90 | dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME); |
| 91 | fm_info_set_mdio(i, dev); |
| 92 | break; |
| 93 | default: |
| 94 | break; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | cpu_eth_init(bis); |
| 99 | #endif /* CONFIG_FMAN_ENET */ |
| 100 | |
| 101 | return pci_eth_init(bis); |
| 102 | } |
| 103 | |
| 104 | void fdt_fixup_board_enet(void *fdt) |
| 105 | { |
| 106 | return; |
| 107 | } |