blob: 018d1dc6720c6ecc4bacb2cf6a879aa454271705 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +05302/*
3 * Copyright 2015 Freescale Semiconductor, Inc.
4 *
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +05305 */
6
7#include <common.h>
8#include <command.h>
Simon Glass0c364412019-12-28 10:44:48 -07009#include <net.h>
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053010#include <netdev.h>
11#include <malloc.h>
12#include <fsl_mdio.h>
13#include <miiphy.h>
14#include <phy.h>
15#include <fm_eth.h>
16#include <asm/io.h>
Prabhakar Kushwaha7b3a6bc2015-06-28 11:03:59 +053017#include <exports.h>
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053018#include <asm/arch/fsl_serdes.h>
Bogdan Purcareata08bc0142017-05-24 16:40:21 +000019#include <fsl-mc/fsl_mc.h>
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053020#include <fsl-mc/ldpaa_wriop.h>
21
Prabhakar Kushwaha7b3a6bc2015-06-28 11:03:59 +053022DECLARE_GLOBAL_DATA_PTR;
23
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090024int board_eth_init(struct bd_info *bis)
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053025{
Ioana Ciorneicfa114a2020-03-18 16:47:40 +020026#ifndef CONFIG_DM_ETH
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053027#if defined(CONFIG_FSL_MC_ENET)
28 int i, interface;
29 struct memac_mdio_info mdio_info;
30 struct mii_dev *dev;
31 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
32 u32 srds_s1;
33 struct memac_mdio_controller *reg;
34
35 srds_s1 = in_le32(&gur->rcwsr[28]) &
36 FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK;
37 srds_s1 >>= FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
38
39 reg = (struct memac_mdio_controller *)CONFIG_SYS_FSL_WRIOP1_MDIO1;
40 mdio_info.regs = reg;
41 mdio_info.name = DEFAULT_WRIOP_MDIO1_NAME;
42
43 /* Register the EMI 1 */
44 fm_memac_mdio_init(bis, &mdio_info);
45
46 reg = (struct memac_mdio_controller *)CONFIG_SYS_FSL_WRIOP1_MDIO2;
47 mdio_info.regs = reg;
48 mdio_info.name = DEFAULT_WRIOP_MDIO2_NAME;
49
50 /* Register the EMI 2 */
51 fm_memac_mdio_init(bis, &mdio_info);
52
53 switch (srds_s1) {
54 case 0x2A:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +053055 wriop_set_phy_address(WRIOP1_DPMAC1, 0, CORTINA_PHY_ADDR1);
56 wriop_set_phy_address(WRIOP1_DPMAC2, 0, CORTINA_PHY_ADDR2);
57 wriop_set_phy_address(WRIOP1_DPMAC3, 0, CORTINA_PHY_ADDR3);
58 wriop_set_phy_address(WRIOP1_DPMAC4, 0, CORTINA_PHY_ADDR4);
59 wriop_set_phy_address(WRIOP1_DPMAC5, 0, AQ_PHY_ADDR1);
60 wriop_set_phy_address(WRIOP1_DPMAC6, 0, AQ_PHY_ADDR2);
61 wriop_set_phy_address(WRIOP1_DPMAC7, 0, AQ_PHY_ADDR3);
62 wriop_set_phy_address(WRIOP1_DPMAC8, 0, AQ_PHY_ADDR4);
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053063
64 break;
Santan Kumarff138e52017-04-13 15:31:09 +053065 case 0x4B:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +053066 wriop_set_phy_address(WRIOP1_DPMAC1, 0, CORTINA_PHY_ADDR1);
67 wriop_set_phy_address(WRIOP1_DPMAC2, 0, CORTINA_PHY_ADDR2);
68 wriop_set_phy_address(WRIOP1_DPMAC3, 0, CORTINA_PHY_ADDR3);
69 wriop_set_phy_address(WRIOP1_DPMAC4, 0, CORTINA_PHY_ADDR4);
Santan Kumarff138e52017-04-13 15:31:09 +053070
71 break;
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053072 default:
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +053073 printf("SerDes1 protocol 0x%x is not supported on LS2080aRDB\n",
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053074 srds_s1);
75 break;
76 }
77
78 for (i = WRIOP1_DPMAC1; i <= WRIOP1_DPMAC4; i++) {
79 interface = wriop_get_enet_if(i);
80 switch (interface) {
81 case PHY_INTERFACE_MODE_XGMII:
82 dev = miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO1_NAME);
83 wriop_set_mdio(i, dev);
84 break;
85 default:
86 break;
87 }
88 }
89
90 for (i = WRIOP1_DPMAC5; i <= WRIOP1_DPMAC8; i++) {
91 switch (wriop_get_enet_if(i)) {
92 case PHY_INTERFACE_MODE_XGMII:
93 dev = miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO2_NAME);
94 wriop_set_mdio(i, dev);
95 break;
96 default:
97 break;
98 }
99 }
100
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +0530101 cpu_eth_init(bis);
Bogdan Purcareata08bc0142017-05-24 16:40:21 +0000102#endif /* CONFIG_FSL_MC_ENET */
Ioana Ciorneicfa114a2020-03-18 16:47:40 +0200103#endif /* !CONFIG_DM_ETH */
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +0530104
Prabhakar Kushwaha7b3a6bc2015-06-28 11:03:59 +0530105#ifdef CONFIG_PHY_AQUANTIA
106 /*
107 * Export functions to be used by AQ firmware
108 * upload application
109 */
110 gd->jt->strcpy = strcpy;
111 gd->jt->mdelay = mdelay;
112 gd->jt->mdio_get_current_dev = mdio_get_current_dev;
113 gd->jt->phy_find_by_mask = phy_find_by_mask;
114 gd->jt->mdio_phydev_for_ethname = mdio_phydev_for_ethname;
115 gd->jt->miiphy_set_current_dev = miiphy_set_current_dev;
116#endif
Ioana Ciorneicfa114a2020-03-18 16:47:40 +0200117
118#ifdef CONFIG_DM_ETH
119 return 0;
120#else
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +0530121 return pci_eth_init(bis);
Ioana Ciorneicfa114a2020-03-18 16:47:40 +0200122#endif
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +0530123}
Bogdan Purcareata08bc0142017-05-24 16:40:21 +0000124
125#if defined(CONFIG_RESET_PHY_R)
126void reset_phy(void)
127{
128 mc_env_boot();
129}
130#endif /* CONFIG_RESET_PHY_R */