Author: siarzhuk Date: 2011-07-08 23:12:11 +0200 (Fri, 08 Jul 2011) New Revision: 42392 Changeset: https://dev.haiku-os.org/changeset/42392 Added: haiku/vendor/freebsd/RELEASE_8_2_0/dev/dc/ haiku/vendor/freebsd/RELEASE_8_2_0/dev/fxp/ haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/acphy.c haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/acphyreg.h haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/amphy.c haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/amphyreg.h haiku/vendor/freebsd/RELEASE_8_2_0/dev/xl/ haiku/vendor/freebsd/RELEASE_8_2_0/pci/ haiku/vendor/freebsd/RELEASE_8_2_0/pci/if_rl.c haiku/vendor/freebsd/RELEASE_8_2_0/pci/if_rlreg.h Modified: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphy.c haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphyreg.h haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/exphy.c haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/inphy.c haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/inphyreg.h haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/rlphy.c haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/ukphy.c haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/ukphy_subr.c Log: Just added updates for ipro100, 3com, dec21xxx, rtl8139 are tagged to RELEASE_8_2_0. Note: Modification of files in dev/mii - is result of previous incorrect tagging them to RELEASE_8_2_0 - original modules are not correspond to current state of this branch on FreeBSD. So this modification updates them to real RELEASE_8_2_0 version. Copied: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/acphy.c (from rev 42391, haiku/vendor/freebsd/current/dev/mii/acphy.c) =================================================================== --- haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/acphy.c (rev 0) +++ haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/acphy.c 2011-07-08 21:12:11 UTC (rev 42392) @@ -0,0 +1,261 @@ +/*- + * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*- + * Copyright (c) 1997 Manuel Bouyer. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD: src/sys/dev/mii/acphy.c,v 1.21.10.6.2.1 2010/12/21 17:09:25 kensmith Exp $"); + +/* + * Driver for Altima AC101 10/100 PHY + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/socket.h> +#include <sys/errno.h> +#include <sys/module.h> +#include <sys/bus.h> + +#include <net/if.h> +#include <net/if_media.h> + +#include <dev/mii/mii.h> +#include <dev/mii/miivar.h> +#include "miidevs.h" + +#include <dev/mii/acphyreg.h> + +#include "miibus_if.h" + +static int acphy_probe(device_t); +static int acphy_attach(device_t); + +static device_method_t acphy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, acphy_probe), + DEVMETHOD(device_attach, acphy_attach), + DEVMETHOD(device_detach, mii_phy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + { 0, 0 } +}; + +static devclass_t acphy_devclass; + +static driver_t acphy_driver = { + "acphy", + acphy_methods, + sizeof(struct mii_softc) +}; + +DRIVER_MODULE(acphy, miibus, acphy_driver, acphy_devclass, 0, 0); + +static int acphy_service(struct mii_softc *, struct mii_data *, int); +static void acphy_reset(struct mii_softc *); +static void acphy_status(struct mii_softc *); + +static const struct mii_phydesc acphys[] = { + MII_PHY_DESC(xxALTIMA, AC101), + MII_PHY_DESC(xxALTIMA, AC101L), + /* XXX This is reported to work, but it's not from any data sheet. */ + MII_PHY_DESC(xxALTIMA, ACXXX), + MII_PHY_END +}; + +static int +acphy_probe(device_t dev) +{ + + return (mii_phy_dev_probe(dev, acphys, BUS_PROBE_DEFAULT)); +} + +static int +acphy_attach(device_t dev) +{ + struct mii_softc *sc; + struct mii_attach_args *ma; + struct mii_data *mii; + + sc = device_get_softc(dev); + ma = device_get_ivars(dev); + sc->mii_dev = device_get_parent(dev); + mii = ma->mii_data; + LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); + + sc->mii_flags = miibus_get_flags(dev); + sc->mii_inst = mii->mii_instance++; + sc->mii_phy = ma->mii_phyno; + sc->mii_service = acphy_service; + sc->mii_pdata = mii; + + acphy_reset(sc); + + sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + device_printf(dev, " "); + +#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) + if ((PHY_READ(sc, MII_ACPHY_MCTL) & AC_MCTL_FX_SEL) != 0) { + sc->mii_flags |= MIIF_HAVEFIBER; + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_FX, 0, sc->mii_inst), + MII_MEDIA_100_TX); + printf("100baseFX, "); + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_FX, IFM_FDX, sc->mii_inst), + MII_MEDIA_100_TX_FDX); + printf("100baseFX-FDX, "); + } +#undef ADD + + mii_phy_add_media(sc); + printf("\n"); + + MIIBUS_MEDIAINIT(sc->mii_dev); + return (0); +} + +static int +acphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) +{ + int reg; + + switch (cmd) { + case MII_POLLSTAT: + break; + + case MII_MEDIACHG: + /* + * If the interface is not up, don't do anything. + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + break; + + /* Wake & deisolate up if necessary */ + reg = PHY_READ(sc, MII_BMCR); + if (reg & (BMCR_ISO | BMCR_PDOWN)) + PHY_WRITE(sc, MII_BMCR, reg & ~(BMCR_ISO | BMCR_PDOWN)); + + mii_phy_setmedia(sc); + break; + + case MII_TICK: + /* + * Is the interface even up? + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + return (0); + + /* + * This PHY's autonegotiation doesn't need to be kicked. + */ + break; + } + + /* Update the media status. */ + acphy_status(sc); + + /* Callback if something changed. */ + mii_phy_update(sc, cmd); + return (0); +} + +static void +acphy_status(struct mii_softc *sc) +{ + struct mii_data *mii = sc->mii_pdata; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; + int bmsr, bmcr, diag; + + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = IFM_ETHER; + + bmsr = PHY_READ(sc, MII_BMSR) | + PHY_READ(sc, MII_BMSR); + if (bmsr & BMSR_LINK) + mii->mii_media_status |= IFM_ACTIVE; + + bmcr = PHY_READ(sc, MII_BMCR); + if (bmcr & BMCR_ISO) { + mii->mii_media_active |= IFM_NONE; + mii->mii_media_status = 0; + return; + } + + if (bmcr & BMCR_LOOP) + mii->mii_media_active |= IFM_LOOP; + + if (bmcr & BMCR_AUTOEN) { + if ((bmsr & BMSR_ACOMP) == 0) { + /* Erg, still trying, I guess... */ + mii->mii_media_active |= IFM_NONE; + return; + } + diag = PHY_READ(sc, MII_ACPHY_DIAG); + if (diag & AC_DIAG_SPEED) + mii->mii_media_active |= IFM_100_TX; + else + mii->mii_media_active |= IFM_10_T; + + if (diag & AC_DIAG_DUPLEX) + mii->mii_media_active |= IFM_FDX; + else + mii->mii_media_active |= IFM_HDX; + } else + mii->mii_media_active = ife->ifm_media; +} + +static void +acphy_reset(struct mii_softc *sc) +{ + + mii_phy_reset(sc); + PHY_WRITE(sc, MII_ACPHY_INT, 0); +} Copied: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/acphyreg.h (from rev 42391, haiku/vendor/freebsd/current/dev/mii/acphyreg.h) =================================================================== --- haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/acphyreg.h (rev 0) +++ haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/acphyreg.h 2011-07-08 21:12:11 UTC (rev 42392) @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 2001 Semen Ustimenko (semenu@xxxxxxxxxxx) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/mii/acphyreg.h,v 1.2.10.1.6.1 2010/12/21 17:09:25 kensmith Exp $ + */ + +#ifndef _DEV_MII_ACPHYREG_H_ +#define _DEV_MII_ACPHYREG_H_ + +/* + * Register definitions for the Altima Communications AC101 + */ + +#define MII_ACPHY_POL 0x10 /* Polarity int level */ + +/* High byte is interrupt mask register */ +#define MII_ACPHY_INT 0x11 /* Interrupt control/status */ +#define AC_INT_ACOMP 0x0001 /* Autoneg complete */ +#define AC_INT_REM_FLT 0x0002 /* Remote fault */ +#define AC_INT_LINK_DOWN 0x0004 /* Link not OK */ +#define AC_INT_LP_ACK 0x0008 /* FLP ack recved */ +#define AC_INT_PD_FLT 0x0010 /* Parallel detect fault */ +#define AC_INT_PAGE_RECV 0x0020 /* New page recved */ +#define AC_INT_RX_ER 0x0040 /* RX_ER transitions high */ +#define AC_INT_JAB 0x0080 /* Jabber detected */ + +#define MII_ACPHY_DIAG 0x12 /* Diagnostic */ +#define AC_DIAG_RX_LOCK 0x0100 +#define AC_DIAG_RX_PASS 0x0200 +#define AC_DIAG_SPEED 0x0400 /* Aneg speed result */ +#define AC_DIAG_DUPLEX 0x0800 /* Aneg duplex result */ + +#define MII_ACPHY_PWRLOOP 0x13 /* Power/Loopback */ +#define MII_ACPHY_CBLMEAS 0x14 /* Cable meas. */ + +#define MII_ACPHY_MCTL 0x15 /* Mode control */ +#define AC_MCTL_FX_SEL 0x0001 /* FX mode */ +#define AC_MCTL_BYP_PCS 0x0002 /* Bypass PCS */ +#define AC_MCTL_SCRMBL 0x0004 /* Data scrambling */ +#define AC_MCTL_REM_LOOP 0x0008 /* Remote loopback */ +#define AC_MCTL_DIS_WDT 0x0010 /* Disable watchdog timer */ +#define AC_MCTL_DIS_REC 0x0020 /* Disable recv error counter */ +#define AC_MCTL_REC_FULL 0x0040 /* Recv error counter full */ +#define AC_MCTL_FRC_FEF 0x0080 /* Force Far End Fault Insert. */ +#define AC_MCTL_DIS_FEF 0x0100 /* Disable FEF Insertion */ +#define AC_MCTL_LED_SEL 0x0200 /* Compat LED config */ +#define AC_MCTL_ALED_SEL 0x0400 /* ActLED RX&TX - RX only */ +#define AC_MCTL_10BT_SEL 0x0800 /* Enable 7-wire interface */ +#define AC_MCTL_DIS_JAB 0x1000 /* Disable jabber */ +#define AC_MCTL_FRC_LINK 0x2000 /* Force TX link up */ +#define AC_MCTL_DIS_NLP 0x4000 /* Disable NLP check */ + +#define MII_ACPHY_REC 0x18 /* Recv error counter */ + +#endif /* _DEV_MII_ACPHYREG_H_ */ Copied: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/amphy.c (from rev 42391, haiku/vendor/freebsd/current/dev/mii/amphy.c) =================================================================== --- haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/amphy.c (rev 0) +++ haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/amphy.c 2011-07-08 21:12:11 UTC (rev 42392) @@ -0,0 +1,236 @@ +/*- + * Copyright (c) 1997, 1998, 1999 + * Bill Paul <wpaul@xxxxxxxxxxxxxxx>. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD: src/sys/dev/mii/amphy.c,v 1.24.2.5.2.1 2010/12/21 17:09:25 kensmith Exp $"); + +/* + * driver for AMD AM79c873 PHYs + * This driver also works for Davicom DM910{1,2} PHYs, which appear + * to be AM79c873 workalikes. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/module.h> +#include <sys/socket.h> +#include <sys/bus.h> + +#include <net/if.h> +#include <net/if_media.h> + +#include <dev/mii/mii.h> +#include <dev/mii/miivar.h> +#include "miidevs.h" + +#include <dev/mii/amphyreg.h> + +#include "miibus_if.h" + +static int amphy_probe(device_t); +static int amphy_attach(device_t); + +static device_method_t amphy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, amphy_probe), + DEVMETHOD(device_attach, amphy_attach), + DEVMETHOD(device_detach, mii_phy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + { 0, 0 } +}; + +static devclass_t amphy_devclass; + +static driver_t amphy_driver = { + "amphy", + amphy_methods, + sizeof(struct mii_softc) +}; + +DRIVER_MODULE(amphy, miibus, amphy_driver, amphy_devclass, 0, 0); + +static int amphy_service(struct mii_softc *, struct mii_data *, int); +static void amphy_status(struct mii_softc *); + +static const struct mii_phydesc amphys[] = { + MII_PHY_DESC(DAVICOM, DM9102), + MII_PHY_DESC(xxAMD, 79C873), + MII_PHY_DESC(xxDAVICOM, DM9101), + MII_PHY_END +}; + +static int +amphy_probe(device_t dev) +{ + + return (mii_phy_dev_probe(dev, amphys, BUS_PROBE_DEFAULT)); +} + +static int +amphy_attach(device_t dev) +{ + struct mii_softc *sc; + struct mii_attach_args *ma; + struct mii_data *mii; + + sc = device_get_softc(dev); + ma = device_get_ivars(dev); + sc->mii_dev = device_get_parent(dev); + mii = ma->mii_data; + LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); + + sc->mii_flags = miibus_get_flags(dev); + sc->mii_inst = mii->mii_instance++; + sc->mii_phy = ma->mii_phyno; + sc->mii_service = amphy_service; + sc->mii_pdata = mii; + +#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) + +#if 0 + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst), + MII_MEDIA_100_TX); +#endif + + mii_phy_reset(sc); + + sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + device_printf(dev, " "); + mii_phy_add_media(sc); + printf("\n"); +#undef ADD + MIIBUS_MEDIAINIT(sc->mii_dev); + return (0); +} + +static int +amphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) +{ + + switch (cmd) { + case MII_POLLSTAT: + break; + + case MII_MEDIACHG: + /* + * If the interface is not up, don't do anything. + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + break; + + mii_phy_setmedia(sc); + break; + + case MII_TICK: + if (mii_phy_tick(sc) == EJUSTRETURN) + return (0); + break; + } + + /* Update the media status. */ + amphy_status(sc); + + /* Callback if something changed. */ + mii_phy_update(sc, cmd); + return (0); +} + +static void +amphy_status(struct mii_softc *sc) +{ + struct mii_data *mii = sc->mii_pdata; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; + int bmsr, bmcr, par, anlpar; + + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = IFM_ETHER; + + bmsr = PHY_READ(sc, MII_BMSR) | + PHY_READ(sc, MII_BMSR); + if (bmsr & BMSR_LINK) + mii->mii_media_status |= IFM_ACTIVE; + + bmcr = PHY_READ(sc, MII_BMCR); + if (bmcr & BMCR_ISO) { + mii->mii_media_active |= IFM_NONE; + mii->mii_media_status = 0; + return; + } + + if (bmcr & BMCR_LOOP) + mii->mii_media_active |= IFM_LOOP; + + if (bmcr & BMCR_AUTOEN) { + /* + * The PAR status bits are only valid if autonegotiation + * has completed (or it's disabled). + */ + if ((bmsr & BMSR_ACOMP) == 0) { + /* Erg, still trying, I guess... */ + mii->mii_media_active |= IFM_NONE; + return; + } + + if (PHY_READ(sc, MII_ANER) & ANER_LPAN) { + anlpar = PHY_READ(sc, MII_ANAR) & + PHY_READ(sc, MII_ANLPAR); + if (anlpar & ANLPAR_TX_FD) + mii->mii_media_active |= IFM_100_TX|IFM_FDX; + else if (anlpar & ANLPAR_T4) + mii->mii_media_active |= IFM_100_T4|IFM_HDX; + else if (anlpar & ANLPAR_TX) + mii->mii_media_active |= IFM_100_TX|IFM_HDX; + else if (anlpar & ANLPAR_10_FD) + mii->mii_media_active |= IFM_10_T|IFM_FDX; + else if (anlpar & ANLPAR_10) + mii->mii_media_active |= IFM_10_T|IFM_HDX; + else + mii->mii_media_active |= IFM_NONE; + return; + } + + /* + * Link partner is not capable of autonegotiation. + */ + par = PHY_READ(sc, MII_AMPHY_DSCSR); + if (par & DSCSR_100FDX) + mii->mii_media_active |= IFM_100_TX|IFM_FDX; + else if (par & DSCSR_100HDX) + mii->mii_media_active |= IFM_100_TX|IFM_HDX; + else if (par & DSCSR_10FDX) + mii->mii_media_active |= IFM_10_T|IFM_HDX; + else if (par & DSCSR_10HDX) + mii->mii_media_active |= IFM_10_T|IFM_HDX; + } else + mii->mii_media_active = ife->ifm_media; +} Copied: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/amphyreg.h (from rev 42391, haiku/vendor/freebsd/current/dev/mii/amphyreg.h) =================================================================== --- haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/amphyreg.h (rev 0) +++ haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/amphyreg.h 2011-07-08 21:12:11 UTC (rev 42392) @@ -0,0 +1,84 @@ +/*- + * Copyright (c) 1997, 1998, 1999 + * Bill Paul <wpaul@xxxxxxxxxxxxxxx>. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/mii/amphyreg.h,v 1.2.22.1.6.1 2010/12/21 17:09:25 kensmith Exp $ + */ + +#ifndef _DEV_MII_AMTPHYREG_H_ +#define _DEV_MII_AMTPHYREG_H_ + +/* + * AMD Am79C873 registers. + */ + + +#define MII_AMPHY_DSCR 0x10 /* Specified configuration register */a +#define DSCR_BP4B5B 0x8000 /* Bypass 4B5B encoding */ +#define DSCR_BPSCR 0x4000 /* Bypass scrambler */ +#define DSCR_BPALIGN 0x2000 /* Bypass symbol alignment */ +#define DSCR_REPEATER 0x0800 /* Repeater mode */ +#define DSCR_TX 0x0400 /* TX/FX mode control */ +#define DSCR_UTP 0x0200 /* UTP/STP mode control */ +#define DSCR_CLK25MDIS 0x0100 /* CLK25M disable */ +#define DSCR_FGLNKTX 0x0080 /* Force good link at 100baseTX */ +#define DSCR_LINKLEDCTL 0x0020 /* Link LED control */ +#define DSCR_FDXLEDCTL 0x0010 /* FDX LED control */ +#define DSCR_SMRTS 0x0008 /* Reset state machine */ +#define DSCR_MFPSC 0x0004 /* Preamble surpression control */ +#define DSCR_SLEEP 0x0002 /* Sleep mode */ +#define DSCR_RLOUT 0x0001 /* Remote loopout control */ + +#define MII_AMPHY_DSCSR 0x11 /* Specified configuration and status */ +#define DSCSR_100FDX 0x8000 /* 100MBps full duplex */ +#define DSCSR_100HDX 0x4000 /* 100Mbps half duplex */ +#define DSCSR_10FDX 0x2000 /* 10Mbps full duplex */ +#define DSCSR_10HDX 0x1000 /* 10Mbps half duplex */ +#define DSCSR_PADDR 0x01F0 /* PHY address */ +#define DSCSR_ASTAT 0x000F /* Autonegotiation status */ + +#define ASTAT_COMPLETE 0x8 +#define ASTAT_PDLINK_READY_FAIL 0x7 +#define ASTAT_PDLINK_READY 0x6 +#define ASTAT_CONSTMATCH_FAIL 0x5 +#define ASTAT_CONSTMATCH 0x4 +#define ASTAT_ACKMATCH_FAIL 0x3 +#define ASTAT_ACKMATCH 0x2 +#define ASTAT_ABILITYMATCH 0x1 +#define ASTAT_IDLE 0x0 + +#define MII_AMPHY_T10CSRSCR 0x12 /* 10baseT configuration/status */ +#define T10CSRSCR_LPEN 0x4000 /* Link pulse enable */ +#define T10CSRSCR_HBE 0x2000 /* Heartbeat enable */ +#define T10CSRSCR_JABEN 0x0800 /* Jabber enable */ +#define T10CSRSCR_SER 0x0400 /* Serial mode enable */ +#define T10CSRSCR_POLR 0x0001 /* Polarity reversed */ + +#endif /* _DEV_MII_AMTPHYREG_H_ */ Modified: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphy.c =================================================================== --- haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphy.c 2011-07-08 20:06:13 UTC (rev 42391) +++ haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphy.c 2011-07-08 21:12:11 UTC (rev 42392) @@ -14,13 +14,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -46,11 +39,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Manuel Bouyer. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -68,7 +56,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/mii/bmtphy.c,v 1.12 2006/12/02 15:32:33 marius Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/mii/bmtphy.c,v 1.12.10.8.2.1 2010/12/21 17:09:25 kensmith Exp $"); /* * Driver for the Broadcom BCM5201/BCM5202 "Mini-Theta" PHYs. This also @@ -97,6 +85,11 @@ static int bmtphy_probe(device_t); static int bmtphy_attach(device_t); +struct bmtphy_softc { + struct mii_softc mii_sc; + int mii_model; +}; + static device_method_t bmtphy_methods[] = { /* Device interface */ DEVMETHOD(device_probe, bmtphy_probe), @@ -112,18 +105,21 @@ static driver_t bmtphy_driver = { "bmtphy", bmtphy_methods, - sizeof(struct mii_softc) + sizeof(struct bmtphy_softc) }; DRIVER_MODULE(bmtphy, miibus, bmtphy_driver, bmtphy_devclass, 0, 0); static int bmtphy_service(struct mii_softc *, struct mii_data *, int); static void bmtphy_status(struct mii_softc *); +static void bmtphy_reset(struct mii_softc *); static const struct mii_phydesc bmtphys_dp[] = { MII_PHY_DESC(BROADCOM, BCM4401), MII_PHY_DESC(BROADCOM, BCM5201), + MII_PHY_DESC(BROADCOM, BCM5214), MII_PHY_DESC(BROADCOM, BCM5221), + MII_PHY_DESC(BROADCOM, BCM5222), MII_PHY_END }; @@ -149,27 +145,31 @@ static int bmtphy_attach(device_t dev) { - struct mii_softc *sc; - struct mii_attach_args *ma; - struct mii_data *mii; + struct bmtphy_softc *bsc; + struct mii_softc *sc; + struct mii_attach_args *ma; + struct mii_data *mii; - sc = device_get_softc(dev); + bsc = device_get_softc(dev); + sc = &bsc->mii_sc; ma = device_get_ivars(dev); sc->mii_dev = device_get_parent(dev); - mii = device_get_softc(sc->mii_dev); + mii = ma->mii_data; LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); - sc->mii_inst = mii->mii_instance; + sc->mii_flags = miibus_get_flags(dev); + sc->mii_inst = mii->mii_instance++; sc->mii_phy = ma->mii_phyno; sc->mii_service = bmtphy_service; sc->mii_pdata = mii; - mii_phy_reset(sc); + sc->mii_flags |= MIIF_NOMANPAUSE; - mii->mii_instance++; + bsc->mii_model = MII_MODEL(ma->mii_id2); - sc->mii_capabilities = - PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + bmtphy_reset(sc); + + sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); mii_phy_add_media(sc); printf("\n"); @@ -182,32 +182,13 @@ static int bmtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { - struct ifmedia_entry *ife; - int reg; - ife = mii->mii_media.ifm_cur; - switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); break; case MII_MEDIACHG: /* - * If the media indicates a different PHY instance, - * isolate ourselves. - */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { - reg = PHY_READ(sc, MII_BMCR); - PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); - } - - /* * If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) @@ -217,11 +198,6 @@ break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); if (mii_phy_tick(sc) == EJUSTRETURN) return (0); break; @@ -232,16 +208,15 @@ /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); } static void bmtphy_status(struct mii_softc *sc) { - struct mii_data *mii; - struct ifmedia_entry *ife; - int bmsr, bmcr, aux_csr; + struct mii_data *mii; + struct ifmedia_entry *ife; + int bmsr, bmcr, aux_csr; mii = sc->mii_pdata; ife = mii->mii_media.ifm_cur; @@ -250,7 +225,6 @@ mii->mii_media_active = IFM_ETHER; bmsr = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); - aux_csr = PHY_READ(sc, MII_BMTPHY_AUX_CSR); if (bmsr & BMSR_LINK) mii->mii_media_status |= IFM_ACTIVE; @@ -276,12 +250,45 @@ return; } + aux_csr = PHY_READ(sc, MII_BMTPHY_AUX_CSR); if (aux_csr & AUX_CSR_SPEED) mii->mii_media_active |= IFM_100_TX; else mii->mii_media_active |= IFM_10_T; if (aux_csr & AUX_CSR_FDX) - mii->mii_media_active |= IFM_FDX; + mii->mii_media_active |= + IFM_FDX | mii_phy_flowstatus(sc); + else + mii->mii_media_active |= IFM_HDX; } else mii->mii_media_active = ife->ifm_media; } + +static void +bmtphy_reset(struct mii_softc *sc) +{ + struct bmtphy_softc *bsc; + u_int16_t data; + + bsc = (struct bmtphy_softc *)sc; + + mii_phy_reset(sc); + + if (bsc->mii_model == MII_MODEL_BROADCOM_BCM5221) { + /* Enable shadow register mode. */ + data = PHY_READ(sc, 0x1f); + PHY_WRITE(sc, 0x1f, data | 0x0080); + + /* Enable APD (Auto PowerDetect). */ + data = PHY_READ(sc, MII_BMTPHY_AUX2); + PHY_WRITE(sc, MII_BMTPHY_AUX2, data | 0x0020); + + /* Enable clocks across APD for Auto-MDIX functionality. */ + data = PHY_READ(sc, MII_BMTPHY_INTR); + PHY_WRITE(sc, MII_BMTPHY_INTR, data | 0x0004); + + /* Disable shadow register mode. */ + data = PHY_READ(sc, 0x1f); + PHY_WRITE(sc, 0x1f, data & ~0x0080); + } +} Property changes on: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphy.c ___________________________________________________________________ Added: svn:mergeinfo + /haiku/vendor/freebsd/current/dev/mii/bmtphy.c:42313-42391 Modified: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphyreg.h =================================================================== --- haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphyreg.h 2011-07-08 20:06:13 UTC (rev 42391) +++ haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphyreg.h 2011-07-08 21:12:11 UTC (rev 42392) @@ -13,13 +13,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -35,7 +28,7 @@ * * from NetBSD: bmtphyreg.h,v 1.1 2001/06/02 21:42:10 thorpej Exp * - * $FreeBSD: src/sys/dev/mii/bmtphyreg.h,v 1.2 2005/01/06 01:42:55 imp Exp $ + * $FreeBSD: src/sys/dev/mii/bmtphyreg.h,v 1.2.22.2.2.1 2010/12/21 17:09:25 kensmith Exp $ */ #ifndef _DEV_MII_BMTPHYREG_H_ Property changes on: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/bmtphyreg.h ___________________________________________________________________ Added: svn:mergeinfo + /haiku/vendor/freebsd/current/dev/mii/bmtphyreg.h:42313-42391 Modified: haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/exphy.c =================================================================== --- haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/exphy.c 2011-07-08 20:06:13 UTC (rev 42391) +++ haiku/vendor/freebsd/RELEASE_8_2_0/dev/mii/exphy.c 2011-07-08 21:12:11 UTC (rev 42392) @@ -16,13 +16,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -48,11 +41,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Manuel Bouyer. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -67,7 +55,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/mii/exphy.c,v 1.23 2007/01/12 23:17:43 marius Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/mii/exphy.c,v 1.23.10.5.2.1 2010/12/21 17:09:25 kensmith Exp $"); /* * driver for 3Com internal PHYs @@ -147,25 +135,18 @@ sc = device_get_softc(dev); [... truncated: 3871 lines follow ...]