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