blob: 5eca9386f6eb38c41e06713d84dd00341e2c300b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Priyanka Jain29b426b2014-01-30 11:30:04 +05302/*
3 * Copyright 2014 Freescale Semiconductor, Inc.
Priyanka Jain29b426b2014-01-30 11:30:04 +05304 */
5
6#include <common.h>
Simon Glass274e0b02020-05-10 11:39:56 -06007#include <net.h>
Priyanka Jain29b426b2014-01-30 11:30:04 +05308#include <netdev.h>
Codrin Ciubotariub29e5e22015-01-21 11:54:12 +02009#include <asm/fsl_serdes.h>
Priyanka Jain29b426b2014-01-30 11:30:04 +053010#include <asm/immap_85xx.h>
11#include <fm_eth.h>
12#include <fsl_mdio.h>
13#include <malloc.h>
Shaohui Xie513eaf22015-10-26 19:47:47 +080014#include <fsl_dtsec.h>
Codrin Ciubotariub29e5e22015-01-21 11:54:12 +020015#include <vsc9953.h>
Priyanka Jain29b426b2014-01-30 11:30:04 +053016
17#include "../common/fman.h"
18
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090019int board_eth_init(struct bd_info *bis)
Priyanka Jain29b426b2014-01-30 11:30:04 +053020{
21#ifdef CONFIG_FMAN_ENET
22 struct memac_mdio_info memac_mdio_info;
23 unsigned int i;
24 int phy_addr = 0;
Codrin Ciubotariub29e5e22015-01-21 11:54:12 +020025
Priyanka Jain29b426b2014-01-30 11:30:04 +053026 printf("Initializing Fman\n");
27
28 memac_mdio_info.regs =
Tom Rini364d0022023-01-10 11:19:45 -050029 (struct memac_mdio_controller *)CFG_SYS_FM1_DTSEC_MDIO_ADDR;
Priyanka Jain29b426b2014-01-30 11:30:04 +053030 memac_mdio_info.name = DEFAULT_FM_MDIO_NAME;
31
32 /* Register the real 1G MDIO bus */
33 fm_memac_mdio_init(bis, &memac_mdio_info);
34
35 /*
36 * Program on board RGMII, SGMII PHY addresses.
37 */
Tom Rini0a2bac72022-11-16 13:10:29 -050038 for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CFG_SYS_NUM_FM1_DTSEC; i++) {
Priyanka Jain29b426b2014-01-30 11:30:04 +053039 int idx = i - FM1_DTSEC1;
40
41 switch (fm_info_get_enet_if(i)) {
York Sund08610d2016-11-21 11:04:34 -080042#ifdef CONFIG_TARGET_T1042D4RDB
Priyanka Jaine7597fe2015-06-05 15:29:02 +053043 case PHY_INTERFACE_MODE_SGMII:
44 /* T1042D4RDB supports SGMII on DTSEC1, DTSEC2
45 * & DTSEC3
46 */
47 if (FM1_DTSEC1 == i)
Tom Rini6a5dccc2022-11-16 13:10:41 -050048 phy_addr = CFG_SYS_SGMII1_PHY_ADDR;
Priyanka Jaine7597fe2015-06-05 15:29:02 +053049 if (FM1_DTSEC2 == i)
Tom Rini6a5dccc2022-11-16 13:10:41 -050050 phy_addr = CFG_SYS_SGMII2_PHY_ADDR;
Priyanka Jaine7597fe2015-06-05 15:29:02 +053051 if (FM1_DTSEC3 == i)
Tom Rini6a5dccc2022-11-16 13:10:41 -050052 phy_addr = CFG_SYS_SGMII3_PHY_ADDR;
Priyanka Jaine7597fe2015-06-05 15:29:02 +053053 fm_info_set_phy_address(i, phy_addr);
54 break;
55#endif
Priyanka Jain29b426b2014-01-30 11:30:04 +053056 case PHY_INTERFACE_MODE_RGMII:
Madalin Bucur03b80152020-11-04 15:09:17 +020057 case PHY_INTERFACE_MODE_RGMII_TXID:
58 case PHY_INTERFACE_MODE_RGMII_RXID:
59 case PHY_INTERFACE_MODE_RGMII_ID:
Priyanka Jain29b426b2014-01-30 11:30:04 +053060 if (FM1_DTSEC4 == i)
Tom Rini6a5dccc2022-11-16 13:10:41 -050061 phy_addr = CFG_SYS_RGMII1_PHY_ADDR;
Priyanka Jain29b426b2014-01-30 11:30:04 +053062 if (FM1_DTSEC5 == i)
Tom Rini6a5dccc2022-11-16 13:10:41 -050063 phy_addr = CFG_SYS_RGMII2_PHY_ADDR;
Priyanka Jain29b426b2014-01-30 11:30:04 +053064 fm_info_set_phy_address(i, phy_addr);
65 break;
66 case PHY_INTERFACE_MODE_QSGMII:
67 fm_info_set_phy_address(i, 0);
68 break;
Marek BehĂșn48631e42022-04-07 00:33:03 +020069 case PHY_INTERFACE_MODE_NA:
Priyanka Jain29b426b2014-01-30 11:30:04 +053070 fm_info_set_phy_address(i, 0);
71 break;
72 default:
73 printf("Fman1: DTSEC%u set to unknown interface %i\n",
74 idx + 1, fm_info_get_enet_if(i));
75 fm_info_set_phy_address(i, 0);
76 break;
77 }
Codrin Ciubotariu3df7b7a2015-01-12 14:08:37 +020078 if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_QSGMII ||
Marek BehĂșn48631e42022-04-07 00:33:03 +020079 fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NA)
Codrin Ciubotariu3df7b7a2015-01-12 14:08:37 +020080 fm_info_set_mdio(i, NULL);
81 else
82 fm_info_set_mdio(i,
83 miiphy_get_dev_by_name(
84 DEFAULT_FM_MDIO_NAME));
Priyanka Jain29b426b2014-01-30 11:30:04 +053085 }
86
Codrin Ciubotariub29e5e22015-01-21 11:54:12 +020087
Priyanka Jain29b426b2014-01-30 11:30:04 +053088 cpu_eth_init(bis);
89#endif
90
91 return pci_eth_init(bis);
92}