Deleted Added
full compact
dcphy.c (146734) dcphy.c (150763)
1/*-
2 * Copyright (c) 1997, 1998, 1999
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) 1997, 1998, 1999
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/dc/dcphy.c 146734 2005-05-29 04:42:30Z nyan $");
34__FBSDID("$FreeBSD: head/sys/dev/dc/dcphy.c 150763 2005-09-30 19:39:27Z imp $");
35
36/*
37 * Pseudo-driver for internal NWAY support on DEC 21143 and workalike
38 * controllers. Technically we're abusing the miibus code to handle
39 * media selection and NWAY support here since there is no MII
40 * interface. However the logical operations are roughly the same,
41 * and the alternative is to create a fake MII interface in the driver,
42 * which is harder to do.

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

110DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0);
111
112static int dcphy_service(struct mii_softc *, struct mii_data *, int);
113static void dcphy_status(struct mii_softc *);
114static void dcphy_reset(struct mii_softc *);
115static int dcphy_auto(struct mii_softc *);
116
117static int
35
36/*
37 * Pseudo-driver for internal NWAY support on DEC 21143 and workalike
38 * controllers. Technically we're abusing the miibus code to handle
39 * media selection and NWAY support here since there is no MII
40 * interface. However the logical operations are roughly the same,
41 * and the alternative is to create a fake MII interface in the driver,
42 * which is harder to do.

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

110DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0);
111
112static int dcphy_service(struct mii_softc *, struct mii_data *, int);
113static void dcphy_status(struct mii_softc *);
114static void dcphy_reset(struct mii_softc *);
115static int dcphy_auto(struct mii_softc *);
116
117static int
118dcphy_probe(dev)
119 device_t dev;
118dcphy_probe(device_t dev)
120{
121 struct mii_attach_args *ma;
122
123 ma = device_get_ivars(dev);
124
125 /*
126 * The dc driver will report the 21143 vendor and device
127 * ID to let us know that it wants us to attach.
128 */
129 if (ma->mii_id1 != DC_VENDORID_DEC ||
130 ma->mii_id2 != DC_DEVICEID_21143)
131 return(ENXIO);
132
133 device_set_desc(dev, "Intel 21143 NWAY media interface");
134
135 return (0);
136}
137
138static int
119{
120 struct mii_attach_args *ma;
121
122 ma = device_get_ivars(dev);
123
124 /*
125 * The dc driver will report the 21143 vendor and device
126 * ID to let us know that it wants us to attach.
127 */
128 if (ma->mii_id1 != DC_VENDORID_DEC ||
129 ma->mii_id2 != DC_DEVICEID_21143)
130 return(ENXIO);
131
132 device_set_desc(dev, "Intel 21143 NWAY media interface");
133
134 return (0);
135}
136
137static int
139dcphy_attach(dev)
140 device_t dev;
138dcphy_attach(device_t dev)
141{
142 struct mii_softc *sc;
143 struct mii_attach_args *ma;
144 struct mii_data *mii;
145 struct dc_softc *dc_sc;
146
147 sc = device_get_softc(dev);
148 ma = device_get_ivars(dev);

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

195 printf("\n");
196#undef ADD
197
198 MIIBUS_MEDIAINIT(sc->mii_dev);
199 return(0);
200}
201
202static int
139{
140 struct mii_softc *sc;
141 struct mii_attach_args *ma;
142 struct mii_data *mii;
143 struct dc_softc *dc_sc;
144
145 sc = device_get_softc(dev);
146 ma = device_get_ivars(dev);

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

193 printf("\n");
194#undef ADD
195
196 MIIBUS_MEDIAINIT(sc->mii_dev);
197 return(0);
198}
199
200static int
203dcphy_service(sc, mii, cmd)
204 struct mii_softc *sc;
205 struct mii_data *mii;
206 int cmd;
201dcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
207{
208 struct dc_softc *dc_sc;
209 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
210 int reg;
211 u_int32_t mode;
212
213 dc_sc = mii->mii_ifp->if_softc;
214

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

332 dcphy_status(sc);
333
334 /* Callback if something changed. */
335 mii_phy_update(sc, cmd);
336 return (0);
337}
338
339static void
202{
203 struct dc_softc *dc_sc;
204 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
205 int reg;
206 u_int32_t mode;
207
208 dc_sc = mii->mii_ifp->if_softc;
209

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

327 dcphy_status(sc);
328
329 /* Callback if something changed. */
330 mii_phy_update(sc, cmd);
331 return (0);
332}
333
334static void
340dcphy_status(sc)
341 struct mii_softc *sc;
335dcphy_status(struct mii_softc *sc)
342{
343 struct mii_data *mii = sc->mii_pdata;
344 int reg, anlpar, tstat = 0;
345 struct dc_softc *dc_sc;
346
347 dc_sc = mii->mii_ifp->if_softc;
348
349 mii->mii_media_status = IFM_AVALID;

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

416 mii->mii_media_active |= IFM_100_TX;
417 if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_FULLDUPLEX)
418 mii->mii_media_active |= IFM_FDX;
419
420 return;
421}
422
423static int
336{
337 struct mii_data *mii = sc->mii_pdata;
338 int reg, anlpar, tstat = 0;
339 struct dc_softc *dc_sc;
340
341 dc_sc = mii->mii_ifp->if_softc;
342
343 mii->mii_media_status = IFM_AVALID;

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

410 mii->mii_media_active |= IFM_100_TX;
411 if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_FULLDUPLEX)
412 mii->mii_media_active |= IFM_FDX;
413
414 return;
415}
416
417static int
424dcphy_auto(mii)
425 struct mii_softc *mii;
418dcphy_auto(struct mii_softc *mii)
426{
427 struct dc_softc *sc;
428
429 sc = mii->mii_pdata->mii_ifp->if_softc;
430
431 DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
432 DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX);
433 DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET);

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

438 DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
439 DC_SETBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
440 DC_SETBIT(sc, DC_10BTSTAT, DC_ASTAT_TXDISABLE);
441
442 return(EJUSTRETURN);
443}
444
445static void
419{
420 struct dc_softc *sc;
421
422 sc = mii->mii_pdata->mii_ifp->if_softc;
423
424 DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
425 DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX);
426 DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET);

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

431 DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
432 DC_SETBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
433 DC_SETBIT(sc, DC_10BTSTAT, DC_ASTAT_TXDISABLE);
434
435 return(EJUSTRETURN);
436}
437
438static void
446dcphy_reset(mii)
447 struct mii_softc *mii;
439dcphy_reset(struct mii_softc *mii)
448{
449 struct dc_softc *sc;
450
451 sc = mii->mii_pdata->mii_ifp->if_softc;
452
453 DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET);
454 DELAY(1000);
455 DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
456
457 return;
458}
459
440{
441 struct dc_softc *sc;
442
443 sc = mii->mii_pdata->mii_ifp->if_softc;
444
445 DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET);
446 DELAY(1000);
447 DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
448
449 return;
450}
451