Deleted Added
full compact
if_xl.c (211717) if_xl.c (213893)
1/*-
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.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@ctr.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/xl/if_xl.c 211717 2010-08-23 19:18:50Z yongari $");
34__FBSDID("$FreeBSD: head/sys/dev/xl/if_xl.c 213893 2010-10-15 14:52:11Z marius $");
35
36/*
37 * 3Com 3c90x Etherlink XL PCI NIC driver
38 *
39 * Supports the 3Com "boomerang", "cyclone" and "hurricane" PCI
40 * bus-master chips (3c90x cards and embedded controllers) including
41 * the following:
42 *

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

518static int
519xl_miibus_readreg(device_t dev, int phy, int reg)
520{
521 struct xl_softc *sc;
522 struct xl_mii_frame frame;
523
524 sc = device_get_softc(dev);
525
35
36/*
37 * 3Com 3c90x Etherlink XL PCI NIC driver
38 *
39 * Supports the 3Com "boomerang", "cyclone" and "hurricane" PCI
40 * bus-master chips (3c90x cards and embedded controllers) including
41 * the following:
42 *

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

518static int
519xl_miibus_readreg(device_t dev, int phy, int reg)
520{
521 struct xl_softc *sc;
522 struct xl_mii_frame frame;
523
524 sc = device_get_softc(dev);
525
526 /*
527 * Pretend that PHYs are only available at MII address 24.
528 * This is to guard against problems with certain 3Com ASIC
529 * revisions that incorrectly map the internal transceiver
530 * control registers at all MII addresses. This can cause
531 * the miibus code to attach the same PHY several times over.
532 */
533 if ((sc->xl_flags & XL_FLAG_PHYOK) == 0 && phy != 24)
534 return (0);
535
536 bzero((char *)&frame, sizeof(frame));
537 frame.mii_phyaddr = phy;
538 frame.mii_regaddr = reg;
539
540 xl_mii_readreg(sc, &frame);
541
542 return (frame.mii_data);
543}
544
545static int
546xl_miibus_writereg(device_t dev, int phy, int reg, int data)
547{
548 struct xl_softc *sc;
549 struct xl_mii_frame frame;
550
551 sc = device_get_softc(dev);
552
526 bzero((char *)&frame, sizeof(frame));
527 frame.mii_phyaddr = phy;
528 frame.mii_regaddr = reg;
529
530 xl_mii_readreg(sc, &frame);
531
532 return (frame.mii_data);
533}
534
535static int
536xl_miibus_writereg(device_t dev, int phy, int reg, int data)
537{
538 struct xl_softc *sc;
539 struct xl_mii_frame frame;
540
541 sc = device_get_softc(dev);
542
553 if ((sc->xl_flags & XL_FLAG_PHYOK) == 0 && phy != 24)
554 return (0);
555
556 bzero((char *)&frame, sizeof(frame));
557 frame.mii_phyaddr = phy;
558 frame.mii_regaddr = reg;
559 frame.mii_data = data;
560
561 xl_mii_writereg(sc, &frame);
562
563 return (0);

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

1145static int
1146xl_attach(device_t dev)
1147{
1148 u_char eaddr[ETHER_ADDR_LEN];
1149 u_int16_t sinfo2, xcvr[2];
1150 struct xl_softc *sc;
1151 struct ifnet *ifp;
1152 int media, pmcap;
543 bzero((char *)&frame, sizeof(frame));
544 frame.mii_phyaddr = phy;
545 frame.mii_regaddr = reg;
546 frame.mii_data = data;
547
548 xl_mii_writereg(sc, &frame);
549
550 return (0);

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

1132static int
1133xl_attach(device_t dev)
1134{
1135 u_char eaddr[ETHER_ADDR_LEN];
1136 u_int16_t sinfo2, xcvr[2];
1137 struct xl_softc *sc;
1138 struct ifnet *ifp;
1139 int media, pmcap;
1153 int unit, error = 0, rid, res;
1140 int error = 0, phy, rid, res, unit;
1154 uint16_t did;
1155
1156 sc = device_get_softc(dev);
1157 sc->xl_dev = dev;
1158
1159 unit = device_get_unit(dev);
1160
1161 mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,

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

1462 xl_mediacheck(sc);
1463
1464 if (sc->xl_media & XL_MEDIAOPT_MII ||
1465 sc->xl_media & XL_MEDIAOPT_BTX ||
1466 sc->xl_media & XL_MEDIAOPT_BT4) {
1467 if (bootverbose)
1468 device_printf(dev, "found MII/AUTO\n");
1469 xl_setcfg(sc);
1141 uint16_t did;
1142
1143 sc = device_get_softc(dev);
1144 sc->xl_dev = dev;
1145
1146 unit = device_get_unit(dev);
1147
1148 mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,

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

1449 xl_mediacheck(sc);
1450
1451 if (sc->xl_media & XL_MEDIAOPT_MII ||
1452 sc->xl_media & XL_MEDIAOPT_BTX ||
1453 sc->xl_media & XL_MEDIAOPT_BT4) {
1454 if (bootverbose)
1455 device_printf(dev, "found MII/AUTO\n");
1456 xl_setcfg(sc);
1470 if (mii_phy_probe(dev, &sc->xl_miibus,
1471 xl_ifmedia_upd, xl_ifmedia_sts)) {
1472 device_printf(dev, "no PHY found!\n");
1473 error = ENXIO;
1457 /*
1458 * Attach PHYs only at MII address 24 if !XL_FLAG_PHYOK.
1459 * This is to guard against problems with certain 3Com ASIC
1460 * revisions that incorrectly map the internal transceiver
1461 * control registers at all MII addresses.
1462 */
1463 phy = MII_PHY_ANY;
1464 if ((sc->xl_flags & XL_FLAG_PHYOK) != 0)
1465 phy = 24;
1466 error = mii_attach(dev, &sc->xl_miibus, ifp, xl_ifmedia_upd,
1467 xl_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
1468 if (error != 0) {
1469 device_printf(dev, "attaching PHYs failed\n");
1474 goto fail;
1475 }
1476 goto done;
1477 }
1478
1479 /*
1480 * Sanity check. If the user has selected "auto" and this isn't
1481 * a 10/100 card of some kind, we need to force the transceiver

--- 1947 unchanged lines hidden ---
1470 goto fail;
1471 }
1472 goto done;
1473 }
1474
1475 /*
1476 * Sanity check. If the user has selected "auto" and this isn't
1477 * a 10/100 card of some kind, we need to force the transceiver

--- 1947 unchanged lines hidden ---