[Midnightbsd-cvs] src [8457] trunk/sys/dev/bge: do not hardcode phy address
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 18 17:57:12 EDT 2016
Revision: 8457
http://svnweb.midnightbsd.org/src/?rev=8457
Author: laffer1
Date: 2016-09-18 17:57:12 -0400 (Sun, 18 Sep 2016)
Log Message:
-----------
do not hardcode phy address
Modified Paths:
--------------
trunk/sys/dev/bge/if_bge.c
trunk/sys/dev/bge/if_bgereg.h
Modified: trunk/sys/dev/bge/if_bge.c
===================================================================
--- trunk/sys/dev/bge/if_bge.c 2016-09-18 21:56:23 UTC (rev 8456)
+++ trunk/sys/dev/bge/if_bge.c 2016-09-18 21:57:12 UTC (rev 8457)
@@ -3240,7 +3240,7 @@
struct bge_softc *sc;
uint32_t hwcfg = 0, misccfg, pcistate;
u_char eaddr[ETHER_ADDR_LEN];
- int capmask, error, msicount, phy_addr, reg, rid, trys;
+ int capmask, error, msicount, reg, rid, trys;
sc = device_get_softc(dev);
sc->bge_dev = dev;
@@ -3300,7 +3300,7 @@
sc->bge_chiprev = BGE_CHIPREV(sc->bge_chipid);
/* Set default PHY address. */
- phy_addr = 1;
+ sc->bge_phy_addr = 1;
/*
* PHY address mapping for various devices.
*
@@ -3329,29 +3329,18 @@
if (sc->bge_chipid != BGE_CHIPID_BCM5717_A0) {
if (CSR_READ_4(sc, BGE_SGDIG_STS) &
BGE_SGDIGSTS_IS_SERDES)
- phy_addr = sc->bge_func_addr + 8;
+ sc->bge_phy_addr = sc->bge_func_addr + 8;
else
- phy_addr = sc->bge_func_addr + 1;
+ sc->bge_phy_addr = sc->bge_func_addr + 1;
} else {
if (CSR_READ_4(sc, BGE_CPMU_PHY_STRAP) &
BGE_CPMU_PHY_STRAP_IS_SERDES)
- phy_addr = sc->bge_func_addr + 8;
+ sc->bge_phy_addr = sc->bge_func_addr + 8;
else
- phy_addr = sc->bge_func_addr + 1;
+ sc->bge_phy_addr = sc->bge_func_addr + 1;
}
}
- /*
- * Don't enable Ethernet at WireSpeed for the 5700, 5906, or the
- * 5705 A0 and A1 chips.
- */
- if (sc->bge_asicrev == BGE_ASICREV_BCM5700 ||
- (sc->bge_asicrev == BGE_ASICREV_BCM5705 &&
- (sc->bge_chipid != BGE_CHIPID_BCM5705_A0 &&
- sc->bge_chipid != BGE_CHIPID_BCM5705_A1)) ||
- sc->bge_asicrev == BGE_ASICREV_BCM5906)
- sc->bge_phy_flags |= BGE_PHY_NO_WIRESPEED;
-
if (bge_has_eaddr(sc))
sc->bge_flags |= BGE_FLAG_EADDR;
@@ -3436,38 +3425,6 @@
/* Add SYSCTLs, requires the chipset family to be set. */
bge_add_sysctls(sc);
- /* Set various PHY bug flags. */
- if (sc->bge_chipid == BGE_CHIPID_BCM5701_A0 ||
- sc->bge_chipid == BGE_CHIPID_BCM5701_B0)
- sc->bge_phy_flags |= BGE_PHY_CRC_BUG;
- if (sc->bge_chiprev == BGE_CHIPREV_5703_AX ||
- sc->bge_chiprev == BGE_CHIPREV_5704_AX)
- sc->bge_phy_flags |= BGE_PHY_ADC_BUG;
- if (sc->bge_chipid == BGE_CHIPID_BCM5704_A0)
- sc->bge_phy_flags |= BGE_PHY_5704_A0_BUG;
- if (pci_get_subvendor(dev) == DELL_VENDORID)
- sc->bge_phy_flags |= BGE_PHY_NO_3LED;
- if ((BGE_IS_5705_PLUS(sc)) &&
- sc->bge_asicrev != BGE_ASICREV_BCM5906 &&
- sc->bge_asicrev != BGE_ASICREV_BCM5717 &&
- sc->bge_asicrev != BGE_ASICREV_BCM5719 &&
- sc->bge_asicrev != BGE_ASICREV_BCM5720 &&
- sc->bge_asicrev != BGE_ASICREV_BCM5785 &&
- sc->bge_asicrev != BGE_ASICREV_BCM57765 &&
- sc->bge_asicrev != BGE_ASICREV_BCM57780) {
- if (sc->bge_asicrev == BGE_ASICREV_BCM5755 ||
- sc->bge_asicrev == BGE_ASICREV_BCM5761 ||
- sc->bge_asicrev == BGE_ASICREV_BCM5784 ||
- sc->bge_asicrev == BGE_ASICREV_BCM5787) {
- if (pci_get_device(dev) != BCOM_DEVICEID_BCM5722 &&
- pci_get_device(dev) != BCOM_DEVICEID_BCM5756)
- sc->bge_phy_flags |= BGE_PHY_JITTER_BUG;
- if (pci_get_device(dev) == BCOM_DEVICEID_BCM5755M)
- sc->bge_phy_flags |= BGE_PHY_ADJUST_TRIM;
- } else
- sc->bge_phy_flags |= BGE_PHY_BER_BUG;
- }
-
/* Identify the chips that use an CPMU. */
if (BGE_IS_5717_PLUS(sc) ||
sc->bge_asicrev == BGE_ASICREV_BCM5784 ||
@@ -3528,6 +3485,7 @@
sc->bge_asicrev == BGE_ASICREV_BCM5906) {
/* These chips are 10/100 only. */
capmask &= ~BMSR_EXTSTAT;
+ sc->bge_phy_flags |= BGE_PHY_NO_WIRESPEED;
}
/*
@@ -3785,12 +3743,55 @@
/* The SysKonnect SK-9D41 is a 1000baseSX card. */
if ((pci_read_config(dev, BGE_PCI_SUBSYS, 4) >> 16) ==
SK_SUBSYSID_9D41 || (hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) {
- if (BGE_IS_5705_PLUS(sc))
+ if (BGE_IS_5705_PLUS(sc)) {
sc->bge_flags |= BGE_FLAG_MII_SERDES;
- else
+ sc->bge_phy_flags |= BGE_PHY_NO_WIRESPEED;
+ } else
sc->bge_flags |= BGE_FLAG_TBI;
}
+ /* Set various PHY bug flags. */
+ if (sc->bge_chipid == BGE_CHIPID_BCM5701_A0 ||
+ sc->bge_chipid == BGE_CHIPID_BCM5701_B0)
+ sc->bge_phy_flags |= BGE_PHY_CRC_BUG;
+ if (sc->bge_chiprev == BGE_CHIPREV_5703_AX ||
+ sc->bge_chiprev == BGE_CHIPREV_5704_AX)
+ sc->bge_phy_flags |= BGE_PHY_ADC_BUG;
+ if (sc->bge_chipid == BGE_CHIPID_BCM5704_A0)
+ sc->bge_phy_flags |= BGE_PHY_5704_A0_BUG;
+ if (pci_get_subvendor(dev) == DELL_VENDORID)
+ sc->bge_phy_flags |= BGE_PHY_NO_3LED;
+ if ((BGE_IS_5705_PLUS(sc)) &&
+ sc->bge_asicrev != BGE_ASICREV_BCM5906 &&
+ sc->bge_asicrev != BGE_ASICREV_BCM5717 &&
+ sc->bge_asicrev != BGE_ASICREV_BCM5719 &&
+ sc->bge_asicrev != BGE_ASICREV_BCM5720 &&
+ sc->bge_asicrev != BGE_ASICREV_BCM5785 &&
+ sc->bge_asicrev != BGE_ASICREV_BCM57765 &&
+ sc->bge_asicrev != BGE_ASICREV_BCM57780) {
+ if (sc->bge_asicrev == BGE_ASICREV_BCM5755 ||
+ sc->bge_asicrev == BGE_ASICREV_BCM5761 ||
+ sc->bge_asicrev == BGE_ASICREV_BCM5784 ||
+ sc->bge_asicrev == BGE_ASICREV_BCM5787) {
+ if (pci_get_device(dev) != BCOM_DEVICEID_BCM5722 &&
+ pci_get_device(dev) != BCOM_DEVICEID_BCM5756)
+ sc->bge_phy_flags |= BGE_PHY_JITTER_BUG;
+ if (pci_get_device(dev) == BCOM_DEVICEID_BCM5755M)
+ sc->bge_phy_flags |= BGE_PHY_ADJUST_TRIM;
+ } else
+ sc->bge_phy_flags |= BGE_PHY_BER_BUG;
+ }
+
+ /*
+ * Don't enable Ethernet at WireSpeed for the 5700 or the
+ * 5705 A0 and A1 chips.
+ */
+ if (sc->bge_asicrev == BGE_ASICREV_BCM5700 ||
+ (sc->bge_asicrev == BGE_ASICREV_BCM5705 &&
+ (sc->bge_chipid != BGE_CHIPID_BCM5705_A0 &&
+ sc->bge_chipid != BGE_CHIPID_BCM5705_A1)))
+ sc->bge_phy_flags |= BGE_PHY_NO_WIRESPEED;
+
if (sc->bge_flags & BGE_FLAG_TBI) {
ifmedia_init(&sc->bge_ifmedia, IFM_IMASK, bge_ifmedia_upd,
bge_ifmedia_sts);
@@ -3814,13 +3815,13 @@
bge_asf_driver_up(sc);
error = mii_attach(dev, &sc->bge_miibus, ifp, bge_ifmedia_upd,
- bge_ifmedia_sts, capmask, phy_addr, MII_OFFSET_ANY,
+ bge_ifmedia_sts, capmask, sc->bge_phy_addr, MII_OFFSET_ANY,
MIIF_DOPAUSE);
if (error != 0) {
if (trys++ < 4) {
device_printf(sc->bge_dev, "Try again\n");
- bge_miibus_writereg(sc->bge_dev, 1, MII_BMCR,
- BMCR_RESET);
+ bge_miibus_writereg(sc->bge_dev,
+ sc->bge_phy_addr, MII_BMCR, BMCR_RESET);
goto again;
}
device_printf(sc->bge_dev, "attaching PHYs failed\n");
@@ -6042,9 +6043,10 @@
/* Clear the interrupt. */
CSR_WRITE_4(sc, BGE_MAC_EVT_ENB,
BGE_EVTENB_MI_INTERRUPT);
- bge_miibus_readreg(sc->bge_dev, 1, BRGPHY_MII_ISR);
- bge_miibus_writereg(sc->bge_dev, 1, BRGPHY_MII_IMR,
- BRGPHY_INTRS);
+ bge_miibus_readreg(sc->bge_dev, sc->bge_phy_addr,
+ BRGPHY_MII_ISR);
+ bge_miibus_writereg(sc->bge_dev, sc->bge_phy_addr,
+ BRGPHY_MII_IMR, BRGPHY_INTRS);
}
return;
}
Modified: trunk/sys/dev/bge/if_bgereg.h
===================================================================
--- trunk/sys/dev/bge/if_bgereg.h 2016-09-18 21:56:23 UTC (rev 8456)
+++ trunk/sys/dev/bge/if_bgereg.h 2016-09-18 21:57:12 UTC (rev 8457)
@@ -2984,6 +2984,7 @@
#define BGE_MFW_TYPE_DASH 0x00000008
int bge_phy_ape_lock;
int bge_func_addr;
+ int bge_phy_addr;
uint32_t bge_phy_flags;
#define BGE_PHY_NO_WIRESPEED 0x00000001
#define BGE_PHY_ADC_BUG 0x00000002
More information about the Midnightbsd-cvs
mailing list