if_hme.c (210334) | if_hme.c (213893) |
---|---|
1/*- 2 * Copyright (c) 1999 The NetBSD Foundation, Inc. 3 * Copyright (c) 2001-2003 Thomas Moestl <tmm@FreeBSD.org>. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Paul Kranenburg. 8 * --- 24 unchanged lines hidden (view full) --- 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 * 37 * from: NetBSD: hme.c,v 1.45 2005/02/18 00:22:11 heas Exp 38 */ 39 40#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1999 The NetBSD Foundation, Inc. 3 * Copyright (c) 2001-2003 Thomas Moestl <tmm@FreeBSD.org>. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Paul Kranenburg. 8 * --- 24 unchanged lines hidden (view full) --- 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 * 37 * from: NetBSD: hme.c,v 1.45 2005/02/18 00:22:11 heas Exp 38 */ 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/sys/dev/hme/if_hme.c 210334 2010-07-21 10:05:07Z attilio $"); | 41__FBSDID("$FreeBSD: head/sys/dev/hme/if_hme.c 213893 2010-10-15 14:52:11Z marius $"); |
42 43/* 44 * HME Ethernet module driver. 45 * 46 * The HME is e.g. part of the PCIO PCI multi function device. 47 * It supports TX gathering and TX and RX checksum offloading. 48 * RX buffers must be aligned at a programmable offset modulo 16. We choose 2 49 * for this offset: mbuf clusters are usually on about 2^11 boundaries, 2 bytes --- 260 unchanged lines hidden (view full) --- 310 ifp->if_ioctl = hme_ioctl; 311 ifp->if_init = hme_init; 312 IFQ_SET_MAXLEN(&ifp->if_snd, HME_NTXQ); 313 ifp->if_snd.ifq_drv_maxlen = HME_NTXQ; 314 IFQ_SET_READY(&ifp->if_snd); 315 316 hme_mifinit(sc); 317 | 42 43/* 44 * HME Ethernet module driver. 45 * 46 * The HME is e.g. part of the PCIO PCI multi function device. 47 * It supports TX gathering and TX and RX checksum offloading. 48 * RX buffers must be aligned at a programmable offset modulo 16. We choose 2 49 * for this offset: mbuf clusters are usually on about 2^11 boundaries, 2 bytes --- 260 unchanged lines hidden (view full) --- 310 ifp->if_ioctl = hme_ioctl; 311 ifp->if_init = hme_init; 312 IFQ_SET_MAXLEN(&ifp->if_snd, HME_NTXQ); 313 ifp->if_snd.ifq_drv_maxlen = HME_NTXQ; 314 IFQ_SET_READY(&ifp->if_snd); 315 316 hme_mifinit(sc); 317 |
318 if ((error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus, hme_mediachange, 319 hme_mediastatus)) != 0) { 320 device_printf(sc->sc_dev, "phy probe failed: %d\n", error); | 318 /* 319 * DP83840A used with HME chips don't advertise their media 320 * capabilities themselves properly so force writing the ANAR 321 * according to the BMSR in mii_phy_setmedia(). 322 */ 323 error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp, hme_mediachange, 324 hme_mediastatus, BMSR_DEFCAPMASK, HME_PHYAD_EXTERNAL, 325 MII_OFFSET_ANY, MIIF_FORCEANEG); 326 i = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp, hme_mediachange, 327 hme_mediastatus, BMSR_DEFCAPMASK, HME_PHYAD_INTERNAL, 328 MII_OFFSET_ANY, MIIF_FORCEANEG); 329 if (error != 0 && i != 0) { 330 error = ENXIO; 331 device_printf(sc->sc_dev, "attaching PHYs failed\n"); |
321 goto fail_rxdesc; 322 } 323 sc->sc_mii = device_get_softc(sc->sc_miibus); 324 325 /* 326 * Walk along the list of attached MII devices and 327 * establish an `MII instance' to `PHY number' 328 * mapping. We'll use this mapping to enable the MII --- 1070 unchanged lines hidden (view full) --- 1399 */ 1400int 1401hme_mii_readreg(device_t dev, int phy, int reg) 1402{ 1403 struct hme_softc *sc; 1404 int n; 1405 u_int32_t v; 1406 | 332 goto fail_rxdesc; 333 } 334 sc->sc_mii = device_get_softc(sc->sc_miibus); 335 336 /* 337 * Walk along the list of attached MII devices and 338 * establish an `MII instance' to `PHY number' 339 * mapping. We'll use this mapping to enable the MII --- 1070 unchanged lines hidden (view full) --- 1410 */ 1411int 1412hme_mii_readreg(device_t dev, int phy, int reg) 1413{ 1414 struct hme_softc *sc; 1415 int n; 1416 u_int32_t v; 1417 |
1407 /* We can at most have two PHYs. */ 1408 if (phy != HME_PHYAD_EXTERNAL && phy != HME_PHYAD_INTERNAL) 1409 return (0); 1410 | |
1411 sc = device_get_softc(dev); 1412 /* Select the desired PHY in the MIF configuration register */ 1413 v = HME_MIF_READ_4(sc, HME_MIFI_CFG); 1414 if (phy == HME_PHYAD_EXTERNAL) 1415 v |= HME_MIF_CFG_PHY; 1416 else 1417 v &= ~HME_MIF_CFG_PHY; 1418 HME_MIF_WRITE_4(sc, HME_MIFI_CFG, v); --- 21 unchanged lines hidden (view full) --- 1440 1441int 1442hme_mii_writereg(device_t dev, int phy, int reg, int val) 1443{ 1444 struct hme_softc *sc; 1445 int n; 1446 u_int32_t v; 1447 | 1418 sc = device_get_softc(dev); 1419 /* Select the desired PHY in the MIF configuration register */ 1420 v = HME_MIF_READ_4(sc, HME_MIFI_CFG); 1421 if (phy == HME_PHYAD_EXTERNAL) 1422 v |= HME_MIF_CFG_PHY; 1423 else 1424 v &= ~HME_MIF_CFG_PHY; 1425 HME_MIF_WRITE_4(sc, HME_MIFI_CFG, v); --- 21 unchanged lines hidden (view full) --- 1447 1448int 1449hme_mii_writereg(device_t dev, int phy, int reg, int val) 1450{ 1451 struct hme_softc *sc; 1452 int n; 1453 u_int32_t v; 1454 |
1448 /* We can at most have two PHYs. */ 1449 if (phy != HME_PHYAD_EXTERNAL && phy != HME_PHYAD_INTERNAL) 1450 return (0); 1451 | |
1452 sc = device_get_softc(dev); 1453 /* Select the desired PHY in the MIF configuration register */ 1454 v = HME_MIF_READ_4(sc, HME_MIFI_CFG); 1455 if (phy == HME_PHYAD_EXTERNAL) 1456 v |= HME_MIF_CFG_PHY; 1457 else 1458 v &= ~HME_MIF_CFG_PHY; 1459 HME_MIF_WRITE_4(sc, HME_MIFI_CFG, v); --- 279 unchanged lines hidden --- | 1455 sc = device_get_softc(dev); 1456 /* Select the desired PHY in the MIF configuration register */ 1457 v = HME_MIF_READ_4(sc, HME_MIFI_CFG); 1458 if (phy == HME_PHYAD_EXTERNAL) 1459 v |= HME_MIF_CFG_PHY; 1460 else 1461 v &= ~HME_MIF_CFG_PHY; 1462 HME_MIF_WRITE_4(sc, HME_MIFI_CFG, v); --- 279 unchanged lines hidden --- |