Exemplo n.º 1
0
static int
rgephy_attach(device_t dev)
{
	struct mii_softc *sc;
	u_int flags;

	sc = device_get_softc(dev);
	flags = 0;
	if (mii_dev_mac_match(dev, "re"))
		flags |= MIIF_PHYPRIV0;
	else if (mii_dev_mac_match(dev, "ure"))
		flags |= MIIF_PHYPRIV1;
	mii_phy_dev_attach(dev, flags, &rgephy_funcs, 0);

	/* RTL8169S do not report auto-sense; add manually. */
	sc->mii_capabilities = (PHY_READ(sc, MII_BMSR) | BMSR_ANEG) &
	    sc->mii_capmask;
	if (sc->mii_capabilities & BMSR_EXTSTAT)
		sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
	device_printf(dev, " ");
	mii_phy_add_media(sc);
	printf("\n");
	/*
	 * Allow IFM_FLAG0 to be set indicating that auto-negotiation with
	 * manual configuration, which is used to work around issues with
	 * certain setups by default, should not be triggered as it may in
	 * turn cause harm in some edge cases.
	 */
	sc->mii_pdata->mii_media.ifm_mask |= IFM_FLAG0;

	PHY_RESET(sc);

	MIIBUS_MEDIAINIT(sc->mii_dev);
	return (0);
}
Exemplo n.º 2
0
static int
rlphy_probe(device_t dev)
{
	int rv;

	rv = mii_phy_dev_probe(dev, rlphys, BUS_PROBE_DEFAULT);
	if (rv <= 0)
		return (rv);

	if (mii_dev_mac_match(dev, "rl") || mii_dev_mac_match(dev, "re"))
		return (mii_phy_dev_probe(dev, rlintphys, BUS_PROBE_DEFAULT));
	return (ENXIO);
}
Exemplo n.º 3
0
static int
jmphy_attach(device_t dev)
{
	u_int flags;

	flags = 0;
	if (mii_dev_mac_match(dev, "jme") &&
	    (miibus_get_flags(dev) & MIIF_MACPRIV0) != 0)
		flags |= MIIF_PHYPRIV0;
	mii_phy_dev_attach(dev, flags, &jmphy_funcs, 1);
	return (0);
}
Exemplo n.º 4
0
static int
e1000phy_attach(device_t dev)
{
	struct mii_softc *sc;

	sc = device_get_softc(dev);

	mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &e1000phy_funcs, 0);

	if (mii_dev_mac_match(dev, "msk") &&
	    (sc->mii_flags & MIIF_MACPRIV0) != 0)
		sc->mii_flags |= MIIF_PHYPRIV0;

	switch (sc->mii_mpd_model) {
	case MII_MODEL_xxMARVELL_E1011:
	case MII_MODEL_xxMARVELL_E1112:
		if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK)
			sc->mii_flags |= MIIF_HAVEFIBER;
		break;
	case MII_MODEL_xxMARVELL_E1149:
	case MII_MODEL_xxMARVELL_E1149R:
		/*
		 * Some 88E1149 PHY's page select is initialized to
		 * point to other bank instead of copper/fiber bank
		 * which in turn resulted in wrong registers were
		 * accessed during PHY operation. It is believed that
		 * page 0 should be used for copper PHY so reinitialize
		 * E1000_EADR to select default copper PHY. If parent
		 * device know the type of PHY(either copper or fiber),
		 * that information should be used to select default
		 * type of PHY.
		 */
		PHY_WRITE(sc, E1000_EADR, 0);
		break;
	}

	PHY_RESET(sc);

	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
	if (sc->mii_capabilities & BMSR_EXTSTAT) {
		sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
		if ((sc->mii_extcapabilities &
		    (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
			sc->mii_flags |= MIIF_HAVE_GTCR;
	}
	device_printf(dev, " ");
	mii_phy_add_media(sc);
	printf("\n");

	MIIBUS_MEDIAINIT(sc->mii_dev);
	return (0);
}
Exemplo n.º 5
0
static int
nsphy_attach(device_t dev)
{
	u_int flags;

	flags = MIIF_NOMANPAUSE;
	/*
	 * Am79C971 wedge when isolating all of their external PHYs.
	 */
	if (mii_dev_mac_match(dev,"pcn"))
		flags |= MIIF_NOISOLATE;
	mii_phy_dev_attach(dev, flags, &nsphy_funcs, 1);
	return (0);
}
Exemplo n.º 6
0
static int
ip1000phy_attach(device_t dev)
{
	struct mii_attach_args *ma;
	u_int flags;

	ma = device_get_ivars(dev);
	flags = MIIF_NOISOLATE | MIIF_NOMANPAUSE;
	if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxICPLUS_IP1000A &&
	     mii_dev_mac_match(dev, "stge") &&
	     (miibus_get_flags(dev) & MIIF_MACPRIV0) != 0)
		flags |= MIIF_PHYPRIV0;
	mii_phy_dev_attach(dev, flags, &ip1000phy_funcs, 1);
	return (0);
}
Exemplo n.º 7
0
/* Attach the PHY to the MII bus */
static int
brgphy_attach(device_t dev)
{
    struct brgphy_softc *bsc;
    struct bge_softc *bge_sc = NULL;
    struct bce_softc *bce_sc = NULL;
    struct mii_softc *sc;

    bsc = device_get_softc(dev);
    sc = &bsc->mii_sc;

    mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
                       &brgphy_funcs, 0);

    bsc->serdes_flags = 0;

    /* Find the MAC driver associated with this PHY. */
    if (mii_dev_mac_match(dev, "bge"))
        bge_sc = mii_dev_mac_softc(dev);
    else if (mii_dev_mac_match(dev, "bce"))
        bce_sc = mii_dev_mac_softc(dev);

    /* Handle any special cases based on the PHY ID */
    switch (sc->mii_mpd_oui) {
    case MII_OUI_BROADCOM:
        switch (sc->mii_mpd_model) {
        case MII_MODEL_BROADCOM_BCM5706:
        case MII_MODEL_BROADCOM_BCM5714:
            /*
             * The 5464 PHY used in the 5706 supports both copper
             * and fiber interfaces over GMII.  Need to check the
             * shadow registers to see which mode is actually
             * in effect, and therefore whether we have 5706C or
             * 5706S.
             */
            PHY_WRITE(sc, BRGPHY_MII_SHADOW_1C,
                      BRGPHY_SHADOW_1C_MODE_CTRL);
            if (PHY_READ(sc, BRGPHY_MII_SHADOW_1C) &
                    BRGPHY_SHADOW_1C_ENA_1000X) {
                bsc->serdes_flags |= BRGPHY_5706S;
                sc->mii_flags |= MIIF_HAVEFIBER;
            }
            break;
        }
        break;
    case MII_OUI_BROADCOM2:
        switch (sc->mii_mpd_model) {
        case MII_MODEL_BROADCOM2_BCM5708S:
            bsc->serdes_flags |= BRGPHY_5708S;
            sc->mii_flags |= MIIF_HAVEFIBER;
            break;
        case MII_MODEL_BROADCOM2_BCM5709S:
            /*
             * XXX
             * 5720S and 5709S shares the same PHY id.
             * Assume 5720S PHY if parent device is bge(4).
             */
            if (bge_sc != NULL)
                bsc->serdes_flags |= BRGPHY_5708S;
            else
                bsc->serdes_flags |= BRGPHY_5709S;
            sc->mii_flags |= MIIF_HAVEFIBER;
            break;
        }
        break;
    }

    PHY_RESET(sc);

    /* Read the PHY's capabilities. */
    sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
    if (sc->mii_capabilities & BMSR_EXTSTAT)
        sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
    device_printf(dev, " ");

    /* Add the supported media types */
    if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
        mii_phy_add_media(sc);
        printf("\n");
    } else {
        sc->mii_anegticks = MII_ANEGTICKS_GIGE;
        ifmedia_add(&sc->mii_pdata->mii_media,
                    IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, IFM_FDX, sc->mii_inst),
                    0, NULL);
        printf("1000baseSX-FDX, ");
        /*
         * 2.5G support is a software enabled feature
         * on the 5708S and 5709S.
         */
        if (bce_sc && (bce_sc->bce_phy_flags &
                       BCE_PHY_2_5G_CAPABLE_FLAG)) {
            ifmedia_add(&sc->mii_pdata->mii_media,
                        IFM_MAKEWORD(IFM_ETHER, IFM_2500_SX, IFM_FDX,
                                     sc->mii_inst), 0, NULL);
            printf("2500baseSX-FDX, ");
        } else if ((bsc->serdes_flags & BRGPHY_5708S) && bce_sc &&
                   (detect_hs21(bce_sc) != 0)) {
            /*
             * There appears to be certain silicon revision
             * in IBM HS21 blades that is having issues with
             * this driver wating for the auto-negotiation to
             * complete. This happens with a specific chip id
             * only and when the 1000baseSX-FDX is the only
             * mode. Workaround this issue since it's unlikely
             * to be ever addressed.
             */
            printf("auto-neg workaround, ");
            bsc->serdes_flags |= BRGPHY_NOANWAIT;
        }
        ifmedia_add(&sc->mii_pdata->mii_media, IFM_MAKEWORD(IFM_ETHER,
                    IFM_AUTO, 0, sc->mii_inst), 0, NULL);
        printf("auto\n");
    }

    MIIBUS_MEDIAINIT(sc->mii_dev);
    return (0);
}