From 1ec4c3a889b3ec01a7244d5bb80d4e817e0a69de Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Mon, 12 Feb 2007 23:58:52 +0000 Subject: Add BCM5701 A0/B0 CRC bug workaround. Magic values taken from Linux driver. --- sys/dev/bge/if_bge.c | 3 +++ sys/dev/bge/if_bgereg.h | 1 + sys/dev/mii/brgphy.c | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+) (limited to 'sys/dev') diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 58b5dbf9c9be..572ba466f852 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -2216,6 +2216,9 @@ bge_attach(device_t dev) } /* Set various bug flags. */ + if (sc->bge_chipid == BGE_CHIPID_BCM5701_A0 || + sc->bge_chipid == BGE_CHIPID_BCM5701_B0) + sc->bge_flags |= BGE_FLAG_CRC_BUG; if (sc->bge_chiprev == BGE_CHIPREV_5703_AX || sc->bge_chiprev == BGE_CHIPREV_5704_AX) sc->bge_flags |= BGE_FLAG_ADC_BUG; diff --git a/sys/dev/bge/if_bgereg.h b/sys/dev/bge/if_bgereg.h index fa577a0248d2..d77bd5c4250a 100644 --- a/sys/dev/bge/if_bgereg.h +++ b/sys/dev/bge/if_bgereg.h @@ -2467,6 +2467,7 @@ struct bge_softc { #define BGE_FLAG_JITTER_BUG 0x01000000 #define BGE_FLAG_BER_BUG 0x02000000 #define BGE_FLAG_ADJUST_TRIM 0x04000000 +#define BGE_FLAG_CRC_BUG 0x08000000 uint32_t bge_chipid; uint8_t bge_asicrev; uint8_t bge_chiprev; diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 37f40b1ced4c..3c56585f84d1 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -103,6 +103,7 @@ static void brgphy_fixup_5704_a0_bug(struct mii_softc *); static void brgphy_fixup_adc_bug(struct mii_softc *); static void brgphy_fixup_adjust_trim(struct mii_softc *); static void brgphy_fixup_ber_bug(struct mii_softc *); +static void brgphy_fixup_crc_bug(struct mii_softc *); static void brgphy_fixup_jitter_bug(struct mii_softc *); static void brgphy_ethernet_wirespeed(struct mii_softc *); static void brgphy_jumbo_settings(struct mii_softc *, u_long); @@ -611,6 +612,25 @@ brgphy_fixup_ber_bug(struct mii_softc *sc) PHY_WRITE(sc, dspcode[i].reg, dspcode[i].val); } +static void +brgphy_fixup_crc_bug(struct mii_softc *sc) +{ + static const struct { + int reg; + uint16_t val; + } dspcode[] = { + { BRGPHY_MII_DSP_ADDR_REG, 0x0a75 }, + { 0x1c, 0x8c68 }, + { 0x1c, 0x8d68 }, + { 0x1c, 0x8c68 }, + { 0, 0 }, + }; + int i; + + for (i = 0; dspcode[i].reg != 0; i++) + PHY_WRITE(sc, dspcode[i].reg, dspcode[i].val); +} + static void brgphy_fixup_jitter_bug(struct mii_softc *sc) { @@ -716,6 +736,8 @@ brgphy_reset(struct mii_softc *sc) brgphy_fixup_adjust_trim(sc); if (bge_sc->bge_flags & BGE_FLAG_BER_BUG) brgphy_fixup_ber_bug(sc); + if (bge_sc->bge_flags & BGE_FLAG_CRC_BUG) + brgphy_fixup_crc_bug(sc); if (bge_sc->bge_flags & BGE_FLAG_JITTER_BUG) brgphy_fixup_jitter_bug(sc); -- cgit v1.3