Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * Chunhe Lan <Chunhe.Lan@freescale.com> |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 8 | #include <config.h> |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 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> |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 12 | #include <netdev.h> |
| 13 | #include <asm/mmu.h> |
| 14 | #include <asm/processor.h> |
| 15 | #include <asm/cache.h> |
| 16 | #include <asm/immap_85xx.h> |
| 17 | #include <asm/fsl_law.h> |
| 18 | #include <fsl_ddr_sdram.h> |
| 19 | #include <asm/fsl_serdes.h> |
| 20 | #include <asm/fsl_portals.h> |
| 21 | #include <asm/fsl_liodn.h> |
| 22 | #include <malloc.h> |
| 23 | #include <fm_eth.h> |
| 24 | #include <fsl_mdio.h> |
| 25 | #include <miiphy.h> |
| 26 | #include <phy.h> |
Shaohui Xie | 513eaf2 | 2015-10-26 19:47:47 +0800 | [diff] [blame] | 27 | #include <fsl_dtsec.h> |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 28 | #include <asm/fsl_serdes.h> |
| 29 | #include <hwconfig.h> |
| 30 | |
| 31 | #include "../common/fman.h" |
| 32 | #include "t4rdb.h" |
| 33 | |
| 34 | void fdt_fixup_board_enet(void *fdt) |
| 35 | { |
| 36 | return; |
| 37 | } |
| 38 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 39 | int board_eth_init(struct bd_info *bis) |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 40 | { |
| 41 | #if defined(CONFIG_FMAN_ENET) |
| 42 | int i, interface; |
| 43 | struct memac_mdio_info dtsec_mdio_info; |
| 44 | struct memac_mdio_info tgec_mdio_info; |
| 45 | struct mii_dev *dev; |
Tom Rini | d5c3bf2 | 2022-10-28 20:27:12 -0400 | [diff] [blame] | 46 | ccsr_gur_t *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR); |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 47 | u32 srds_prtcl_s1, srds_prtcl_s2; |
| 48 | |
| 49 | srds_prtcl_s1 = in_be32(&gur->rcwsr[4]) & |
| 50 | FSL_CORENET2_RCWSR4_SRDS1_PRTCL; |
| 51 | srds_prtcl_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT; |
| 52 | srds_prtcl_s2 = in_be32(&gur->rcwsr[4]) & |
| 53 | FSL_CORENET2_RCWSR4_SRDS2_PRTCL; |
| 54 | srds_prtcl_s2 >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT; |
| 55 | |
| 56 | dtsec_mdio_info.regs = |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 57 | (struct memac_mdio_controller *)CFG_SYS_FM2_DTSEC_MDIO_ADDR; |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 58 | |
| 59 | dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME; |
| 60 | |
| 61 | /* Register the 1G MDIO bus */ |
| 62 | fm_memac_mdio_init(bis, &dtsec_mdio_info); |
| 63 | |
| 64 | tgec_mdio_info.regs = |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 65 | (struct memac_mdio_controller *)CFG_SYS_FM2_TGEC_MDIO_ADDR; |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 66 | tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME; |
| 67 | |
| 68 | /* Register the 10G MDIO bus */ |
| 69 | fm_memac_mdio_init(bis, &tgec_mdio_info); |
| 70 | |
Chunhe Lan | c3d5f0a | 2014-05-20 13:34:28 +0800 | [diff] [blame] | 71 | if ((srds_prtcl_s1 == 28) || (srds_prtcl_s1 == 27)) { |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 72 | /* SGMII */ |
| 73 | fm_info_set_phy_address(FM1_DTSEC1, SGMII_PHY_ADDR1); |
| 74 | fm_info_set_phy_address(FM1_DTSEC2, SGMII_PHY_ADDR2); |
| 75 | fm_info_set_phy_address(FM1_DTSEC3, SGMII_PHY_ADDR3); |
| 76 | fm_info_set_phy_address(FM1_DTSEC4, SGMII_PHY_ADDR4); |
| 77 | } else { |
| 78 | puts("Invalid SerDes1 protocol for T4240RDB\n"); |
| 79 | } |
| 80 | |
Ying Zhang | d942ab7 | 2016-04-21 14:23:46 +0800 | [diff] [blame] | 81 | fm_disable_port(FM1_DTSEC5); |
| 82 | fm_disable_port(FM1_DTSEC6); |
| 83 | |
Tom Rini | 0a2bac7 | 2022-11-16 13:10:29 -0500 | [diff] [blame] | 84 | for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CFG_SYS_NUM_FM1_DTSEC; i++) { |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 85 | interface = fm_info_get_enet_if(i); |
| 86 | switch (interface) { |
| 87 | case PHY_INTERFACE_MODE_SGMII: |
| 88 | dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); |
| 89 | fm_info_set_mdio(i, dev); |
| 90 | break; |
| 91 | default: |
| 92 | break; |
| 93 | } |
| 94 | } |
| 95 | |
Tom Rini | 0a2bac7 | 2022-11-16 13:10:29 -0500 | [diff] [blame] | 96 | for (i = FM1_10GEC1; i < FM1_10GEC1 + CFG_SYS_NUM_FM1_10GEC; i++) { |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 97 | switch (fm_info_get_enet_if(i)) { |
| 98 | case PHY_INTERFACE_MODE_XGMII: |
| 99 | dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME); |
| 100 | fm_info_set_mdio(i, dev); |
| 101 | break; |
| 102 | default: |
| 103 | break; |
| 104 | } |
| 105 | } |
| 106 | |
Tom Rini | 0a2bac7 | 2022-11-16 13:10:29 -0500 | [diff] [blame] | 107 | #if (CFG_SYS_NUM_FMAN == 2) |
Chunhe Lan | c0d5227 | 2014-12-10 20:00:39 +0800 | [diff] [blame] | 108 | if ((srds_prtcl_s2 == 56) || (srds_prtcl_s2 == 55)) { |
Vladimir Oltean | 6a6e402 | 2021-09-18 15:32:34 +0300 | [diff] [blame] | 109 | /* SGMII && 10GBase-R */ |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 110 | fm_info_set_phy_address(FM2_DTSEC1, SGMII_PHY_ADDR5); |
| 111 | fm_info_set_phy_address(FM2_DTSEC2, SGMII_PHY_ADDR6); |
| 112 | fm_info_set_phy_address(FM2_DTSEC3, SGMII_PHY_ADDR7); |
| 113 | fm_info_set_phy_address(FM2_DTSEC4, SGMII_PHY_ADDR8); |
| 114 | fm_info_set_phy_address(FM1_10GEC1, FM1_10GEC1_PHY_ADDR); |
| 115 | fm_info_set_phy_address(FM1_10GEC2, FM1_10GEC2_PHY_ADDR); |
| 116 | fm_info_set_phy_address(FM2_10GEC1, FM2_10GEC2_PHY_ADDR); |
| 117 | fm_info_set_phy_address(FM2_10GEC2, FM2_10GEC1_PHY_ADDR); |
| 118 | } else { |
| 119 | puts("Invalid SerDes2 protocol for T4240RDB\n"); |
| 120 | } |
| 121 | |
Ying Zhang | d942ab7 | 2016-04-21 14:23:46 +0800 | [diff] [blame] | 122 | fm_disable_port(FM2_DTSEC5); |
| 123 | fm_disable_port(FM2_DTSEC6); |
Tom Rini | 0a2bac7 | 2022-11-16 13:10:29 -0500 | [diff] [blame] | 124 | for (i = FM2_DTSEC1; i < FM2_DTSEC1 + CFG_SYS_NUM_FM2_DTSEC; i++) { |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 125 | interface = fm_info_get_enet_if(i); |
| 126 | switch (interface) { |
| 127 | case PHY_INTERFACE_MODE_SGMII: |
| 128 | dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); |
| 129 | fm_info_set_mdio(i, dev); |
| 130 | break; |
| 131 | default: |
| 132 | break; |
| 133 | } |
| 134 | } |
| 135 | |
Tom Rini | 0a2bac7 | 2022-11-16 13:10:29 -0500 | [diff] [blame] | 136 | for (i = FM2_10GEC1; i < FM2_10GEC1 + CFG_SYS_NUM_FM2_10GEC; i++) { |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 137 | switch (fm_info_get_enet_if(i)) { |
| 138 | case PHY_INTERFACE_MODE_XGMII: |
| 139 | dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME); |
| 140 | fm_info_set_mdio(i, dev); |
| 141 | break; |
| 142 | default: |
| 143 | break; |
| 144 | } |
| 145 | } |
Tom Rini | 0a2bac7 | 2022-11-16 13:10:29 -0500 | [diff] [blame] | 146 | #endif /* CFG_SYS_NUM_FMAN */ |
Chunhe Lan | 8e4f3ff | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 147 | |
| 148 | cpu_eth_init(bis); |
| 149 | #endif /* CONFIG_FMAN_ENET */ |
| 150 | |
| 151 | return pci_eth_init(bis); |
| 152 | } |