blob: 62c7a7a315502c4328a88a58a63e8298cd2d3af3 [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>
9#include <netdev.h>
10#include <malloc.h>
11#include <fsl_mdio.h>
12#include <miiphy.h>
13#include <phy.h>
14#include <fm_eth.h>
15#include <asm/io.h>
Prabhakar Kushwaha7b3a6bc2015-06-28 11:03:59 +053016#include <exports.h>
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053017#include <asm/arch/fsl_serdes.h>
Bogdan Purcareata08bc0142017-05-24 16:40:21 +000018#include <fsl-mc/fsl_mc.h>
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053019#include <fsl-mc/ldpaa_wriop.h>
20
Prabhakar Kushwaha7b3a6bc2015-06-28 11:03:59 +053021DECLARE_GLOBAL_DATA_PTR;
22
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053023int board_eth_init(bd_t *bis)
24{
25#if defined(CONFIG_FSL_MC_ENET)
26 int i, interface;
27 struct memac_mdio_info mdio_info;
28 struct mii_dev *dev;
29 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
30 u32 srds_s1;
31 struct memac_mdio_controller *reg;
32
33 srds_s1 = in_le32(&gur->rcwsr[28]) &
34 FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK;
35 srds_s1 >>= FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
36
37 reg = (struct memac_mdio_controller *)CONFIG_SYS_FSL_WRIOP1_MDIO1;
38 mdio_info.regs = reg;
39 mdio_info.name = DEFAULT_WRIOP_MDIO1_NAME;
40
41 /* Register the EMI 1 */
42 fm_memac_mdio_init(bis, &mdio_info);
43
44 reg = (struct memac_mdio_controller *)CONFIG_SYS_FSL_WRIOP1_MDIO2;
45 mdio_info.regs = reg;
46 mdio_info.name = DEFAULT_WRIOP_MDIO2_NAME;
47
48 /* Register the EMI 2 */
49 fm_memac_mdio_init(bis, &mdio_info);
50
51 switch (srds_s1) {
52 case 0x2A:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +053053 wriop_set_phy_address(WRIOP1_DPMAC1, 0, CORTINA_PHY_ADDR1);
54 wriop_set_phy_address(WRIOP1_DPMAC2, 0, CORTINA_PHY_ADDR2);
55 wriop_set_phy_address(WRIOP1_DPMAC3, 0, CORTINA_PHY_ADDR3);
56 wriop_set_phy_address(WRIOP1_DPMAC4, 0, CORTINA_PHY_ADDR4);
57 wriop_set_phy_address(WRIOP1_DPMAC5, 0, AQ_PHY_ADDR1);
58 wriop_set_phy_address(WRIOP1_DPMAC6, 0, AQ_PHY_ADDR2);
59 wriop_set_phy_address(WRIOP1_DPMAC7, 0, AQ_PHY_ADDR3);
60 wriop_set_phy_address(WRIOP1_DPMAC8, 0, AQ_PHY_ADDR4);
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053061
62 break;
Santan Kumarff138e52017-04-13 15:31:09 +053063 case 0x4B:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +053064 wriop_set_phy_address(WRIOP1_DPMAC1, 0, CORTINA_PHY_ADDR1);
65 wriop_set_phy_address(WRIOP1_DPMAC2, 0, CORTINA_PHY_ADDR2);
66 wriop_set_phy_address(WRIOP1_DPMAC3, 0, CORTINA_PHY_ADDR3);
67 wriop_set_phy_address(WRIOP1_DPMAC4, 0, CORTINA_PHY_ADDR4);
Santan Kumarff138e52017-04-13 15:31:09 +053068
69 break;
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053070 default:
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +053071 printf("SerDes1 protocol 0x%x is not supported on LS2080aRDB\n",
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053072 srds_s1);
73 break;
74 }
75
76 for (i = WRIOP1_DPMAC1; i <= WRIOP1_DPMAC4; i++) {
77 interface = wriop_get_enet_if(i);
78 switch (interface) {
79 case PHY_INTERFACE_MODE_XGMII:
80 dev = miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO1_NAME);
81 wriop_set_mdio(i, dev);
82 break;
83 default:
84 break;
85 }
86 }
87
88 for (i = WRIOP1_DPMAC5; i <= WRIOP1_DPMAC8; i++) {
89 switch (wriop_get_enet_if(i)) {
90 case PHY_INTERFACE_MODE_XGMII:
91 dev = miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO2_NAME);
92 wriop_set_mdio(i, dev);
93 break;
94 default:
95 break;
96 }
97 }
98
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +053099 cpu_eth_init(bis);
Bogdan Purcareata08bc0142017-05-24 16:40:21 +0000100#endif /* CONFIG_FSL_MC_ENET */
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +0530101
Prabhakar Kushwaha7b3a6bc2015-06-28 11:03:59 +0530102#ifdef CONFIG_PHY_AQUANTIA
103 /*
104 * Export functions to be used by AQ firmware
105 * upload application
106 */
107 gd->jt->strcpy = strcpy;
108 gd->jt->mdelay = mdelay;
109 gd->jt->mdio_get_current_dev = mdio_get_current_dev;
110 gd->jt->phy_find_by_mask = phy_find_by_mask;
111 gd->jt->mdio_phydev_for_ethname = mdio_phydev_for_ethname;
112 gd->jt->miiphy_set_current_dev = miiphy_set_current_dev;
113#endif
Prabhakar Kushwahab0b41892015-05-28 14:53:54 +0530114 return pci_eth_init(bis);
115}
Bogdan Purcareata08bc0142017-05-24 16:40:21 +0000116
117#if defined(CONFIG_RESET_PHY_R)
118void reset_phy(void)
119{
120 mc_env_boot();
121}
122#endif /* CONFIG_RESET_PHY_R */