Print this page
Just the 5719/5720 changes

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/bge/bge_mii.c
          +++ new/usr/src/uts/common/io/bge/bge_mii.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
       26 +/*
       27 + * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
       28 + */
       29 +
  26   30  #include "bge_impl.h"
  27   31  
  28   32  /*
  29   33   * Bit test macros, returning boolean_t values
  30   34   */
  31   35  #define BIS(w, b)       (((w) & (b)) ? B_TRUE : B_FALSE)
  32   36  #define BIC(w, b)       (((w) & (b)) ? B_FALSE : B_TRUE)
  33   37  #define UPORDOWN(x)     ((x) ? "up" : "down")
  34   38  
  35   39  /*
↓ open down ↓ 164 lines elided ↑ open up ↑
 200  204   * Basic low-level function to reset the PHY.
 201  205   * Doesn't incorporate any special-case workarounds.
 202  206   *
 203  207   * Returns TRUE on success, FALSE if the RESET bit doesn't clear
 204  208   */
 205  209  static boolean_t
 206  210  bge_phy_reset(bge_t *bgep)
 207  211  {
 208  212          uint16_t control;
 209  213          uint_t count;
      214 +        boolean_t ret = B_FALSE;
 210  215  
 211  216          BGE_TRACE(("bge_phy_reset($%p)", (void *)bgep));
 212  217  
 213  218          ASSERT(mutex_owned(bgep->genlock));
 214  219  
 215  220          if (DEVICE_5906_SERIES_CHIPSETS(bgep)) {
 216  221                  drv_usecwait(40);
 217  222                  /* put PHY into ready state */
 218  223                  bge_reg_clr32(bgep, MISC_CONFIG_REG, MISC_CONFIG_EPHY_IDDQ);
 219  224                  (void) bge_reg_get32(bgep, MISC_CONFIG_REG); /* flush */
 220  225                  drv_usecwait(40);
 221  226          }
 222  227  
 223  228          /*
 224      -         * Set the PHY RESET bit, then wait up to 5 ms for it to self-clear
      229 +         * Set the PHY RESET bit, then wait up to 50 ms for it to self-clear
 225  230           */
 226  231          bge_mii_put16(bgep, MII_CONTROL, MII_CONTROL_RESET);
 227      -        for (count = 0; ++count < 1000; ) {
 228      -                drv_usecwait(5);
      232 +        for (count = 0; ++count < 5000; ) {
 229  233                  control = bge_mii_get16(bgep, MII_CONTROL);
 230      -                if (BIC(control, MII_CONTROL_RESET))
 231      -                        return (B_TRUE);
      234 +                if (BIC(control, MII_CONTROL_RESET)) {
      235 +                        drv_usecwait(40);
      236 +                        ret = B_TRUE;
      237 +                        break;
      238 +                }
      239 +                drv_usecwait(10);
 232  240          }
 233  241  
 234      -        if (DEVICE_5906_SERIES_CHIPSETS(bgep))
      242 +        if (ret == B_TRUE && DEVICE_5906_SERIES_CHIPSETS(bgep))
 235  243                  (void) bge_adj_volt_5906(bgep);
 236  244  
 237      -        BGE_DEBUG(("bge_phy_reset: FAILED, control now 0x%x", control));
      245 +        if (ret == B_FALSE)
      246 +                BGE_DEBUG(("bge_phy_reset: FAILED, control now 0x%x", control));
 238  247  
 239      -        return (B_FALSE);
      248 +        return (ret);
 240  249  }
 241  250  
 242  251  /*
 243  252   * Basic low-level function to powerdown the PHY, if supported
 244  253   * If powerdown support is compiled out, this function does nothing.
 245  254   */
 246  255  static void
 247  256  bge_phy_powerdown(bge_t *bgep)
 248  257  {
 249  258          BGE_TRACE(("bge_phy_powerdown"));
↓ open down ↓ 284 lines elided ↑ open up ↑
 534  543  bge_restart_copper(bge_t *bgep, boolean_t powerdown)
 535  544  {
 536  545          uint16_t phy_status;
 537  546          boolean_t reset_ok;
 538  547          uint16_t extctrl, auxctrl;
 539  548  
 540  549          BGE_TRACE(("bge_restart_copper($%p, %d)", (void *)bgep, powerdown));
 541  550  
 542  551          ASSERT(mutex_owned(bgep->genlock));
 543  552  
 544      -        switch (MHCR_CHIP_ASIC_REV(bgep->chipid.asic_rev)) {
 545      -        default:
 546      -                /*
 547      -                 * Shouldn't happen; it means we don't recognise this chip.
 548      -                 * It's probably a new one, so we'll try our best anyway ...
 549      -                 */
 550      -        case MHCR_CHIP_ASIC_REV_5703:
 551      -        case MHCR_CHIP_ASIC_REV_5704:
 552      -        case MHCR_CHIP_ASIC_REV_5705:
 553      -        case MHCR_CHIP_ASIC_REV_5752:
 554      -        case MHCR_CHIP_ASIC_REV_5714:
 555      -        case MHCR_CHIP_ASIC_REV_5715:
 556      -                reset_ok = bge_phy_reset_and_check(bgep);
 557      -                break;
 558      -
 559      -        case MHCR_CHIP_ASIC_REV_5906:
 560      -        case MHCR_CHIP_ASIC_REV_5700:
 561      -        case MHCR_CHIP_ASIC_REV_5701:
 562      -        case MHCR_CHIP_ASIC_REV_5723:
 563      -        case MHCR_CHIP_ASIC_REV_5721_5751:
 564      -                /*
 565      -                 * Just a plain reset; the "check" code breaks these chips
 566      -                 */
      553 +        if (bgep->chipid.flags & CHIP_FLAG_NO_CHECK_RESET) {
 567  554                  reset_ok = bge_phy_reset(bgep);
 568  555                  if (!reset_ok)
 569  556                          bge_fm_ereport(bgep, DDI_FM_DEVICE_NO_RESPONSE);
 570      -                break;
      557 +        } else {
      558 +                reset_ok = bge_phy_reset_and_check(bgep);
 571  559          }
      560 +
 572  561          if (!reset_ok) {
 573  562                  BGE_REPORT((bgep, "PHY failed to reset correctly"));
 574  563                  return (DDI_FAILURE);
 575  564          }
 576  565  
 577  566          /*
 578  567           * Step 5: disable WOL (not required after RESET)
 579  568           *
 580  569           * Step 6: refer to errata
 581  570           */
↓ open down ↓ 1 lines elided ↑ open up ↑
 583  572          default:
 584  573                  break;
 585  574  
 586  575          case MHCR_CHIP_REV_5704_A0:
 587  576                  bge_phy_tweak_gmii(bgep);
 588  577                  break;
 589  578          }
 590  579  
 591  580          switch (MHCR_CHIP_ASIC_REV(bgep->chipid.asic_rev)) {
 592  581          case MHCR_CHIP_ASIC_REV_5705:
 593      -        case MHCR_CHIP_ASIC_REV_5721_5751:
      582 +        case MHCR_CHIP_ASIC_REV_5750:
 594  583                  bge_phy_bit_err_fix(bgep);
 595  584                  break;
 596  585          }
 597  586  
 598  587          if (!(bgep->chipid.flags & CHIP_FLAG_NO_JUMBO) &&
 599  588              (bgep->chipid.default_mtu > BGE_DEFAULT_MTU)) {
 600  589                  /* Set the GMII Fifo Elasticity to high latency */
 601  590                  extctrl = bge_mii_get16(bgep, 0x10);
 602  591                  bge_mii_put16(bgep, 0x10, extctrl | 0x1);
 603  592  
↓ open down ↓ 896 lines elided ↑ open up ↑
1500 1489          mutex_enter(bgep->genlock);
1501 1490  
1502 1491          /*
1503 1492           * Probe for the (internal) PHY.  If it's not there, we'll assume
1504 1493           * that this is a 5703/4S, with a SerDes interface rather than
1505 1494           * a PHY. BCM5714S/BCM5715S are not supported.It are based on
1506 1495           * BCM800x PHY.
1507 1496           */
1508 1497          bgep->phy_mii_addr = 1;
1509 1498          if (DEVICE_5717_SERIES_CHIPSETS(bgep)) {
1510      -                int regval = bge_reg_get32(bgep, CPMU_STATUS_REG);
1511      -                if (regval & CPMU_STATUS_FUN_NUM)
1512      -                        bgep->phy_mii_addr += 1;
     1499 +                uint32_t regval = bge_reg_get32(bgep, CPMU_STATUS_REG);
     1500 +                if (MHCR_CHIP_ASIC_REV(bgep->chipid.asic_rev) ==
     1501 +                    MHCR_CHIP_ASIC_REV_5719 ||
     1502 +                    MHCR_CHIP_ASIC_REV(bgep->chipid.asic_rev) ==
     1503 +                    MHCR_CHIP_ASIC_REV_5720) {
     1504 +                        bgep->phy_mii_addr +=
     1505 +                            (regval & CPMU_STATUS_FUN_NUM_5719) >>
     1506 +                            CPMU_STATUS_FUN_NUM_5719_SHIFT;
     1507 +                } else {
     1508 +                        bgep->phy_mii_addr +=
     1509 +                            (regval & CPMU_STATUS_FUN_NUM_5717) ? 1 : 0;
     1510 +                }
1513 1511                  regval = bge_reg_get32(bgep, SGMII_STATUS_REG);
1514 1512                  if (regval & MEDIA_SELECTION_MODE)
1515 1513                          bgep->phy_mii_addr += 7;
1516 1514          }
1517      -
1518 1515          if (bge_phy_probe(bgep)) {
1519 1516                  bgep->chipid.flags &= ~CHIP_FLAG_SERDES;
1520 1517                  bgep->physops = &copper_ops;
1521 1518          } else {
1522 1519                  bgep->chipid.flags |= CHIP_FLAG_SERDES;
1523 1520                  bgep->physops = &serdes_ops;
1524 1521          }
1525 1522  
1526 1523          if ((*bgep->physops->phys_restart)(bgep, B_FALSE) != DDI_SUCCESS) {
1527 1524                  mutex_exit(bgep->genlock);
↓ open down ↓ 96 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX