Deleted Added
full compact
if_dc.c (213841) if_dc.c (213893)
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/if_dc.c 213841 2010-10-14 17:22:38Z yongari $");
34__FBSDID("$FreeBSD: head/sys/dev/dc/if_dc.c 213893 2010-10-15 14:52:11Z marius $");
35
36/*
37 * DEC "tulip" clone ethernet driver. Supports the DEC/Intel 21143
38 * series chips and several workalikes including the following:
39 *
40 * Macronix 98713/98715/98725/98727/98732 PMAC (www.macronix.com)
41 * Macronix/Lite-On 82c115 PNIC II (www.macronix.com)
42 * Lite-On 82c168/82c169 PNIC (www.litecom.com)

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

774{
775 struct dc_mii_frame frame;
776 struct dc_softc *sc;
777 int i, rval, phy_reg = 0;
778
779 sc = device_get_softc(dev);
780 bzero(&frame, sizeof(frame));
781
35
36/*
37 * DEC "tulip" clone ethernet driver. Supports the DEC/Intel 21143
38 * series chips and several workalikes including the following:
39 *
40 * Macronix 98713/98715/98725/98727/98732 PMAC (www.macronix.com)
41 * Macronix/Lite-On 82c115 PNIC II (www.macronix.com)
42 * Lite-On 82c168/82c169 PNIC (www.litecom.com)

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

774{
775 struct dc_mii_frame frame;
776 struct dc_softc *sc;
777 int i, rval, phy_reg = 0;
778
779 sc = device_get_softc(dev);
780 bzero(&frame, sizeof(frame));
781
782 /*
783 * Note: both the AL981 and AN983 have internal PHYs,
784 * however the AL981 provides direct access to the PHY
785 * registers while the AN983 uses a serial MII interface.
786 * The AN983's MII interface is also buggy in that you
787 * can read from any MII address (0 to 31), but only address 1
788 * behaves normally. To deal with both cases, we pretend
789 * that the PHY is at MII address 1.
790 */
791 if (DC_IS_ADMTEK(sc) && phy != DC_ADMTEK_PHYADDR)
792 return (0);
793
794 /*
795 * Note: the ukphy probes of the RS7112 report a PHY at
796 * MII address 0 (possibly HomePNA?) and 1 (ethernet)
797 * so we only respond to correct one.
798 */
799 if (DC_IS_CONEXANT(sc) && phy != DC_CONEXANT_PHYADDR)
800 return (0);
801
802 if (sc->dc_pmode != DC_PMODE_MII) {
803 if (phy == (MII_NPHY - 1)) {
804 switch (reg) {
805 case MII_BMSR:
806 /*
807 * Fake something to make the probe
808 * code think there's a PHY here.
809 */

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

896{
897 struct dc_softc *sc;
898 struct dc_mii_frame frame;
899 int i, phy_reg = 0;
900
901 sc = device_get_softc(dev);
902 bzero(&frame, sizeof(frame));
903
782 if (sc->dc_pmode != DC_PMODE_MII) {
783 if (phy == (MII_NPHY - 1)) {
784 switch (reg) {
785 case MII_BMSR:
786 /*
787 * Fake something to make the probe
788 * code think there's a PHY here.
789 */

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

876{
877 struct dc_softc *sc;
878 struct dc_mii_frame frame;
879 int i, phy_reg = 0;
880
881 sc = device_get_softc(dev);
882 bzero(&frame, sizeof(frame));
883
904 if (DC_IS_ADMTEK(sc) && phy != DC_ADMTEK_PHYADDR)
905 return (0);
906
907 if (DC_IS_CONEXANT(sc) && phy != DC_CONEXANT_PHYADDR)
908 return (0);
909
910 if (DC_IS_PNIC(sc)) {
911 CSR_WRITE_4(sc, DC_PN_MII, DC_PN_MIIOPCODE_WRITE |
912 (phy << 23) | (reg << 10) | data);
913 for (i = 0; i < DC_TIMEOUT; i++) {
914 if (!(CSR_READ_4(sc, DC_PN_MII) & DC_PN_MII_BUSY))
915 break;
916 }
917 return (0);

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

1810
1811/*
1812 * Attach the interface. Allocate softc structures, do ifmedia
1813 * setup and ethernet/BPF attach.
1814 */
1815static int
1816dc_attach(device_t dev)
1817{
884 if (DC_IS_PNIC(sc)) {
885 CSR_WRITE_4(sc, DC_PN_MII, DC_PN_MIIOPCODE_WRITE |
886 (phy << 23) | (reg << 10) | data);
887 for (i = 0; i < DC_TIMEOUT; i++) {
888 if (!(CSR_READ_4(sc, DC_PN_MII) & DC_PN_MII_BUSY))
889 break;
890 }
891 return (0);

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

1784
1785/*
1786 * Attach the interface. Allocate softc structures, do ifmedia
1787 * setup and ethernet/BPF attach.
1788 */
1789static int
1790dc_attach(device_t dev)
1791{
1818 int tmp = 0;
1819 uint32_t eaddr[(ETHER_ADDR_LEN+3)/4];
1820 u_int32_t command;
1821 struct dc_softc *sc;
1822 struct ifnet *ifp;
1823 u_int32_t reg, revision;
1792 uint32_t eaddr[(ETHER_ADDR_LEN+3)/4];
1793 u_int32_t command;
1794 struct dc_softc *sc;
1795 struct ifnet *ifp;
1796 u_int32_t reg, revision;
1824 int error = 0, rid, mac_offset;
1825 int i;
1797 int error, i, mac_offset, phy, rid, tmp;
1826 u_int8_t *mac;
1827
1828 sc = device_get_softc(dev);
1829 sc->dc_dev = dev;
1830
1831 mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1832 MTX_DEF);
1833

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

2212
2213 /*
2214 * Do MII setup. If this is a 21143, check for a PHY on the
2215 * MII bus after applying any necessary fixups to twiddle the
2216 * GPIO bits. If we don't end up finding a PHY, restore the
2217 * old selection (SIA only or SIA/SYM) and attach the dcphy
2218 * driver instead.
2219 */
1798 u_int8_t *mac;
1799
1800 sc = device_get_softc(dev);
1801 sc->dc_dev = dev;
1802
1803 mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1804 MTX_DEF);
1805

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

2184
2185 /*
2186 * Do MII setup. If this is a 21143, check for a PHY on the
2187 * MII bus after applying any necessary fixups to twiddle the
2188 * GPIO bits. If we don't end up finding a PHY, restore the
2189 * old selection (SIA only or SIA/SYM) and attach the dcphy
2190 * driver instead.
2191 */
2192 tmp = 0;
2220 if (DC_IS_INTEL(sc)) {
2221 dc_apply_fixup(sc, IFM_AUTO);
2222 tmp = sc->dc_pmode;
2223 sc->dc_pmode = DC_PMODE_MII;
2224 }
2225
2226 /*
2227 * Setup General Purpose port mode and data so the tulip can talk
2193 if (DC_IS_INTEL(sc)) {
2194 dc_apply_fixup(sc, IFM_AUTO);
2195 tmp = sc->dc_pmode;
2196 sc->dc_pmode = DC_PMODE_MII;
2197 }
2198
2199 /*
2200 * Setup General Purpose port mode and data so the tulip can talk
2228 * to the MII. This needs to be done before mii_phy_probe so that
2201 * to the MII. This needs to be done before mii_attach so that
2229 * we can actually see them.
2230 */
2231 if (DC_IS_XIRCOM(sc)) {
2232 CSR_WRITE_4(sc, DC_SIAGP, DC_SIAGP_WRITE_EN | DC_SIAGP_INT1_EN |
2233 DC_SIAGP_MD_GP2_OUTPUT | DC_SIAGP_MD_GP0_OUTPUT);
2234 DELAY(10);
2235 CSR_WRITE_4(sc, DC_SIAGP, DC_SIAGP_INT1_EN |
2236 DC_SIAGP_MD_GP2_OUTPUT | DC_SIAGP_MD_GP0_OUTPUT);
2237 DELAY(10);
2238 }
2239
2202 * we can actually see them.
2203 */
2204 if (DC_IS_XIRCOM(sc)) {
2205 CSR_WRITE_4(sc, DC_SIAGP, DC_SIAGP_WRITE_EN | DC_SIAGP_INT1_EN |
2206 DC_SIAGP_MD_GP2_OUTPUT | DC_SIAGP_MD_GP0_OUTPUT);
2207 DELAY(10);
2208 CSR_WRITE_4(sc, DC_SIAGP, DC_SIAGP_INT1_EN |
2209 DC_SIAGP_MD_GP2_OUTPUT | DC_SIAGP_MD_GP0_OUTPUT);
2210 DELAY(10);
2211 }
2212
2240 error = mii_phy_probe(dev, &sc->dc_miibus,
2241 dc_ifmedia_upd, dc_ifmedia_sts);
2213 phy = MII_PHY_ANY;
2214 /*
2215 * Note: both the AL981 and AN983 have internal PHYs, however the
2216 * AL981 provides direct access to the PHY registers while the AN983
2217 * uses a serial MII interface. The AN983's MII interface is also
2218 * buggy in that you can read from any MII address (0 to 31), but
2219 * only address 1 behaves normally. To deal with both cases, we
2220 * pretend that the PHY is at MII address 1.
2221 */
2222 if (DC_IS_ADMTEK(sc))
2223 phy = DC_ADMTEK_PHYADDR;
2242
2224
2225 /*
2226 * Note: the ukphy probes of the RS7112 report a PHY at MII address
2227 * 0 (possibly HomePNA?) and 1 (ethernet) so we only respond to the
2228 * correct one.
2229 */
2230 if (DC_IS_CONEXANT(sc))
2231 phy = DC_CONEXANT_PHYADDR;
2232
2233 error = mii_attach(dev, &sc->dc_miibus, ifp, dc_ifmedia_upd,
2234 dc_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
2235
2243 if (error && DC_IS_INTEL(sc)) {
2244 sc->dc_pmode = tmp;
2245 if (sc->dc_pmode != DC_PMODE_SIA)
2246 sc->dc_pmode = DC_PMODE_SYM;
2247 sc->dc_flags |= DC_21143_NWAY;
2236 if (error && DC_IS_INTEL(sc)) {
2237 sc->dc_pmode = tmp;
2238 if (sc->dc_pmode != DC_PMODE_SIA)
2239 sc->dc_pmode = DC_PMODE_SYM;
2240 sc->dc_flags |= DC_21143_NWAY;
2248 mii_phy_probe(dev, &sc->dc_miibus,
2249 dc_ifmedia_upd, dc_ifmedia_sts);
2241 mii_attach(dev, &sc->dc_miibus, ifp, dc_ifmedia_upd,
2242 dc_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
2243 MII_OFFSET_ANY, 0);
2250 /*
2251 * For non-MII cards, we need to have the 21143
2252 * drive the LEDs. Except there are some systems
2253 * like the NEC VersaPro NoteBook PC which have no
2254 * LEDs, and twiddling these bits has adverse effects
2255 * on them. (I.e. you suddenly can't get a link.)
2256 */
2257 if (!(pci_get_subvendor(dev) == 0x1033 &&
2258 pci_get_subdevice(dev) == 0x8028))
2259 sc->dc_flags |= DC_TULIP_LEDS;
2260 error = 0;
2261 }
2262
2263 if (error) {
2244 /*
2245 * For non-MII cards, we need to have the 21143
2246 * drive the LEDs. Except there are some systems
2247 * like the NEC VersaPro NoteBook PC which have no
2248 * LEDs, and twiddling these bits has adverse effects
2249 * on them. (I.e. you suddenly can't get a link.)
2250 */
2251 if (!(pci_get_subvendor(dev) == 0x1033 &&
2252 pci_get_subdevice(dev) == 0x8028))
2253 sc->dc_flags |= DC_TULIP_LEDS;
2254 error = 0;
2255 }
2256
2257 if (error) {
2264 device_printf(dev, "MII without any PHY!\n");
2258 device_printf(dev, "attaching PHYs failed\n");
2265 goto fail;
2266 }
2267
2268 if (DC_IS_ADMTEK(sc)) {
2269 /*
2270 * Set automatic TX underrun recovery for the ADMtek chips
2271 */
2272 DC_SETBIT(sc, DC_AL_CR, DC_AL_CR_ATUR);

--- 1584 unchanged lines hidden ---
2259 goto fail;
2260 }
2261
2262 if (DC_IS_ADMTEK(sc)) {
2263 /*
2264 * Set automatic TX underrun recovery for the ADMtek chips
2265 */
2266 DC_SETBIT(sc, DC_AL_CR, DC_AL_CR_ATUR);

--- 1584 unchanged lines hidden ---