Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 1 | /* |
Shaohui Xie | e829734 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 2 | * Copyright 2011-2015 Freescale Semiconductor, Inc. |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 5 | */ |
Igal Liberman | 97a8d01 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 6 | #include <errno.h> |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
Simon Glass | 73223f0 | 2016-02-22 22:55:43 -0700 | [diff] [blame] | 9 | #include <fdt_support.h> |
Claudiu Manoil | 93f26f1 | 2014-09-05 13:52:36 +0800 | [diff] [blame] | 10 | #include <fsl_mdio.h> |
Shaohui Xie | e829734 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 11 | #ifdef CONFIG_FSL_LAYERSCAPE |
| 12 | #include <asm/arch/fsl_serdes.h> |
| 13 | #else |
| 14 | #include <asm/fsl_serdes.h> |
| 15 | #endif |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 16 | |
| 17 | #include "fm.h" |
| 18 | |
| 19 | struct fm_eth_info fm_info[] = { |
| 20 | #if (CONFIG_SYS_NUM_FM1_DTSEC >= 1) |
| 21 | FM_DTSEC_INFO_INITIALIZER(1, 1), |
| 22 | #endif |
| 23 | #if (CONFIG_SYS_NUM_FM1_DTSEC >= 2) |
| 24 | FM_DTSEC_INFO_INITIALIZER(1, 2), |
| 25 | #endif |
| 26 | #if (CONFIG_SYS_NUM_FM1_DTSEC >= 3) |
| 27 | FM_DTSEC_INFO_INITIALIZER(1, 3), |
| 28 | #endif |
| 29 | #if (CONFIG_SYS_NUM_FM1_DTSEC >= 4) |
| 30 | FM_DTSEC_INFO_INITIALIZER(1, 4), |
| 31 | #endif |
| 32 | #if (CONFIG_SYS_NUM_FM1_DTSEC >= 5) |
| 33 | FM_DTSEC_INFO_INITIALIZER(1, 5), |
| 34 | #endif |
York Sun | 9e75875 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 35 | #if (CONFIG_SYS_NUM_FM1_DTSEC >= 6) |
| 36 | FM_DTSEC_INFO_INITIALIZER(1, 6), |
| 37 | #endif |
| 38 | #if (CONFIG_SYS_NUM_FM1_DTSEC >= 7) |
| 39 | FM_DTSEC_INFO_INITIALIZER(1, 9), |
| 40 | #endif |
| 41 | #if (CONFIG_SYS_NUM_FM1_DTSEC >= 8) |
| 42 | FM_DTSEC_INFO_INITIALIZER(1, 10), |
| 43 | #endif |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 44 | #if (CONFIG_SYS_NUM_FM2_DTSEC >= 1) |
| 45 | FM_DTSEC_INFO_INITIALIZER(2, 1), |
| 46 | #endif |
| 47 | #if (CONFIG_SYS_NUM_FM2_DTSEC >= 2) |
| 48 | FM_DTSEC_INFO_INITIALIZER(2, 2), |
| 49 | #endif |
| 50 | #if (CONFIG_SYS_NUM_FM2_DTSEC >= 3) |
| 51 | FM_DTSEC_INFO_INITIALIZER(2, 3), |
| 52 | #endif |
| 53 | #if (CONFIG_SYS_NUM_FM2_DTSEC >= 4) |
| 54 | FM_DTSEC_INFO_INITIALIZER(2, 4), |
| 55 | #endif |
Timur Tabi | 99abf7d | 2012-08-14 06:47:21 +0000 | [diff] [blame] | 56 | #if (CONFIG_SYS_NUM_FM2_DTSEC >= 5) |
| 57 | FM_DTSEC_INFO_INITIALIZER(2, 5), |
| 58 | #endif |
York Sun | 9e75875 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 59 | #if (CONFIG_SYS_NUM_FM2_DTSEC >= 6) |
| 60 | FM_DTSEC_INFO_INITIALIZER(2, 6), |
| 61 | #endif |
| 62 | #if (CONFIG_SYS_NUM_FM2_DTSEC >= 7) |
| 63 | FM_DTSEC_INFO_INITIALIZER(2, 9), |
| 64 | #endif |
| 65 | #if (CONFIG_SYS_NUM_FM2_DTSEC >= 8) |
| 66 | FM_DTSEC_INFO_INITIALIZER(2, 10), |
| 67 | #endif |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 68 | #if (CONFIG_SYS_NUM_FM1_10GEC >= 1) |
| 69 | FM_TGEC_INFO_INITIALIZER(1, 1), |
| 70 | #endif |
Shaohui Xie | 944b6cc | 2013-03-25 07:33:17 +0000 | [diff] [blame] | 71 | #if (CONFIG_SYS_NUM_FM1_10GEC >= 2) |
| 72 | FM_TGEC_INFO_INITIALIZER(1, 2), |
| 73 | #endif |
Shengzhou Liu | 82a55c1 | 2013-11-22 17:39:09 +0800 | [diff] [blame] | 74 | #if (CONFIG_SYS_NUM_FM1_10GEC >= 3) |
| 75 | FM_TGEC_INFO_INITIALIZER2(1, 3), |
| 76 | #endif |
| 77 | #if (CONFIG_SYS_NUM_FM1_10GEC >= 4) |
| 78 | FM_TGEC_INFO_INITIALIZER2(1, 4), |
| 79 | #endif |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 80 | #if (CONFIG_SYS_NUM_FM2_10GEC >= 1) |
| 81 | FM_TGEC_INFO_INITIALIZER(2, 1), |
| 82 | #endif |
Shaohui Xie | 944b6cc | 2013-03-25 07:33:17 +0000 | [diff] [blame] | 83 | #if (CONFIG_SYS_NUM_FM2_10GEC >= 2) |
| 84 | FM_TGEC_INFO_INITIALIZER(2, 2), |
| 85 | #endif |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | int fm_standard_init(bd_t *bis) |
| 89 | { |
| 90 | int i; |
| 91 | struct ccsr_fman *reg; |
| 92 | |
| 93 | reg = (void *)CONFIG_SYS_FSL_FM1_ADDR; |
| 94 | if (fm_init_common(0, reg)) |
| 95 | return 0; |
| 96 | |
| 97 | for (i = 0; i < ARRAY_SIZE(fm_info); i++) { |
| 98 | if ((fm_info[i].enabled) && (fm_info[i].index == 1)) |
| 99 | fm_eth_initialize(reg, &fm_info[i]); |
| 100 | } |
| 101 | |
| 102 | #if (CONFIG_SYS_NUM_FMAN == 2) |
| 103 | reg = (void *)CONFIG_SYS_FSL_FM2_ADDR; |
| 104 | if (fm_init_common(1, reg)) |
| 105 | return 0; |
| 106 | |
| 107 | for (i = 0; i < ARRAY_SIZE(fm_info); i++) { |
| 108 | if ((fm_info[i].enabled) && (fm_info[i].index == 2)) |
| 109 | fm_eth_initialize(reg, &fm_info[i]); |
| 110 | } |
| 111 | #endif |
| 112 | |
| 113 | return 1; |
| 114 | } |
| 115 | |
| 116 | /* simple linear search to map from port to array index */ |
| 117 | static int fm_port_to_index(enum fm_port port) |
| 118 | { |
| 119 | int i; |
| 120 | |
| 121 | for (i = 0; i < ARRAY_SIZE(fm_info); i++) { |
| 122 | if (fm_info[i].port == port) |
| 123 | return i; |
| 124 | } |
| 125 | |
| 126 | return -1; |
| 127 | } |
| 128 | |
| 129 | /* |
| 130 | * Determine if an interface is actually active based on HW config |
| 131 | * we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NONE if |
| 132 | * the interface is not active based on HW cfg of the SoC |
| 133 | */ |
| 134 | void fman_enet_init(void) |
| 135 | { |
| 136 | int i; |
| 137 | |
| 138 | for (i = 0; i < ARRAY_SIZE(fm_info); i++) { |
| 139 | phy_interface_t enet_if; |
| 140 | |
| 141 | enet_if = fman_port_enet_if(fm_info[i].port); |
| 142 | if (enet_if != PHY_INTERFACE_MODE_NONE) { |
| 143 | fm_info[i].enabled = 1; |
| 144 | fm_info[i].enet_if = enet_if; |
| 145 | } else { |
| 146 | fm_info[i].enabled = 0; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | return ; |
| 151 | } |
| 152 | |
Kumar Gala | 69a8524 | 2011-09-14 12:01:35 -0500 | [diff] [blame] | 153 | void fm_disable_port(enum fm_port port) |
| 154 | { |
| 155 | int i = fm_port_to_index(port); |
| 156 | |
Rotariu Marian-Cristian | 1155d8d | 2014-05-19 10:59:52 +0300 | [diff] [blame] | 157 | if (i == -1) |
| 158 | return; |
| 159 | |
Kumar Gala | 69a8524 | 2011-09-14 12:01:35 -0500 | [diff] [blame] | 160 | fm_info[i].enabled = 0; |
Shaohui Xie | e829734 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 161 | #ifndef CONFIG_SYS_FMAN_V3 |
Kumar Gala | 69a8524 | 2011-09-14 12:01:35 -0500 | [diff] [blame] | 162 | fman_disable_port(port); |
Shaohui Xie | e829734 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 163 | #endif |
Kumar Gala | 69a8524 | 2011-09-14 12:01:35 -0500 | [diff] [blame] | 164 | } |
| 165 | |
Valentin Longchamp | f51d3b7 | 2013-10-18 11:47:21 +0200 | [diff] [blame] | 166 | void fm_enable_port(enum fm_port port) |
| 167 | { |
| 168 | int i = fm_port_to_index(port); |
| 169 | |
Rotariu Marian-Cristian | 1155d8d | 2014-05-19 10:59:52 +0300 | [diff] [blame] | 170 | if (i == -1) |
| 171 | return; |
| 172 | |
Valentin Longchamp | f51d3b7 | 2013-10-18 11:47:21 +0200 | [diff] [blame] | 173 | fm_info[i].enabled = 1; |
| 174 | fman_enable_port(port); |
| 175 | } |
| 176 | |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 177 | void fm_info_set_mdio(enum fm_port port, struct mii_dev *bus) |
| 178 | { |
| 179 | int i = fm_port_to_index(port); |
| 180 | |
| 181 | if (i == -1) |
| 182 | return; |
| 183 | |
| 184 | fm_info[i].bus = bus; |
| 185 | } |
| 186 | |
| 187 | void fm_info_set_phy_address(enum fm_port port, int address) |
| 188 | { |
| 189 | int i = fm_port_to_index(port); |
| 190 | |
| 191 | if (i == -1) |
| 192 | return; |
| 193 | |
| 194 | fm_info[i].phy_addr = address; |
| 195 | } |
| 196 | |
| 197 | /* |
Timur Tabi | ae2291f | 2012-08-14 06:47:22 +0000 | [diff] [blame] | 198 | * Returns the PHY address for a given Fman port |
| 199 | * |
| 200 | * The port must be set via a prior call to fm_info_set_phy_address(). |
| 201 | * A negative error code is returned if the port is invalid. |
| 202 | */ |
| 203 | int fm_info_get_phy_address(enum fm_port port) |
| 204 | { |
| 205 | int i = fm_port_to_index(port); |
| 206 | |
| 207 | if (i == -1) |
| 208 | return -1; |
| 209 | |
| 210 | return fm_info[i].phy_addr; |
| 211 | } |
| 212 | |
| 213 | /* |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 214 | * Returns the type of the data interface between the given MAC and its PHY. |
| 215 | * This is typically determined by the RCW. |
| 216 | */ |
| 217 | phy_interface_t fm_info_get_enet_if(enum fm_port port) |
| 218 | { |
| 219 | int i = fm_port_to_index(port); |
| 220 | |
| 221 | if (i == -1) |
| 222 | return PHY_INTERFACE_MODE_NONE; |
| 223 | |
| 224 | if (fm_info[i].enabled) |
| 225 | return fm_info[i].enet_if; |
| 226 | |
| 227 | return PHY_INTERFACE_MODE_NONE; |
| 228 | } |
| 229 | |
| 230 | static void |
| 231 | __def_board_ft_fman_fixup_port(void *blob, char * prop, phys_addr_t pa, |
| 232 | enum fm_port port, int offset) |
| 233 | { |
| 234 | return ; |
| 235 | } |
| 236 | |
| 237 | void board_ft_fman_fixup_port(void *blob, char * prop, phys_addr_t pa, |
| 238 | enum fm_port port, int offset) |
| 239 | __attribute__((weak, alias("__def_board_ft_fman_fixup_port"))); |
| 240 | |
Igal Liberman | 97a8d01 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 241 | int ft_fixup_port(void *blob, struct fm_eth_info *info, char *prop) |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 242 | { |
Timur Tabi | 4376b4c | 2012-08-14 06:47:24 +0000 | [diff] [blame] | 243 | int off; |
| 244 | uint32_t ph; |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 245 | phys_addr_t paddr = CONFIG_SYS_CCSRBAR_PHYS + info->compat_offset; |
Shaohui Xie | ea1332c | 2015-12-04 10:22:03 +0800 | [diff] [blame] | 246 | #ifndef CONFIG_SYS_FMAN_V3 |
Kumar Gala | e81c0ab | 2011-10-13 14:55:59 -0500 | [diff] [blame] | 247 | u64 dtsec1_addr = (u64)CONFIG_SYS_CCSRBAR_PHYS + |
| 248 | CONFIG_SYS_FSL_FM1_DTSEC1_OFFSET; |
Shaohui Xie | ea1332c | 2015-12-04 10:22:03 +0800 | [diff] [blame] | 249 | #endif |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 250 | |
| 251 | off = fdt_node_offset_by_compat_reg(blob, prop, paddr); |
Igal Liberman | 97a8d01 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 252 | if (off == -FDT_ERR_NOTFOUND) |
| 253 | return -EINVAL; |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 254 | |
| 255 | if (info->enabled) { |
| 256 | fdt_fixup_phy_connection(blob, off, info->enet_if); |
| 257 | board_ft_fman_fixup_port(blob, prop, paddr, info->port, off); |
Igal Liberman | 97a8d01 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 258 | return 0; |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 259 | } |
| 260 | |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 261 | #ifdef CONFIG_SYS_FMAN_V3 |
Shengzhou Liu | 24d827f | 2014-12-03 15:27:03 +0800 | [diff] [blame] | 262 | #ifndef CONFIG_FSL_FM_10GEC_REGULAR_NOTATION |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 263 | /* |
Shengzhou Liu | 24d827f | 2014-12-03 15:27:03 +0800 | [diff] [blame] | 264 | * On T2/T4 SoCs, physically FM1_DTSEC9 and FM1_10GEC1 use the same |
| 265 | * dual-role MAC, when FM1_10GEC1 is enabled and FM1_DTSEC9 |
| 266 | * is disabled, ensure that the dual-role MAC is not disabled, |
| 267 | * ditto for other dual-role MACs. |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 268 | */ |
Shengzhou Liu | 82a55c1 | 2013-11-22 17:39:09 +0800 | [diff] [blame] | 269 | if (((info->port == FM1_DTSEC9) && (PORT_IS_ENABLED(FM1_10GEC1))) || |
| 270 | ((info->port == FM1_DTSEC10) && (PORT_IS_ENABLED(FM1_10GEC2))) || |
| 271 | ((info->port == FM1_DTSEC1) && (PORT_IS_ENABLED(FM1_10GEC3))) || |
| 272 | ((info->port == FM1_DTSEC2) && (PORT_IS_ENABLED(FM1_10GEC4))) || |
| 273 | ((info->port == FM1_10GEC1) && (PORT_IS_ENABLED(FM1_DTSEC9))) || |
| 274 | ((info->port == FM1_10GEC2) && (PORT_IS_ENABLED(FM1_DTSEC10))) || |
| 275 | ((info->port == FM1_10GEC3) && (PORT_IS_ENABLED(FM1_DTSEC1))) || |
| 276 | ((info->port == FM1_10GEC4) && (PORT_IS_ENABLED(FM1_DTSEC2))) |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 277 | #if (CONFIG_SYS_NUM_FMAN == 2) |
| 278 | || |
| 279 | ((info->port == FM2_DTSEC9) && (PORT_IS_ENABLED(FM2_10GEC1))) || |
| 280 | ((info->port == FM2_DTSEC10) && (PORT_IS_ENABLED(FM2_10GEC2))) || |
| 281 | ((info->port == FM2_10GEC1) && (PORT_IS_ENABLED(FM2_DTSEC9))) || |
| 282 | ((info->port == FM2_10GEC2) && (PORT_IS_ENABLED(FM2_DTSEC10))) |
| 283 | #endif |
Shengzhou Liu | 24d827f | 2014-12-03 15:27:03 +0800 | [diff] [blame] | 284 | #else |
| 285 | /* FM1_DTSECx and FM1_10GECx use the same dual-role MAC */ |
| 286 | if (((info->port == FM1_DTSEC1) && (PORT_IS_ENABLED(FM1_10GEC1))) || |
| 287 | ((info->port == FM1_DTSEC2) && (PORT_IS_ENABLED(FM1_10GEC2))) || |
| 288 | ((info->port == FM1_DTSEC3) && (PORT_IS_ENABLED(FM1_10GEC3))) || |
| 289 | ((info->port == FM1_DTSEC4) && (PORT_IS_ENABLED(FM1_10GEC4))) || |
| 290 | ((info->port == FM1_10GEC1) && (PORT_IS_ENABLED(FM1_DTSEC1))) || |
| 291 | ((info->port == FM1_10GEC2) && (PORT_IS_ENABLED(FM1_DTSEC2))) || |
| 292 | ((info->port == FM1_10GEC3) && (PORT_IS_ENABLED(FM1_DTSEC3))) || |
| 293 | ((info->port == FM1_10GEC4) && (PORT_IS_ENABLED(FM1_DTSEC4))) |
| 294 | #endif |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 295 | ) |
Igal Liberman | 97a8d01 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 296 | return 0; |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 297 | #endif |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 298 | /* board code might have caused offset to change */ |
| 299 | off = fdt_node_offset_by_compat_reg(blob, prop, paddr); |
| 300 | |
Shaohui Xie | ea1332c | 2015-12-04 10:22:03 +0800 | [diff] [blame] | 301 | #ifndef CONFIG_SYS_FMAN_V3 |
Kumar Gala | e81c0ab | 2011-10-13 14:55:59 -0500 | [diff] [blame] | 302 | /* Don't disable FM1-DTSEC1 MAC as its used for MDIO */ |
Timur Tabi | 4376b4c | 2012-08-14 06:47:24 +0000 | [diff] [blame] | 303 | if (paddr != dtsec1_addr) |
Shaohui Xie | ea1332c | 2015-12-04 10:22:03 +0800 | [diff] [blame] | 304 | #endif |
Timur Tabi | 4376b4c | 2012-08-14 06:47:24 +0000 | [diff] [blame] | 305 | fdt_status_disabled(blob, off); /* disable the MAC node */ |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 306 | |
Timur Tabi | 4376b4c | 2012-08-14 06:47:24 +0000 | [diff] [blame] | 307 | /* disable the fsl,dpa-ethernet node that points to the MAC */ |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 308 | ph = fdt_get_phandle(blob, off); |
| 309 | do_fixup_by_prop(blob, "fsl,fman-mac", &ph, sizeof(ph), |
| 310 | "status", "disabled", strlen("disabled") + 1, 1); |
Igal Liberman | 97a8d01 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 311 | |
| 312 | return 0; |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | void fdt_fixup_fman_ethernet(void *blob) |
| 316 | { |
| 317 | int i; |
| 318 | |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 319 | #ifdef CONFIG_SYS_FMAN_V3 |
Shengzhou Liu | 4399434 | 2014-01-13 15:32:24 +0800 | [diff] [blame] | 320 | for (i = 0; i < ARRAY_SIZE(fm_info); i++) |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 321 | ft_fixup_port(blob, &fm_info[i], "fsl,fman-memac"); |
| 322 | #else |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 323 | for (i = 0; i < ARRAY_SIZE(fm_info); i++) { |
Igal Liberman | 97a8d01 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 324 | /* Try the new compatible first. |
| 325 | * If the node is missing, try the old. |
| 326 | */ |
| 327 | if (fm_info[i].type == FM_ETH_1G_E) { |
| 328 | if (ft_fixup_port(blob, &fm_info[i], "fsl,fman-dtsec")) |
| 329 | ft_fixup_port(blob, &fm_info[i], |
| 330 | "fsl,fman-1g-mac"); |
| 331 | } else { |
| 332 | if (ft_fixup_port(blob, &fm_info[i], "fsl,fman-tgec")) |
| 333 | ft_fixup_port(blob, &fm_info[i], |
| 334 | "fsl,fman-10g-mac"); |
| 335 | } |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 336 | } |
Shengzhou Liu | ae8a5d1 | 2013-03-25 07:39:29 +0000 | [diff] [blame] | 337 | #endif |
Kumar Gala | c916d7c | 2011-04-13 08:37:44 -0500 | [diff] [blame] | 338 | } |
Zhao Qiang | ffee1dd | 2013-09-04 10:11:27 +0800 | [diff] [blame] | 339 | |
| 340 | /*QSGMII Riser Card can work in SGMII mode, but the PHY address is different. |
| 341 | *This function scans which Riser Card being used(QSGMII or SGMII Riser Card), |
| 342 | *then set the correct PHY address |
| 343 | */ |
| 344 | void set_sgmii_phy(struct mii_dev *bus, enum fm_port base_port, |
| 345 | unsigned int port_num, int phy_base_addr) |
| 346 | { |
| 347 | unsigned int regnum = 0; |
| 348 | int qsgmii; |
| 349 | int i; |
| 350 | int phy_real_addr; |
| 351 | |
| 352 | qsgmii = is_qsgmii_riser_card(bus, phy_base_addr, port_num, regnum); |
| 353 | |
| 354 | if (!qsgmii) |
| 355 | return; |
| 356 | |
| 357 | for (i = base_port; i < base_port + port_num; i++) { |
| 358 | if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_SGMII) { |
| 359 | phy_real_addr = phy_base_addr + i - base_port; |
| 360 | fm_info_set_phy_address(i, phy_real_addr); |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /*to check whether qsgmii riser card is used*/ |
| 366 | int is_qsgmii_riser_card(struct mii_dev *bus, int phy_base_addr, |
| 367 | unsigned int port_num, unsigned regnum) |
| 368 | { |
| 369 | int i; |
| 370 | int val; |
| 371 | |
| 372 | if (!bus) |
| 373 | return 0; |
| 374 | |
| 375 | for (i = phy_base_addr; i < phy_base_addr + port_num; i++) { |
| 376 | val = bus->read(bus, i, MDIO_DEVAD_NONE, regnum); |
| 377 | if (val != MIIM_TIMEOUT) |
| 378 | return 1; |
| 379 | } |
| 380 | |
| 381 | return 0; |
| 382 | } |