86 if ((ipd_port >= 16) && (ipd_port < 20))
102 else if (ipd_port == 1)
108 if ((ipd_port >= 0) && (ipd_port < 4))
110 else if ((ipd_port >= 16) && (ipd_port < 20))
111 return ipd_port - 16 + 4;
128 if ((ipd_port >= 0) && (ipd_port < 4))
136 if (ipd_port == CVMX_HELPER_BOARD_MGMT_IPD_PORT)
142 if ((ipd_port >= 0) && (ipd_port < 4))
153 if ((ipd_port >= 16) && (ipd_port < 20))
154 return ipd_port - 16 + 1;
161 if (ipd_port >= 0 && ipd_port <= 3)
162 return (ipd_port + 0x1f) & 0x1f;
166 if (ipd_port >= 0 && ipd_port <= 1)
178 if (ipd_port >= 0 && ipd_port <= 3)
180 else if (ipd_port >= 16 && ipd_port <= 19)
181 return ipd_port - 16 + 4;
188 (
"cvmx_helper_board_get_mii_address: Unknown board type %d\n",
215 int is_broadcom_phy = 0;
231 result.
s.link_up = 1;
232 result.
s.full_duplex = 1;
233 result.
s.speed = 1000;
241 result.
s.link_up = 1;
242 result.
s.full_duplex = 1;
243 result.
s.speed = 1000;
251 result.
s.link_up = 1;
252 result.
s.full_duplex = 1;
253 result.
s.speed = 1000;
266 result.
s.link_up = 1;
267 result.
s.full_duplex = 1;
268 result.
s.speed = 1000;
275 if (phy_addr != -1) {
276 if (is_broadcom_phy) {
283 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
285 switch ((phy_status >> 8) & 0x7) {
290 result.
s.link_up = 1;
291 result.
s.full_duplex = 0;
295 result.
s.link_up = 1;
296 result.
s.full_duplex = 1;
300 result.
s.link_up = 1;
301 result.
s.full_duplex = 0;
302 result.
s.speed = 100;
305 result.
s.link_up = 1;
306 result.
s.full_duplex = 1;
307 result.
s.speed = 100;
310 result.
s.link_up = 1;
311 result.
s.full_duplex = 1;
312 result.
s.speed = 100;
315 result.
s.link_up = 1;
316 result.
s.full_duplex = 0;
317 result.
s.speed = 1000;
320 result.
s.link_up = 1;
321 result.
s.full_duplex = 1;
322 result.
s.speed = 1000;
335 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff, 17);
343 if ((phy_status & (1 << 11)) == 0) {
345 cvmx_mdio_read(phy_addr >> 8,
347 if ((auto_status & (1 << 12)) == 0)
348 phy_status |= 1 << 11;
356 if (phy_status & (1 << 11)) {
357 result.
s.link_up = 1;
358 result.
s.full_duplex = ((phy_status >> 13) & 1);
359 switch ((phy_status >> 14) & 3) {
364 result.
s.speed = 100;
367 result.
s.speed = 1000;
386 int interface = cvmx_helper_get_interface_num(ipd_port);
391 result.
s.link_up = inband_status.
s.status;
392 result.
s.full_duplex = inband_status.
s.duplex;
393 switch (inband_status.
s.speed) {
398 result.
s.speed = 100;
401 result.
s.speed = 1000;
418 if (!result.
s.link_up)
448 reg_autoneg_adver.
u16 =
449 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
451 reg_autoneg_adver.
s.asymmetric_pause =
454 reg_autoneg_adver.
s.pause =
457 cvmx_mdio_write(phy_addr >> 8, phy_addr & 0xff,
459 reg_autoneg_adver.
u16);
464 && (link_info.
s.speed == 0)) {
472 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
474 reg_autoneg_adver.
u16 =
475 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
477 reg_autoneg_adver.
s.advert_100base_t4 =
478 reg_status.
s.capable_100base_t4;
479 reg_autoneg_adver.
s.advert_10base_tx_full =
480 reg_status.
s.capable_10_full;
481 reg_autoneg_adver.
s.advert_10base_tx_half =
482 reg_status.
s.capable_10_half;
483 reg_autoneg_adver.
s.advert_100base_tx_full =
484 reg_status.
s.capable_100base_x_full;
485 reg_autoneg_adver.
s.advert_100base_tx_half =
486 reg_status.
s.capable_100base_x_half;
487 cvmx_mdio_write(phy_addr >> 8, phy_addr & 0xff,
489 reg_autoneg_adver.
u16);
490 if (reg_status.
s.capable_extended_status) {
491 reg_extended_status.
u16 =
492 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
494 reg_control_1000.
u16 =
495 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
497 reg_control_1000.
s.advert_1000base_t_full =
498 reg_extended_status.
s.capable_1000base_t_full;
499 reg_control_1000.
s.advert_1000base_t_half =
500 reg_extended_status.
s.capable_1000base_t_half;
501 cvmx_mdio_write(phy_addr >> 8, phy_addr & 0xff,
503 reg_control_1000.
u16);
506 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
508 reg_control.
s.autoneg_enable = 1;
509 reg_control.
s.restart_autoneg = 1;
510 cvmx_mdio_write(phy_addr >> 8, phy_addr & 0xff,
512 }
else if ((link_flags & set_phy_link_flags_autoneg)) {
519 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
521 reg_autoneg_adver.
u16 =
522 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
524 reg_autoneg_adver.
s.advert_100base_t4 = 0;
525 reg_autoneg_adver.
s.advert_10base_tx_full = 0;
526 reg_autoneg_adver.
s.advert_10base_tx_half = 0;
527 reg_autoneg_adver.
s.advert_100base_tx_full = 0;
528 reg_autoneg_adver.
s.advert_100base_tx_half = 0;
529 if (reg_status.
s.capable_extended_status) {
530 reg_control_1000.
u16 =
531 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
533 reg_control_1000.
s.advert_1000base_t_full = 0;
534 reg_control_1000.
s.advert_1000base_t_half = 0;
536 switch (link_info.
s.speed) {
538 reg_autoneg_adver.
s.advert_10base_tx_full =
539 link_info.
s.full_duplex;
540 reg_autoneg_adver.
s.advert_10base_tx_half =
541 !link_info.
s.full_duplex;
544 reg_autoneg_adver.
s.advert_100base_tx_full =
545 link_info.
s.full_duplex;
546 reg_autoneg_adver.
s.advert_100base_tx_half =
547 !link_info.
s.full_duplex;
550 reg_control_1000.
s.advert_1000base_t_full =
551 link_info.
s.full_duplex;
552 reg_control_1000.
s.advert_1000base_t_half =
553 !link_info.
s.full_duplex;
556 cvmx_mdio_write(phy_addr >> 8, phy_addr & 0xff,
558 reg_autoneg_adver.
u16);
559 if (reg_status.
s.capable_extended_status)
560 cvmx_mdio_write(phy_addr >> 8, phy_addr & 0xff,
562 reg_control_1000.
u16);
564 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
566 reg_control.
s.autoneg_enable = 1;
567 reg_control.
s.restart_autoneg = 1;
568 cvmx_mdio_write(phy_addr >> 8, phy_addr & 0xff,
573 cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
575 reg_control.
s.autoneg_enable = 0;
576 reg_control.
s.restart_autoneg = 1;
577 reg_control.
s.duplex = link_info.
s.full_duplex;
578 if (link_info.
s.speed == 1000) {
579 reg_control.
s.speed_msb = 1;
580 reg_control.
s.speed_lsb = 0;
581 }
else if (link_info.
s.speed == 100) {
582 reg_control.
s.speed_msb = 0;
583 reg_control.
s.speed_lsb = 1;
584 }
else if (link_info.
s.speed == 10) {
585 reg_control.
s.speed_msb = 0;
586 reg_control.
s.speed_lsb = 0;
588 cvmx_mdio_write(phy_addr >> 8, phy_addr & 0xff,
637 return supported_ports;
653 if (interface == 0) {
675 if (interface == 0) {
685 if (phy_addr != -1) {
687 cvmx_mdio_read(phy_addr >> 8,
688 phy_addr & 0xff, 0x2);
690 if (phy_identifier == 0x0143) {
694 (
"ERROR: Board type is CVMX_BOARD_TYPE_CN3010_EVB_HS5, but Broadcom PHY found.\n");
696 (
"ERROR: The board type is mis-configured, and software malfunctions are likely.\n");
698 (
"ERROR: All boards require a unique board type to identify them.\n");
701 cvmx_wait(1000000000);