blob: b0ff4b1f375a9d53ccdfd0a622589c71daa5311c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Shengzhou Liuf13321d2014-03-05 15:04:48 +08002/*
3 * Copyright 2014 Freescale Semiconductor, Inc.
Camelia Groza6994f3a2021-04-13 19:47:57 +03004 * Copyright 2021 NXP
Shengzhou Liuf13321d2014-03-05 15:04:48 +08005 *
6 * Shengzhou Liu <Shengzhou.Liu@freescale.com>
Shengzhou Liuf13321d2014-03-05 15:04:48 +08007 */
8
9#include <common.h>
10#include <command.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060011#include <fdt_support.h>
Simon Glass274e0b02020-05-10 11:39:56 -060012#include <net.h>
Shengzhou Liuf13321d2014-03-05 15:04:48 +080013#include <netdev.h>
14#include <asm/mmu.h>
15#include <asm/processor.h>
16#include <asm/immap_85xx.h>
17#include <asm/fsl_law.h>
18#include <asm/fsl_serdes.h>
19#include <asm/fsl_portals.h>
20#include <asm/fsl_liodn.h>
21#include <malloc.h>
22#include <fm_eth.h>
23#include <fsl_mdio.h>
24#include <miiphy.h>
25#include <phy.h>
Shaohui Xie513eaf22015-10-26 19:47:47 +080026#include <fsl_dtsec.h>
Shengzhou Liuf13321d2014-03-05 15:04:48 +080027#include <asm/fsl_serdes.h>
28
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090029int board_eth_init(struct bd_info *bis)
Shengzhou Liuf13321d2014-03-05 15:04:48 +080030{
31#if defined(CONFIG_FMAN_ENET)
32 int i, interface;
33 struct memac_mdio_info dtsec_mdio_info;
34 struct memac_mdio_info tgec_mdio_info;
35 struct mii_dev *dev;
36 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
37 u32 srds_s1;
38
39 srds_s1 = in_be32(&gur->rcwsr[4]) &
40 FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
41 srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
42
43 dtsec_mdio_info.regs =
44 (struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR;
45
46 dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
47
48 /* Register the 1G MDIO bus */
49 fm_memac_mdio_init(bis, &dtsec_mdio_info);
50
51 tgec_mdio_info.regs =
52 (struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR;
53 tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
54
55 /* Register the 10G MDIO bus */
56 fm_memac_mdio_init(bis, &tgec_mdio_info);
57
58 /* Set the two on-board RGMII PHY address */
59 fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY1_ADDR);
60 fm_info_set_phy_address(FM1_DTSEC4, RGMII_PHY2_ADDR);
61
62 switch (srds_s1) {
63 case 0x66:
64 case 0x6b:
65 fm_info_set_phy_address(FM1_10GEC1, CORTINA_PHY_ADDR1);
66 fm_info_set_phy_address(FM1_10GEC2, CORTINA_PHY_ADDR2);
67 fm_info_set_phy_address(FM1_10GEC3, FM1_10GEC3_PHY_ADDR);
68 fm_info_set_phy_address(FM1_10GEC4, FM1_10GEC4_PHY_ADDR);
69 break;
70 default:
71 printf("SerDes1 protocol 0x%x is not supported on T208xRDB\n",
72 srds_s1);
73 break;
74 }
75
76 for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
77 interface = fm_info_get_enet_if(i);
78 switch (interface) {
79 case PHY_INTERFACE_MODE_RGMII:
Madalin Bucur03b80152020-11-04 15:09:17 +020080 case PHY_INTERFACE_MODE_RGMII_TXID:
81 case PHY_INTERFACE_MODE_RGMII_RXID:
82 case PHY_INTERFACE_MODE_RGMII_ID:
Shengzhou Liuf13321d2014-03-05 15:04:48 +080083 dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
84 fm_info_set_mdio(i, dev);
85 break;
86 default:
87 break;
88 }
89 }
90
91 for (i = FM1_10GEC1; i < FM1_10GEC1 + CONFIG_SYS_NUM_FM1_10GEC; i++) {
92 switch (fm_info_get_enet_if(i)) {
93 case PHY_INTERFACE_MODE_XGMII:
94 dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME);
95 fm_info_set_mdio(i, dev);
96 break;
97 default:
98 break;
99 }
100 }
101
102 cpu_eth_init(bis);
103#endif /* CONFIG_FMAN_ENET */
104
105 return pci_eth_init(bis);
106}
107
Camelia Groza6994f3a2021-04-13 19:47:57 +0300108/* Disable the MAC5 and MAC6 "fsl,fman-memac" nodes and the two
109 * "fsl,dpa-ethernet" nodes that reference them.
110 */
111void fdt_fixup_board_fman_ethernet(void *fdt)
112{
113 int mac_off, eth_off, i;
114 char mac_path[2][42] = {
115 "/soc@ffe000000/fman@400000/ethernet@e8000",
116 "/soc@ffe000000/fman@400000/ethernet@ea000",
117 };
118 u32 eth_ph;
119
120 for (i = 0; i < 2; i++) {
121 /* Disable the MAC node */
122 mac_off = fdt_path_offset(fdt, mac_path[i]);
123 if (mac_off < 0)
124 continue;
125 fdt_status_disabled(fdt, mac_off);
126
127 /* Disable the fsl,dpa-ethernet node that points to the MAC.
128 * The fsl,fman-mac property refers to the MAC's phandle.
129 */
130 eth_ph = fdt_get_phandle(fdt, mac_off);
131 if (eth_ph <= 0)
132 continue;
133
134 eth_off = fdt_node_offset_by_prop_value(fdt, -1, "fsl,fman-mac",
135 &eth_ph,
136 sizeof(eth_ph));
137 if (eth_off >= 0)
138 fdt_status_disabled(fdt, eth_off);
139 }
140}
141
Shengzhou Liuf13321d2014-03-05 15:04:48 +0800142void fdt_fixup_board_enet(void *fdt)
143{
144 return;
145}