Deleted Added
full compact
xmphy.c (139749) xmphy.c (150763)
1/*-
2 * Copyright (c) 2000
3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000
3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/dev/mii/xmphy.c 139749 2005-01-06 01:43:34Z imp $");
34__FBSDID("$FreeBSD: head/sys/dev/mii/xmphy.c 150763 2005-09-30 19:39:27Z imp $");
35
36/*
37 * driver for the XaQti XMAC II's internal PHY. This is sort of
38 * like a 10/100 PHY, except the only thing we're really autoselecting
39 * here is full/half duplex. Speed is always 1000mbps.
40 */
41
42#include <sys/param.h>

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

79
80DRIVER_MODULE(xmphy, miibus, xmphy_driver, xmphy_devclass, 0, 0);
81
82static int xmphy_service(struct mii_softc *, struct mii_data *, int);
83static void xmphy_status(struct mii_softc *);
84static int xmphy_mii_phy_auto(struct mii_softc *);
85
86static int
35
36/*
37 * driver for the XaQti XMAC II's internal PHY. This is sort of
38 * like a 10/100 PHY, except the only thing we're really autoselecting
39 * here is full/half duplex. Speed is always 1000mbps.
40 */
41
42#include <sys/param.h>

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

79
80DRIVER_MODULE(xmphy, miibus, xmphy_driver, xmphy_devclass, 0, 0);
81
82static int xmphy_service(struct mii_softc *, struct mii_data *, int);
83static void xmphy_status(struct mii_softc *);
84static int xmphy_mii_phy_auto(struct mii_softc *);
85
86static int
87xmphy_probe(dev)
88 device_t dev;
87xmphy_probe(device_t dev)
89{
90 struct mii_attach_args *ma;
91
92 ma = device_get_ivars(dev);
93
94 if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxXAQTI &&
95 MII_MODEL(ma->mii_id2) == MII_MODEL_XAQTI_XMACII) {
96 device_set_desc(dev, MII_STR_XAQTI_XMACII);

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

102 device_set_desc(dev, MII_STR_JATO_BASEX);
103 return(0);
104 }
105
106 return(ENXIO);
107}
108
109static int
88{
89 struct mii_attach_args *ma;
90
91 ma = device_get_ivars(dev);
92
93 if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxXAQTI &&
94 MII_MODEL(ma->mii_id2) == MII_MODEL_XAQTI_XMACII) {
95 device_set_desc(dev, MII_STR_XAQTI_XMACII);

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

101 device_set_desc(dev, MII_STR_JATO_BASEX);
102 return(0);
103 }
104
105 return(ENXIO);
106}
107
108static int
110xmphy_attach(dev)
111 device_t dev;
109xmphy_attach(device_t dev)
112{
113 struct mii_softc *sc;
114 struct mii_attach_args *ma;
115 struct mii_data *mii;
116 const char *sep = "";
117
118 sc = device_get_softc(dev);
119 ma = device_get_ivars(dev);

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

154#undef ADD
155#undef PRINT
156
157 MIIBUS_MEDIAINIT(sc->mii_dev);
158 return(0);
159}
160
161static int
110{
111 struct mii_softc *sc;
112 struct mii_attach_args *ma;
113 struct mii_data *mii;
114 const char *sep = "";
115
116 sc = device_get_softc(dev);
117 ma = device_get_ivars(dev);

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

152#undef ADD
153#undef PRINT
154
155 MIIBUS_MEDIAINIT(sc->mii_dev);
156 return(0);
157}
158
159static int
162xmphy_service(sc, mii, cmd)
163 struct mii_softc *sc;
164 struct mii_data *mii;
165 int cmd;
160xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
166{
167 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
168 int reg;
169
170 switch (cmd) {
171 case MII_POLLSTAT:
172 /*
173 * If we're not polling our PHY instance, just return.

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

267 xmphy_status(sc);
268
269 /* Callback if something changed. */
270 mii_phy_update(sc, cmd);
271 return (0);
272}
273
274static void
161{
162 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
163 int reg;
164
165 switch (cmd) {
166 case MII_POLLSTAT:
167 /*
168 * If we're not polling our PHY instance, just return.

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

262 xmphy_status(sc);
263
264 /* Callback if something changed. */
265 mii_phy_update(sc, cmd);
266 return (0);
267}
268
269static void
275xmphy_status(sc)
276 struct mii_softc *sc;
270xmphy_status(struct mii_softc *sc)
277{
278 struct mii_data *mii = sc->mii_pdata;
279 int bmsr, bmcr, anlpar;
280
281 mii->mii_media_status = IFM_AVALID;
282 mii->mii_media_active = IFM_ETHER;
283
284 bmsr = PHY_READ(sc, XMPHY_MII_BMSR) |

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

322 else
323 mii->mii_media_active |= IFM_HDX;
324
325 return;
326}
327
328
329static int
271{
272 struct mii_data *mii = sc->mii_pdata;
273 int bmsr, bmcr, anlpar;
274
275 mii->mii_media_status = IFM_AVALID;
276 mii->mii_media_active = IFM_ETHER;
277
278 bmsr = PHY_READ(sc, XMPHY_MII_BMSR) |

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

316 else
317 mii->mii_media_active |= IFM_HDX;
318
319 return;
320}
321
322
323static int
330xmphy_mii_phy_auto(mii)
331 struct mii_softc *mii;
324xmphy_mii_phy_auto(struct mii_softc *mii)
332{
333 int anar = 0;
334
335 anar = PHY_READ(mii, XMPHY_MII_ANAR);
336 anar |= XMPHY_ANAR_FDX|XMPHY_ANAR_HDX;
337 PHY_WRITE(mii, XMPHY_MII_ANAR, anar);
338 DELAY(1000);
339 PHY_WRITE(mii, XMPHY_MII_BMCR,
340 XMPHY_BMCR_AUTOEN | XMPHY_BMCR_STARTNEG);
341
342 return (EJUSTRETURN);
343}
325{
326 int anar = 0;
327
328 anar = PHY_READ(mii, XMPHY_MII_ANAR);
329 anar |= XMPHY_ANAR_FDX|XMPHY_ANAR_HDX;
330 PHY_WRITE(mii, XMPHY_MII_ANAR, anar);
331 DELAY(1000);
332 PHY_WRITE(mii, XMPHY_MII_BMCR,
333 XMPHY_BMCR_AUTOEN | XMPHY_BMCR_STARTNEG);
334
335 return (EJUSTRETURN);
336}