From: aaron Date: Fri, 17 Mar 2000 01:27:13 +0000 (+0000) Subject: Sync with FreeBSD. Also, fix a stupid bug where the dc driver was claiming X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=129bcaac66218ececb8d6d76d5d40e1f5c71b85c;p=openbsd Sync with FreeBSD. Also, fix a stupid bug where the dc driver was claiming all PCI interrupts (kind of a bad thing, noticed by jason@); from jason@ --- diff --git a/sys/dev/pci/if_dc.c b/sys/dev/pci/if_dc.c index 9b11f32df79..91e91f7a2db 100644 --- a/sys/dev/pci/if_dc.c +++ b/sys/dev/pci/if_dc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dc.c,v 1.10 2000/02/15 02:28:14 jason Exp $ */ +/* $OpenBSD: if_dc.c,v 1.11 2000/03/17 01:27:13 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -31,7 +31,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/pci/if_dc.c,v 1.5 2000/01/12 22:24:05 wpaul Exp $ + * $FreeBSD: src/sys/pci/if_dc.c,v 1.8 2000/03/09 19:28:19 rwatson Exp $ */ /* @@ -701,9 +701,10 @@ int dc_miibus_readreg(self, phy, reg) frame.mii_phyaddr = phy; frame.mii_regaddr = reg; - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + phy_reg = CSR_READ_4(sc, DC_NETCFG); + CSR_WRITE_4(sc, DC_NETCFG, phy_reg & ~DC_NETCFG_PORTSEL); dc_mii_readreg(sc, &frame); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + CSR_WRITE_4(sc, DC_NETCFG, phy_reg); return(frame.mii_data); } @@ -769,24 +770,32 @@ void dc_miibus_writereg(self, phy, reg, data) frame.mii_regaddr = reg; frame.mii_data = data; - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + phy_reg = CSR_READ_4(sc, DC_NETCFG); + CSR_WRITE_4(sc, DC_NETCFG, phy_reg & ~DC_NETCFG_PORTSEL); dc_mii_writereg(sc, &frame); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + CSR_WRITE_4(sc, DC_NETCFG, phy_reg); return; } void dc_miibus_statchg(self) - struct device *self; + struct device *self; { - struct dc_softc *sc = (struct dc_softc *)self; - struct mii_data *mii; + struct dc_softc *sc = (struct dc_softc *)self; + struct mii_data *mii; + struct ifmedia *ifm; if (DC_IS_ADMTEK(sc)) return; mii = &sc->sc_mii; - dc_setcfg(sc, mii->mii_media_active); - sc->dc_if_media = mii->mii_media_active; + ifm = &mii->mii_media; + if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) { + dc_setcfg(sc, ifm->ifm_media); + sc->dc_if_media = ifm->ifm_media; + } else { + dc_setcfg(sc, mii->mii_media_active); + sc->dc_if_media = mii->mii_media_active; + } return; } @@ -1110,7 +1119,8 @@ void dc_setcfg(sc, media) if (sc->dc_type == DC_TYPE_98713) DC_SETBIT(sc, DC_NETCFG, (DC_NETCFG_PCS| DC_NETCFG_SCRAMBLER)); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + if (!DC_IS_DAVICOM(sc)) + DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); } else { if (DC_IS_PNIC(sc)) { @@ -1132,7 +1142,8 @@ void dc_setcfg(sc, media) DC_NETCFG_PORTSEL|DC_NETCFG_SCRAMBLER)); if (sc->dc_type == DC_TYPE_98713) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PCS); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + if (!DC_IS_DAVICOM(sc)) + DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); } else { if (DC_IS_PNIC(sc)) { @@ -1146,6 +1157,20 @@ void dc_setcfg(sc, media) } } + /* + * If this is a Davicom DM9102A card with a DM9801 HomePNA + * PHY and we want HomePNA mode, set the portsel bit to turn + * on the external MII port. + */ + if (DC_IS_DAVICOM(sc)) { + if (IFM_SUBTYPE(media) == IFM_HPNA_1) { + DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + sc->dc_link = 1; + } else { + DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + } + } + if ((media & IFM_GMASK) == IFM_FDX) { DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX); if (sc->dc_pmode == DC_PMODE_SYM && DC_IS_PNIC(sc)) @@ -1455,7 +1480,11 @@ void dc_attach(parent, self, aux) } /* Save the cache line size. */ - sc->dc_cachesize = pci_conf_read(pc, pa->pa_tag, DC_PCI_CFLT) & 0xFF; + if (DC_IS_DAVICOM(sc)) + sc->dc_cachesize = 0; + else + sc->dc_cachesize = pci_conf_read(pc, pa->pa_tag, + DC_PCI_CFLT) & 0xFF; /* Reset the adapter. */ dc_reset(sc); @@ -1577,6 +1606,9 @@ void dc_attach(parent, self, aux) } else ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO); + if (DC_IS_DAVICOM(sc) && revision >= DC_REVISION_DM9102A) + ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_HPNA_1,0,NULL); + /* if (error && DC_IS_INTEL(sc)) { sc->dc_pmode = DC_PMODE_SYM; mii_phy_probe(dev, &sc->dc_miibus, @@ -2137,16 +2169,16 @@ int dc_intr(arg) if (!(ifp->if_flags & IFF_UP)) { if (CSR_READ_4(sc, DC_ISR) & DC_INTRS) dc_stop(sc); - return claimed; + return (claimed); } - claimed = 1; - /* Disable interrupts. */ CSR_WRITE_4(sc, DC_IMR, 0x00000000); while((status = CSR_READ_4(sc, DC_ISR)) & DC_INTRS) { + claimed = 1; + CSR_WRITE_4(sc, DC_ISR, status); if ((status & DC_INTRS) == 0) { claimed = 0; @@ -2219,7 +2251,7 @@ int dc_intr(arg) if (ifp->if_snd.ifq_head != NULL) dc_start(ifp); - return claimed; + return (claimed); } /* @@ -2406,7 +2438,7 @@ void dc_init(xsc) /* * Set cache alignment and burst length. */ - if (DC_IS_ASIX(sc)) + if (DC_IS_ASIX(sc) || DC_IS_DAVICOM(sc)) CSR_WRITE_4(sc, DC_BUSCTL, 0); else CSR_WRITE_4(sc, DC_BUSCTL, DC_BUSCTL_MRME|DC_BUSCTL_MRLE); @@ -2528,11 +2560,19 @@ int dc_ifmedia_upd(ifp) { struct dc_softc *sc; struct mii_data *mii; + struct ifmedia *ifm; sc = ifp->if_softc; mii = &sc->sc_mii; mii_mediachg(mii); - sc->dc_link = 0; + + ifm = &mii->mii_media; + + if (DC_IS_DAVICOM(sc) && + IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) + dc_setcfg(sc, ifm->ifm_media); + else + sc->dc_link = 0; return(0); } @@ -2546,10 +2586,19 @@ void dc_ifmedia_sts(ifp, ifmr) { struct dc_softc *sc; struct mii_data *mii; + struct ifmedia *ifm; sc = ifp->if_softc; mii = &sc->sc_mii; mii_pollstat(mii); + ifm = &mii->mii_media; + if (DC_IS_DAVICOM(sc)) { + if (IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) { + ifmr->ifm_active = ifm->ifm_media; + ifmr->ifm_status = 0; + return; + } + } ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_status = mii->mii_media_status; diff --git a/sys/dev/pci/if_dcreg.h b/sys/dev/pci/if_dcreg.h index 0bdfe65c47c..cc3d2bf68cb 100644 --- a/sys/dev/pci/if_dcreg.h +++ b/sys/dev/pci/if_dcreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dcreg.h,v 1.4 2000/01/09 01:20:35 jason Exp $ */ +/* $OpenBSD: if_dcreg.h,v 1.5 2000/03/17 01:27:14 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -31,7 +31,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/pci/if_dcreg.h,v 1.2 1999/12/13 21:45:12 wpaul Exp $ + * $FreeBSD: src/sys/pci/if_dcreg.h,v 1.3 2000/01/19 19:03:08 wpaul Exp $ */ /* @@ -709,6 +709,13 @@ struct dc_softc { #define DC_REVISION_88140 0x00 #define DC_REVISION_88141 0x10 +/* + * The DMA9102A has the same PCI device ID as the DM9102, + * but a higher revision code. + */ +#define DC_REVISION_DM9102 0x10 +#define DC_REVISION_DM9102A 0x30 + /* * PCI low memory base and low I/O base register, and * other PCI registers.