bge: For dual mode PHY controllers, make sure to enable GMII
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 29 Jun 2012 08:16:54 +0000 (16:16 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 29 Jun 2012 08:16:54 +0000 (16:16 +0800)
Obtained-from: OpenBSD via FreeBSD 202293

sys/dev/netif/bge/if_bge.c
sys/dev/netif/bge/if_bgereg.h

index b53523d..20c2350 100644 (file)
@@ -743,7 +743,8 @@ bge_miibus_statchg(device_t dev)
        mii = device_get_softc(sc->bge_miibus);
 
        BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE);
-       if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) {
+       if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T ||
+           IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_SX) {
                BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_GMII);
        } else {
                BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_MII);
@@ -1665,13 +1666,20 @@ bge_blockinit(struct bge_softc *sc)
        if (!BGE_IS_5705_PLUS(sc))
                CSR_WRITE_4(sc, BGE_RXLS_MODE, BGE_RXLSMODE_ENABLE);
 
+       val = BGE_MACMODE_TXDMA_ENB | BGE_MACMODE_RXDMA_ENB |
+           BGE_MACMODE_RX_STATS_CLEAR | BGE_MACMODE_TX_STATS_CLEAR |
+           BGE_MACMODE_RX_STATS_ENB | BGE_MACMODE_TX_STATS_ENB |
+           BGE_MACMODE_FRMHDR_DMA_ENB;
+
+       if (sc->bge_flags & BGE_FLAG_TBI)
+               val |= BGE_PORTMODE_TBI;
+       else if (sc->bge_flags & BGE_FLAG_MII_SERDES)
+               val |= BGE_PORTMODE_GMII;
+       else
+               val |= BGE_PORTMODE_MII;
+
        /* Turn on DMA, clear stats */
-       CSR_WRITE_4(sc, BGE_MAC_MODE, BGE_MACMODE_TXDMA_ENB|
-           BGE_MACMODE_RXDMA_ENB|BGE_MACMODE_RX_STATS_CLEAR|
-           BGE_MACMODE_TX_STATS_CLEAR|BGE_MACMODE_RX_STATS_ENB|
-           BGE_MACMODE_TX_STATS_ENB|BGE_MACMODE_FRMHDR_DMA_ENB|
-           ((sc->bge_flags & BGE_FLAG_TBI) ?
-            BGE_PORTMODE_TBI : BGE_PORTMODE_MII));
+       CSR_WRITE_4(sc, BGE_MAC_MODE, val);
 
        /* Set misc. local control, enable interrupts on attentions */
        CSR_WRITE_4(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_INTR_ONATTN);
@@ -2090,12 +2098,14 @@ bge_attach(device_t dev)
                hwcfg = ntohl(hwcfg);
        }
 
-       if ((hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER)
-               sc->bge_flags |= BGE_FLAG_TBI;
-
        /* The SysKonnect SK-9D41 is a 1000baseSX card. */
-       if (pci_get_subvendor(dev) == PCI_PRODUCT_SCHNEIDERKOCH_SK_9D41)
-               sc->bge_flags |= BGE_FLAG_TBI;
+       if (pci_get_subvendor(dev) == PCI_PRODUCT_SCHNEIDERKOCH_SK_9D41 ||
+           (hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) {
+               if (BGE_IS_5714_FAMILY(sc))
+                       sc->bge_flags |= BGE_FLAG_MII_SERDES;
+               else
+                       sc->bge_flags |= BGE_FLAG_TBI;
+       }
 
        if (sc->bge_flags & BGE_FLAG_TBI) {
                ifmedia_init(&sc->bge_ifmedia, IFM_IMASK,
index 2718646..3a3753a 100644 (file)
@@ -2456,6 +2456,7 @@ struct bge_softc {
 #define BGE_FLAG_TBI           0x00000001
 #define BGE_FLAG_JUMBO         0x00000002
 #define BGE_FLAG_ETH_WIRESPEED 0x00000004
+#define BGE_FLAG_MII_SERDES    0x00000010
 #define BGE_FLAG_MSI           0x00000100      /* unused */
 #define BGE_FLAG_PCIX          0x00000200
 #define BGE_FLAG_PCIE          0x00000400