1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2018-2020 NXP
7 #include <asm/global_data.h>
10 #include <fsl-mc/fsl_mc.h>
12 DECLARE_GLOBAL_DATA_PTR;
14 int board_eth_init(struct bd_info *bis)
16 #ifdef CONFIG_PHY_AQUANTIA
18 * Export functions to be used by AQ firmware
21 gd->jt->strcpy = strcpy;
22 gd->jt->mdelay = mdelay;
23 gd->jt->mdio_get_current_dev = mdio_get_current_dev;
24 gd->jt->phy_find_by_mask = phy_find_by_mask;
25 gd->jt->mdio_phydev_for_ethname = mdio_phydev_for_ethname;
26 gd->jt->miiphy_set_current_dev = miiphy_set_current_dev;
32 #if defined(CONFIG_RESET_PHY_R)
35 #if defined(CONFIG_FSL_MC_ENET)
39 #endif /* CONFIG_RESET_PHY_R */
41 #if defined(CONFIG_MULTI_DTB_FIT)
43 /* Structure to hold SERDES protocols supported (network interfaces are
44 * described in the DTS).
46 * @serdes_block: the index of the SERDES block
47 * @serdes_protocol: the decimal value of the protocol supported
48 * @dts_needed: DTS notes describing the current configuration are needed
50 * When dts_needed is true, the board_fit_config_name_match() function
51 * will try to exactly match the current configuration of the block with a DTS
54 static struct serdes_configuration {
58 } supported_protocols[] = {
76 #define SUPPORTED_SERDES_PROTOCOLS ARRAY_SIZE(supported_protocols)
78 static bool protocol_supported(u8 serdes_block, u32 protocol)
80 struct serdes_configuration serdes_conf;
83 for (i = 0; i < SUPPORTED_SERDES_PROTOCOLS; i++) {
84 serdes_conf = supported_protocols[i];
85 if (serdes_conf.serdes_block == serdes_block &&
86 serdes_conf.serdes_protocol == protocol)
93 static void get_str_protocol(u8 serdes_block, u32 protocol, char *str)
95 struct serdes_configuration serdes_conf;
98 for (i = 0; i < SUPPORTED_SERDES_PROTOCOLS; i++) {
99 serdes_conf = supported_protocols[i];
100 if (serdes_conf.serdes_block == serdes_block &&
101 serdes_conf.serdes_protocol == protocol) {
102 if (serdes_conf.dts_needed == true)
103 sprintf(str, "%u", protocol);
111 int board_fit_config_name_match(const char *name)
113 struct ccsr_gur *gur = (void *)(CFG_SYS_FSL_GUTS_ADDR);
114 u32 rcw_status = in_le32(&gur->rcwsr[28]);
115 char srds_s1_str[2], srds_s2_str[2], srds_s3_str[2];
116 u32 srds_s1, srds_s2, srds_s3;
117 char expected_dts[100];
119 srds_s1 = rcw_status & FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK;
120 srds_s1 >>= FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
122 srds_s2 = rcw_status & FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_MASK;
123 srds_s2 >>= FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
125 srds_s3 = rcw_status & FSL_CHASSIS3_RCWSR28_SRDS3_PRTCL_MASK;
126 srds_s3 >>= FSL_CHASSIS3_RCWSR28_SRDS3_PRTCL_SHIFT;
128 /* Check for supported protocols. The default DTS will be used
131 if (!protocol_supported(1, srds_s1) ||
132 !protocol_supported(2, srds_s2) ||
133 !protocol_supported(3, srds_s3))
136 get_str_protocol(1, srds_s1, srds_s1_str);
137 get_str_protocol(2, srds_s2, srds_s2_str);
138 get_str_protocol(3, srds_s3, srds_s3_str);
140 sprintf(expected_dts, "fsl-lx2160a-qds-%s-%s-%s",
141 srds_s1_str, srds_s2_str, srds_s3_str);
143 if (!strcmp(name, expected_dts))