Home | History | Annotate | Line # | Download | only in mii
ipgphy.c revision 1.9
      1  1.9  msaitoh /*	$NetBSD: ipgphy.c,v 1.9 2020/01/14 09:49:26 msaitoh Exp $ */
      2  1.1  msaitoh /*	$OpenBSD: ipgphy.c,v 1.19 2015/07/19 06:28:12 yuo Exp $	*/
      3  1.1  msaitoh 
      4  1.1  msaitoh /*-
      5  1.1  msaitoh  * Copyright (c) 2006, Pyun YongHyeon <yongari (at) FreeBSD.org>
      6  1.1  msaitoh  * All rights reserved.
      7  1.1  msaitoh  *
      8  1.1  msaitoh  * Redistribution and use in source and binary forms, with or without
      9  1.1  msaitoh  * modification, are permitted provided that the following conditions
     10  1.1  msaitoh  * are met:
     11  1.1  msaitoh  * 1. Redistributions of source code must retain the above copyright
     12  1.1  msaitoh  *    notice unmodified, this list of conditions, and the following
     13  1.1  msaitoh  *    disclaimer.
     14  1.1  msaitoh  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  msaitoh  *    notice, this list of conditions and the following disclaimer in the
     16  1.1  msaitoh  *    documentation and/or other materials provided with the distribution.
     17  1.1  msaitoh  *
     18  1.1  msaitoh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     19  1.1  msaitoh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  1.1  msaitoh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  1.1  msaitoh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     22  1.1  msaitoh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  1.1  msaitoh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  1.1  msaitoh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  1.1  msaitoh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  1.1  msaitoh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  1.1  msaitoh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  1.1  msaitoh  * SUCH DAMAGE.
     29  1.1  msaitoh  *
     30  1.1  msaitoh  */
     31  1.1  msaitoh 
     32  1.1  msaitoh /*
     33  1.1  msaitoh  * Driver for the IC Plus IP1000A/IP1001 10/100/1000 PHY.
     34  1.1  msaitoh  */
     35  1.1  msaitoh #include <sys/cdefs.h>
     36  1.9  msaitoh __KERNEL_RCSID(0, "$NetBSD: ipgphy.c,v 1.9 2020/01/14 09:49:26 msaitoh Exp $");
     37  1.1  msaitoh 
     38  1.1  msaitoh #include <sys/param.h>
     39  1.1  msaitoh #include <sys/systm.h>
     40  1.1  msaitoh #include <sys/kernel.h>
     41  1.1  msaitoh #include <sys/device.h>
     42  1.1  msaitoh #include <sys/socket.h>
     43  1.1  msaitoh #include <sys/errno.h>
     44  1.9  msaitoh #include <prop/proplib.h>
     45  1.1  msaitoh 
     46  1.1  msaitoh #include <net/if.h>
     47  1.1  msaitoh #include <net/if_media.h>
     48  1.1  msaitoh 
     49  1.1  msaitoh #include <dev/mii/mii.h>
     50  1.1  msaitoh #include <dev/mii/miivar.h>
     51  1.1  msaitoh #include <dev/mii/miidevs.h>
     52  1.1  msaitoh 
     53  1.1  msaitoh #include <dev/mii/ipgphyreg.h>
     54  1.1  msaitoh 
     55  1.1  msaitoh static int ipgphy_match(device_t, cfdata_t, void *);
     56  1.1  msaitoh static void ipgphy_attach(device_t, device_t, void *);
     57  1.1  msaitoh 
     58  1.9  msaitoh struct ipgphy_softc {
     59  1.9  msaitoh 	struct mii_softc sc_mii;
     60  1.9  msaitoh 	bool need_loaddspcode;
     61  1.9  msaitoh };
     62  1.9  msaitoh 
     63  1.9  msaitoh CFATTACH_DECL_NEW(ipgphy, sizeof(struct ipgphy_softc),
     64  1.1  msaitoh     ipgphy_match, ipgphy_attach, mii_phy_detach, mii_phy_activate);
     65  1.1  msaitoh 
     66  1.1  msaitoh static int	ipgphy_service(struct mii_softc *, struct mii_data *, int);
     67  1.1  msaitoh static void	ipgphy_status(struct mii_softc *);
     68  1.4  msaitoh static int	ipgphy_mii_phy_auto(struct mii_softc *, u_int);
     69  1.1  msaitoh static void	ipgphy_load_dspcode(struct mii_softc *);
     70  1.1  msaitoh static void	ipgphy_reset(struct mii_softc *);
     71  1.1  msaitoh 
     72  1.1  msaitoh static const struct mii_phy_funcs ipgphy_funcs = {
     73  1.1  msaitoh 	ipgphy_service, ipgphy_status, ipgphy_reset,
     74  1.1  msaitoh };
     75  1.1  msaitoh 
     76  1.1  msaitoh static const struct mii_phydesc ipgphys[] = {
     77  1.1  msaitoh 	MII_PHY_DESC(xxICPLUS, IP1000A),
     78  1.1  msaitoh 	MII_PHY_DESC(xxICPLUS, IP1001),
     79  1.1  msaitoh 	MII_PHY_END,
     80  1.1  msaitoh };
     81  1.1  msaitoh 
     82  1.1  msaitoh static int
     83  1.1  msaitoh ipgphy_match(device_t parent, cfdata_t match, void *aux)
     84  1.1  msaitoh {
     85  1.1  msaitoh 	struct mii_attach_args *ma = aux;
     86  1.1  msaitoh 
     87  1.2  msaitoh 	if (mii_phy_match(ma, ipgphys) != NULL)
     88  1.1  msaitoh 		return 10;
     89  1.2  msaitoh 
     90  1.1  msaitoh 	return 0;
     91  1.1  msaitoh }
     92  1.1  msaitoh 
     93  1.1  msaitoh static void
     94  1.1  msaitoh ipgphy_attach(device_t parent, device_t self, void *aux)
     95  1.1  msaitoh {
     96  1.9  msaitoh 	struct ipgphy_softc *isc = device_private(self);
     97  1.9  msaitoh 	struct mii_softc *sc = &isc->sc_mii;
     98  1.1  msaitoh 	struct mii_attach_args *ma = aux;
     99  1.1  msaitoh 	struct mii_data *mii = ma->mii_data;
    100  1.1  msaitoh 	const struct mii_phydesc *mpd;
    101  1.9  msaitoh 	prop_dictionary_t dict;
    102  1.1  msaitoh 
    103  1.1  msaitoh 	mpd = mii_phy_match(ma, ipgphys);
    104  1.1  msaitoh 	aprint_naive(": Media interface\n");
    105  1.1  msaitoh 	aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
    106  1.1  msaitoh 
    107  1.1  msaitoh 	sc->mii_dev = self;
    108  1.1  msaitoh 	sc->mii_inst = mii->mii_instance;
    109  1.1  msaitoh 	sc->mii_phy = ma->mii_phyno;
    110  1.1  msaitoh 	sc->mii_mpd_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
    111  1.1  msaitoh 	sc->mii_mpd_model = MII_MODEL(ma->mii_id2);
    112  1.1  msaitoh 	sc->mii_mpd_rev = MII_REV(ma->mii_id2);
    113  1.1  msaitoh 	sc->mii_funcs = &ipgphy_funcs;
    114  1.1  msaitoh 	sc->mii_pdata = mii;
    115  1.1  msaitoh 	sc->mii_flags = ma->mii_flags;
    116  1.9  msaitoh 	sc->mii_flags |= MIIF_NOISOLATE;
    117  1.1  msaitoh 
    118  1.9  msaitoh 	if (device_is_a(parent, "stge")) {
    119  1.9  msaitoh 		dict = device_properties(parent);
    120  1.9  msaitoh 		prop_dictionary_get_bool(dict, "need_loaddspcode",
    121  1.9  msaitoh 		    &isc->need_loaddspcode);
    122  1.9  msaitoh 	}
    123  1.1  msaitoh 
    124  1.1  msaitoh 	PHY_RESET(sc);
    125  1.1  msaitoh 
    126  1.1  msaitoh 	PHY_READ(sc, MII_BMSR, &sc->mii_capabilities);
    127  1.1  msaitoh 	sc->mii_capabilities &= ma->mii_capmask;
    128  1.1  msaitoh 	//sc->mii_capabilities &= ~BMSR_ANEG;
    129  1.1  msaitoh 	if (sc->mii_capabilities & BMSR_EXTSTAT)
    130  1.1  msaitoh 		PHY_READ(sc, MII_EXTSR, &sc->mii_extcapabilities);
    131  1.6  msaitoh 
    132  1.1  msaitoh 	mii_phy_add_media(sc);
    133  1.1  msaitoh }
    134  1.1  msaitoh 
    135  1.1  msaitoh static int
    136  1.1  msaitoh ipgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
    137  1.1  msaitoh {
    138  1.1  msaitoh 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
    139  1.4  msaitoh 	uint16_t reg, speed;
    140  1.1  msaitoh 
    141  1.1  msaitoh 	switch (cmd) {
    142  1.1  msaitoh 	case MII_POLLSTAT:
    143  1.2  msaitoh 		/* If we're not polling our PHY instance, just return. */
    144  1.1  msaitoh 		if (IFM_INST(ife->ifm_media) != sc->mii_inst)
    145  1.1  msaitoh 			return 0;
    146  1.1  msaitoh 		break;
    147  1.1  msaitoh 
    148  1.1  msaitoh 	case MII_MEDIACHG:
    149  1.1  msaitoh 		/*
    150  1.1  msaitoh 		 * If the media indicates a different PHY instance,
    151  1.1  msaitoh 		 * isolate ourselves.
    152  1.1  msaitoh 		 */
    153  1.1  msaitoh 		if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
    154  1.1  msaitoh 			PHY_READ(sc, MII_BMCR, &reg);
    155  1.1  msaitoh 			PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
    156  1.1  msaitoh 			return 0;
    157  1.1  msaitoh 		}
    158  1.1  msaitoh 
    159  1.2  msaitoh 		/* If the interface is not up, don't do anything. */
    160  1.1  msaitoh 		if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
    161  1.1  msaitoh 			break;
    162  1.1  msaitoh 
    163  1.1  msaitoh 		PHY_RESET(sc);
    164  1.1  msaitoh 
    165  1.1  msaitoh 		switch (IFM_SUBTYPE(ife->ifm_media)) {
    166  1.1  msaitoh 		case IFM_AUTO:
    167  1.1  msaitoh 		case IFM_1000_T:
    168  1.1  msaitoh 			/*
    169  1.4  msaitoh 			 * This device is required to do auto negotiation
    170  1.4  msaitoh 			 * on 1000BASE-T.
    171  1.1  msaitoh 			 */
    172  1.4  msaitoh 			(void)ipgphy_mii_phy_auto(sc, ife->ifm_media);
    173  1.4  msaitoh 			goto done;
    174  1.1  msaitoh 			break;
    175  1.1  msaitoh 
    176  1.1  msaitoh 		case IFM_100_TX:
    177  1.1  msaitoh 			speed = BMCR_S100;
    178  1.1  msaitoh 			break;
    179  1.1  msaitoh 
    180  1.1  msaitoh 		case IFM_10_T:
    181  1.1  msaitoh 			speed = BMCR_S10;
    182  1.1  msaitoh 			break;
    183  1.1  msaitoh 
    184  1.1  msaitoh 		default:
    185  1.1  msaitoh 			return EINVAL;
    186  1.1  msaitoh 		}
    187  1.1  msaitoh 
    188  1.4  msaitoh 		if ((ife->ifm_media & IFM_FDX) != 0)
    189  1.1  msaitoh 			speed |= BMCR_FDX;
    190  1.1  msaitoh 
    191  1.1  msaitoh 		PHY_WRITE(sc, MII_100T2CR, 0);
    192  1.1  msaitoh 		PHY_WRITE(sc, MII_BMCR, speed);
    193  1.1  msaitoh done:
    194  1.1  msaitoh 		break;
    195  1.1  msaitoh 
    196  1.1  msaitoh 	case MII_TICK:
    197  1.2  msaitoh 		/* If we're not currently selected, just return. */
    198  1.1  msaitoh 		if (IFM_INST(ife->ifm_media) != sc->mii_inst)
    199  1.1  msaitoh 			return 0;
    200  1.1  msaitoh 
    201  1.2  msaitoh 		/* Is the interface even up? */
    202  1.1  msaitoh 		if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
    203  1.1  msaitoh 			return 0;
    204  1.1  msaitoh 
    205  1.2  msaitoh 		/* Only used for autonegotiation. */
    206  1.4  msaitoh 		if ((IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) &&
    207  1.4  msaitoh 		    (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)) {
    208  1.1  msaitoh 			sc->mii_ticks = 0;
    209  1.1  msaitoh 			break;
    210  1.1  msaitoh 		}
    211  1.1  msaitoh 
    212  1.1  msaitoh 		/*
    213  1.1  msaitoh 		 * Check to see if we have link.  If we do, we don't
    214  1.1  msaitoh 		 * need to restart the autonegotiation process.  Read
    215  1.1  msaitoh 		 * the BMSR twice in case it's latched.
    216  1.1  msaitoh 		 */
    217  1.1  msaitoh 		PHY_READ(sc, MII_BMSR, &reg);
    218  1.1  msaitoh 		PHY_READ(sc, MII_BMSR, &reg);
    219  1.1  msaitoh 		if (reg & BMSR_LINK) {
    220  1.1  msaitoh 			/*
    221  1.1  msaitoh 			 * Reset autonegotiation timer to 0 in case the link
    222  1.1  msaitoh 			 * goes down in the next tick.
    223  1.1  msaitoh 			 */
    224  1.1  msaitoh 			sc->mii_ticks = 0;
    225  1.1  msaitoh 			/* See above. */
    226  1.1  msaitoh 			break;
    227  1.1  msaitoh 		}
    228  1.1  msaitoh 
    229  1.1  msaitoh 		/* Announce link loss right after it happens */
    230  1.1  msaitoh 		if (sc->mii_ticks++ == 0)
    231  1.1  msaitoh 			break;
    232  1.1  msaitoh 
    233  1.2  msaitoh 		/* Only retry autonegotiation every mii_anegticks seconds. */
    234  1.1  msaitoh 		if (sc->mii_ticks <= sc->mii_anegticks)
    235  1.1  msaitoh 			break;
    236  1.1  msaitoh 
    237  1.1  msaitoh 		sc->mii_ticks = 0;
    238  1.4  msaitoh 		ipgphy_mii_phy_auto(sc, ife->ifm_media);
    239  1.1  msaitoh 		break;
    240  1.1  msaitoh 	}
    241  1.1  msaitoh 
    242  1.1  msaitoh 	/* Update the media status. */
    243  1.1  msaitoh 	ipgphy_status(sc);
    244  1.1  msaitoh 
    245  1.1  msaitoh 	/* Callback if something changed. */
    246  1.1  msaitoh 	mii_phy_update(sc, cmd);
    247  1.1  msaitoh 	return 0;
    248  1.1  msaitoh }
    249  1.1  msaitoh 
    250  1.1  msaitoh static void
    251  1.1  msaitoh ipgphy_status(struct mii_softc *sc)
    252  1.1  msaitoh {
    253  1.1  msaitoh 	struct mii_data *mii = sc->mii_pdata;
    254  1.1  msaitoh 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
    255  1.1  msaitoh 	uint16_t bmsr, bmcr, stat, gtsr;
    256  1.1  msaitoh 
    257  1.3  msaitoh 	/* For IP1000A, use generic way */
    258  1.3  msaitoh 	if (sc->mii_mpd_model == MII_MODEL_xxICPLUS_IP1000A) {
    259  1.3  msaitoh 		ukphy_status(sc);
    260  1.3  msaitoh 		return;
    261  1.3  msaitoh 	}
    262  1.3  msaitoh 
    263  1.1  msaitoh 	mii->mii_media_status = IFM_AVALID;
    264  1.1  msaitoh 	mii->mii_media_active = IFM_ETHER;
    265  1.1  msaitoh 
    266  1.1  msaitoh 	PHY_READ(sc, MII_BMSR, &bmsr);
    267  1.1  msaitoh 	PHY_READ(sc, MII_BMSR, &bmsr);
    268  1.6  msaitoh 	if (bmsr & BMSR_LINK)
    269  1.1  msaitoh 		mii->mii_media_status |= IFM_ACTIVE;
    270  1.1  msaitoh 
    271  1.1  msaitoh 	PHY_READ(sc, MII_BMCR, &bmcr);
    272  1.1  msaitoh 	if (bmcr & BMCR_LOOP)
    273  1.1  msaitoh 		mii->mii_media_active |= IFM_LOOP;
    274  1.1  msaitoh 
    275  1.1  msaitoh 	if (bmcr & BMCR_AUTOEN) {
    276  1.1  msaitoh 		if ((bmsr & BMSR_ACOMP) == 0) {
    277  1.1  msaitoh 			/* Erg, still trying, I guess... */
    278  1.1  msaitoh 			mii->mii_media_active |= IFM_NONE;
    279  1.1  msaitoh 			return;
    280  1.1  msaitoh 		}
    281  1.1  msaitoh 
    282  1.3  msaitoh 		PHY_READ(sc, IPGPHY_LSR, &stat);
    283  1.3  msaitoh 		switch (stat & IPGPHY_LSR_SPEED_MASK) {
    284  1.3  msaitoh 		case IPGPHY_LSR_SPEED_10:
    285  1.3  msaitoh 			mii->mii_media_active |= IFM_10_T;
    286  1.3  msaitoh 			break;
    287  1.3  msaitoh 		case IPGPHY_LSR_SPEED_100:
    288  1.3  msaitoh 			mii->mii_media_active |= IFM_100_TX;
    289  1.3  msaitoh 			break;
    290  1.3  msaitoh 		case IPGPHY_LSR_SPEED_1000:
    291  1.3  msaitoh 			mii->mii_media_active |= IFM_1000_T;
    292  1.3  msaitoh 			break;
    293  1.3  msaitoh 		default:
    294  1.3  msaitoh 			mii->mii_media_active |= IFM_NONE;
    295  1.3  msaitoh 			return;
    296  1.1  msaitoh 		}
    297  1.1  msaitoh 
    298  1.3  msaitoh 		if (stat & IPGPHY_LSR_FULL_DUPLEX)
    299  1.3  msaitoh 			mii->mii_media_active |= IFM_FDX;
    300  1.3  msaitoh 		else
    301  1.3  msaitoh 			mii->mii_media_active |= IFM_HDX;
    302  1.3  msaitoh 
    303  1.1  msaitoh 		if (mii->mii_media_active & IFM_FDX)
    304  1.1  msaitoh 			mii->mii_media_active |= mii_phy_flowstatus(sc);
    305  1.1  msaitoh 
    306  1.1  msaitoh 		if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) {
    307  1.1  msaitoh 			PHY_READ(sc, MII_100T2SR, &gtsr);
    308  1.1  msaitoh 			if (gtsr & GTSR_MS_RES)
    309  1.1  msaitoh 				mii->mii_media_active |= IFM_ETH_MASTER;
    310  1.1  msaitoh 		}
    311  1.1  msaitoh 	} else
    312  1.1  msaitoh 		mii->mii_media_active = ife->ifm_media;
    313  1.1  msaitoh }
    314  1.1  msaitoh 
    315  1.1  msaitoh static int
    316  1.4  msaitoh ipgphy_mii_phy_auto(struct mii_softc *sc, u_int media)
    317  1.1  msaitoh {
    318  1.1  msaitoh 	uint16_t reg = 0;
    319  1.4  msaitoh 	u_int subtype = IFM_SUBTYPE(media);
    320  1.1  msaitoh 
    321  1.4  msaitoh 	/* XXX Is it requreid ? */
    322  1.1  msaitoh 	if (sc->mii_mpd_model == MII_MODEL_xxICPLUS_IP1001) {
    323  1.1  msaitoh 		PHY_READ(sc, MII_ANAR, &reg);
    324  1.1  msaitoh 		reg &= ~(ANAR_PAUSE_SYM | ANAR_PAUSE_ASYM);
    325  1.1  msaitoh 		reg |= ANAR_NP;
    326  1.1  msaitoh 	}
    327  1.1  msaitoh 
    328  1.4  msaitoh 	if (subtype == IFM_AUTO)
    329  1.4  msaitoh 		reg |= ANAR_10 | ANAR_10_FD | ANAR_TX | ANAR_TX_FD;
    330  1.1  msaitoh 
    331  1.1  msaitoh 	if (sc->mii_flags & MIIF_DOPAUSE)
    332  1.1  msaitoh 		reg |= ANAR_PAUSE_SYM | ANAR_PAUSE_ASYM;
    333  1.1  msaitoh 
    334  1.1  msaitoh 	PHY_WRITE(sc, MII_ANAR, reg | ANAR_CSMA);
    335  1.1  msaitoh 
    336  1.4  msaitoh 	if (subtype == IFM_AUTO)
    337  1.4  msaitoh 		reg = GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX;
    338  1.4  msaitoh 	else if (subtype == IFM_1000_T) {
    339  1.4  msaitoh 		if ((media & IFM_FDX) != 0)
    340  1.4  msaitoh 			reg = GTCR_ADV_1000TFDX;
    341  1.4  msaitoh 		else
    342  1.4  msaitoh 			reg = GTCR_ADV_1000THDX;
    343  1.4  msaitoh 	} else
    344  1.4  msaitoh 		reg = 0;
    345  1.4  msaitoh 
    346  1.1  msaitoh 	PHY_WRITE(sc, MII_100T2CR, reg);
    347  1.1  msaitoh 
    348  1.1  msaitoh 	PHY_WRITE(sc, MII_BMCR, BMCR_FDX | BMCR_AUTOEN | BMCR_STARTNEG);
    349  1.1  msaitoh 
    350  1.1  msaitoh 	return EJUSTRETURN;
    351  1.1  msaitoh }
    352  1.1  msaitoh 
    353  1.1  msaitoh static void
    354  1.1  msaitoh ipgphy_load_dspcode(struct mii_softc *sc)
    355  1.1  msaitoh {
    356  1.9  msaitoh 
    357  1.1  msaitoh 	PHY_WRITE(sc, 31, 0x0001);
    358  1.1  msaitoh 	PHY_WRITE(sc, 27, 0x01e0);
    359  1.1  msaitoh 	PHY_WRITE(sc, 31, 0x0002);
    360  1.1  msaitoh 	PHY_WRITE(sc, 27, 0xeb8e);
    361  1.1  msaitoh 	PHY_WRITE(sc, 31, 0x0000);
    362  1.1  msaitoh 	PHY_WRITE(sc, 30, 0x005e);
    363  1.1  msaitoh 	PHY_WRITE(sc, 9, 0x0700);
    364  1.1  msaitoh 
    365  1.1  msaitoh 	DELAY(50);
    366  1.1  msaitoh }
    367  1.1  msaitoh 
    368  1.1  msaitoh static void
    369  1.1  msaitoh ipgphy_reset(struct mii_softc *sc)
    370  1.1  msaitoh {
    371  1.9  msaitoh 	struct ipgphy_softc *isc = device_private(sc->mii_dev);
    372  1.1  msaitoh 	uint16_t reg;
    373  1.1  msaitoh 
    374  1.1  msaitoh 	mii_phy_reset(sc);
    375  1.1  msaitoh 
    376  1.2  msaitoh 	/* Clear autoneg/full-duplex as we don't want it after reset */
    377  1.1  msaitoh 	PHY_READ(sc, MII_BMCR, &reg);
    378  1.1  msaitoh 	reg &= ~(BMCR_AUTOEN | BMCR_FDX);
    379  1.1  msaitoh 	PHY_WRITE(sc, MII_BMCR, reg);
    380  1.1  msaitoh 
    381  1.9  msaitoh 	if (isc->need_loaddspcode)
    382  1.9  msaitoh 		ipgphy_load_dspcode(sc);
    383  1.1  msaitoh }
    384