Deleted Added
full compact
smcphy.c (214262) smcphy.c (215297)
1/*-
2 * Copyright (c) 2006 Benno Rice. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 9 unchanged lines hidden (view full) ---

18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006 Benno Rice. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 9 unchanged lines hidden (view full) ---

18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include <sys/cdefs.h>
26__FBSDID("$FreeBSD: head/sys/dev/mii/smcphy.c 214262 2010-10-24 11:37:01Z marius $");
26__FBSDID("$FreeBSD: head/sys/dev/mii/smcphy.c 215297 2010-11-14 13:26:10Z marius $");
27
28/*
29 * Driver for the internal PHY on the SMSC LAN91C111.
30 */
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>

--- 14 unchanged lines hidden (view full) ---

49
50#include "miibus_if.h"
51
52static int smcphy_probe(device_t);
53static int smcphy_attach(device_t);
54
55static int smcphy_service(struct mii_softc *, struct mii_data *, int);
56static int smcphy_reset(struct mii_softc *);
27
28/*
29 * Driver for the internal PHY on the SMSC LAN91C111.
30 */
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>

--- 14 unchanged lines hidden (view full) ---

49
50#include "miibus_if.h"
51
52static int smcphy_probe(device_t);
53static int smcphy_attach(device_t);
54
55static int smcphy_service(struct mii_softc *, struct mii_data *, int);
56static int smcphy_reset(struct mii_softc *);
57static void smcphy_auto(struct mii_softc *);
57static void smcphy_auto(struct mii_softc *, int);
58
59static device_method_t smcphy_methods[] = {
60 /* device interface */
61 DEVMETHOD(device_probe, smcphy_probe),
62 DEVMETHOD(device_attach, smcphy_attach),
63 DEVMETHOD(device_detach, mii_phy_detach),
64 DEVMETHOD(device_shutdown, bus_generic_shutdown),
65

--- 77 unchanged lines hidden (view full) ---

143 /*
144 * If the interface is not up, don't do anything.
145 */
146 if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
147 break;
148
149 switch (IFM_SUBTYPE(ife->ifm_media)) {
150 case IFM_AUTO:
58
59static device_method_t smcphy_methods[] = {
60 /* device interface */
61 DEVMETHOD(device_probe, smcphy_probe),
62 DEVMETHOD(device_attach, smcphy_attach),
63 DEVMETHOD(device_detach, mii_phy_detach),
64 DEVMETHOD(device_shutdown, bus_generic_shutdown),
65

--- 77 unchanged lines hidden (view full) ---

143 /*
144 * If the interface is not up, don't do anything.
145 */
146 if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
147 break;
148
149 switch (IFM_SUBTYPE(ife->ifm_media)) {
150 case IFM_AUTO:
151 smcphy_auto(sc);
151 smcphy_auto(sc, ife->ifm_media);
152 break;
153
154 default:
155 mii_phy_setmedia(sc);
156 break;
157 }
158
159 break;

--- 22 unchanged lines hidden (view full) ---

182 if (++sc->mii_ticks <= MII_ANEGTICKS) {
183 break;
184 }
185
186 sc->mii_ticks = 0;
187 if (smcphy_reset(sc) != 0) {
188 device_printf(sc->mii_dev, "reset failed\n");
189 }
152 break;
153
154 default:
155 mii_phy_setmedia(sc);
156 break;
157 }
158
159 break;

--- 22 unchanged lines hidden (view full) ---

182 if (++sc->mii_ticks <= MII_ANEGTICKS) {
183 break;
184 }
185
186 sc->mii_ticks = 0;
187 if (smcphy_reset(sc) != 0) {
188 device_printf(sc->mii_dev, "reset failed\n");
189 }
190 smcphy_auto(sc);
190 smcphy_auto(sc, ife->ifm_media);
191 break;
192 }
193
194 /* Update the media status. */
195 ukphy_status(sc);
196
197 /* Callback if something changed. */
198 mii_phy_update(sc, cmd);

--- 19 unchanged lines hidden (view full) ---

218 return (EIO);
219 }
220
221 PHY_WRITE(sc, MII_BMCR, 0x3000);
222 return (0);
223}
224
225static void
191 break;
192 }
193
194 /* Update the media status. */
195 ukphy_status(sc);
196
197 /* Callback if something changed. */
198 mii_phy_update(sc, cmd);

--- 19 unchanged lines hidden (view full) ---

218 return (EIO);
219 }
220
221 PHY_WRITE(sc, MII_BMCR, 0x3000);
222 return (0);
223}
224
225static void
226smcphy_auto(struct mii_softc *sc)
226smcphy_auto(struct mii_softc *sc, int media)
227{
228 uint16_t anar;
229
230 anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) |
231 ANAR_CSMA;
227{
228 uint16_t anar;
229
230 anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) |
231 ANAR_CSMA;
232 if (sc->mii_flags & MIIF_DOPAUSE)
232 if ((media & IFM_FLOW) != 0 || (sc->mii_flags & MIIF_FORCEPAUSE) != 0)
233 anar |= ANAR_FC;
234 PHY_WRITE(sc, MII_ANAR, anar);
235 /* Apparently this helps. */
236 anar = PHY_READ(sc, MII_ANAR);
237 PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG);
238}
233 anar |= ANAR_FC;
234 PHY_WRITE(sc, MII_ANAR, anar);
235 /* Apparently this helps. */
236 anar = PHY_READ(sc, MII_ANAR);
237 PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG);
238}