From owner-svn-src-all@FreeBSD.ORG Fri Apr 10 16:12:01 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9334B106566B; Fri, 10 Apr 2009 16:12:01 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F5CC8FC1C; Fri, 10 Apr 2009 16:12:01 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3AGC1cX053521; Fri, 10 Apr 2009 16:12:01 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3AGC1t4053520; Fri, 10 Apr 2009 16:12:01 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200904101612.n3AGC1t4053520@svn.freebsd.org> From: Warner Losh Date: Fri, 10 Apr 2009 16:12:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190900 - head/sys/dev/ed X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Apr 2009 16:12:02 -0000 Author: imp Date: Fri Apr 10 16:12:00 2009 New Revision: 190900 URL: http://svn.freebsd.org/changeset/base/190900 Log: Improvements for TC5299J MII support. Modified: head/sys/dev/ed/if_ed_pccard.c Modified: head/sys/dev/ed/if_ed_pccard.c ============================================================================== --- head/sys/dev/ed/if_ed_pccard.c Fri Apr 10 15:33:47 2009 (r190899) +++ head/sys/dev/ed/if_ed_pccard.c Fri Apr 10 16:12:00 2009 (r190900) @@ -258,7 +258,6 @@ static int ed_ifmedia_upd(struct ifnet * static void ed_ifmedia_sts(struct ifnet *, struct ifmediareq *); static int ed_pccard_tc5299j(device_t dev, const struct ed_product *); -static void ed_pccard_tc5299j_mii_reset(struct ed_softc *sc); static u_int ed_pccard_tc5299j_mii_readbits(struct ed_softc *sc, int nbits); static void ed_pccard_tc5299j_mii_writebits(struct ed_softc *sc, u_int val, int nbits); @@ -574,7 +573,6 @@ ed_pccard_attach(device_t dev) } } else if (sc->chip_type == ED_CHIP_TYPE_TC5299J) { - ed_pccard_tc5299j_mii_reset(sc); if ((error = mii_phy_probe(dev, &sc->miibus, ed_ifmedia_upd, ed_ifmedia_sts)) != 0) { device_printf(dev, "Missing mii!\n"); @@ -1009,36 +1007,24 @@ ed_pccard_tc5299j(device_t dev, const st return (0); } -/* MII bit-twiddling routines for cards using TC5299J chipset */ -#define TC5299J_MIISET(sc, x) ed_nic_outb(sc, ED_TC5299J_MIIBUS, \ - ed_nic_inb(sc, ED_TC5299J_MIIBUS) | (x)) -#define TC5299J_MIICLR(sc, x) ed_nic_outb(sc, ED_TC5299J_MIIBUS, \ - ed_nic_inb(sc, ED_TC5299J_MIIBUS) & ~(x)) - -static void -ed_pccard_tc5299j_mii_reset(struct ed_softc *sc) -{ - /* Do nothing! */ -} - static void ed_pccard_tc5299j_mii_writebits(struct ed_softc *sc, u_int val, int nbits) { int i; - uint8_t cr; + uint8_t cr, data; + /* Select page 3 */ cr = ed_nic_inb(sc, ED_P0_CR); ed_nic_outb(sc, ED_P0_CR, cr | ED_CR_PAGE_3); - TC5299J_MIICLR(sc, ED_TC5299J_MII_DIROUT); for (i = nbits - 1; i >= 0; i--) { - if ((val >> i) & 1) - TC5299J_MIISET(sc, ED_TC5299J_MII_DATAOUT); - else - TC5299J_MIICLR(sc, ED_TC5299J_MII_DATAOUT); - TC5299J_MIISET(sc, ED_TC5299J_MII_CLK); - TC5299J_MIICLR(sc, ED_TC5299J_MII_CLK); + data = (val >> i) & 1 ? ED_TC5299J_MII_DATAOUT : 0; + ed_nic_outb(sc, ED_TC5299J_MIIBUS, data); + ed_nic_outb(sc, ED_TC5299J_MIIBUS, data | ED_TC5299J_MII_CLK); } + ed_nic_outb(sc, ED_TC5299J_MIIBUS, 0); + + /* Restore prior page */ ed_nic_outb(sc, ED_P0_CR, cr); } @@ -1049,17 +1035,21 @@ ed_pccard_tc5299j_mii_readbits(struct ed u_int val = 0; uint8_t cr; + /* Select page 3 */ cr = ed_nic_inb(sc, ED_P0_CR); ed_nic_outb(sc, ED_P0_CR, cr | ED_CR_PAGE_3); - TC5299J_MIISET(sc, ED_TC5299J_MII_DIROUT); + ed_asic_outb(sc, ED_TC5299J_MIIBUS, ED_TC5299J_MII_DIROUT); for (i = nbits - 1; i >= 0; i--) { - TC5299J_MIISET(sc, ED_TC5299J_MII_CLK); + ed_nic_outb(sc, ED_TC5299J_MIIBUS, + ED_TC5299J_MII_CLK | ED_TC5299J_MII_DIROUT); val <<= 1; if (ed_nic_inb(sc, ED_TC5299J_MIIBUS) & ED_TC5299J_MII_DATAIN) val++; - TC5299J_MIICLR(sc, ED_TC5299J_MII_CLK); + ed_nic_outb(sc, ED_TC5299J_MIIBUS, ED_TC5299J_MII_DIROUT); } + + /* Restore prior page */ ed_nic_outb(sc, ED_P0_CR, cr); return val; }