| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tulip.c,v 1.164 2008/11/07 00:20:03 dyoung Exp $ */ | | 1 | /* $NetBSD: tulip.c,v 1.165 2009/04/17 08:04:49 cegger Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center; and by Charles M. Hannum. | | 9 | * NASA Ames Research Center; and by Charles M. Hannum. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 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 | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 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 THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | /* | | 33 | /* |
34 | * Device driver for the Digital Semiconductor ``Tulip'' (21x4x) | | 34 | * Device driver for the Digital Semiconductor ``Tulip'' (21x4x) |
35 | * Ethernet controller family, and a variety of clone chips. | | 35 | * Ethernet controller family, and a variety of clone chips. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.164 2008/11/07 00:20:03 dyoung Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.165 2009/04/17 08:04:49 cegger Exp $"); |
40 | | | 40 | |
41 | #include "bpfilter.h" | | 41 | #include "bpfilter.h" |
42 | | | 42 | |
43 | #include <sys/param.h> | | 43 | #include <sys/param.h> |
44 | #include <sys/systm.h> | | 44 | #include <sys/systm.h> |
45 | #include <sys/callout.h> | | 45 | #include <sys/callout.h> |
46 | #include <sys/mbuf.h> | | 46 | #include <sys/mbuf.h> |
47 | #include <sys/malloc.h> | | 47 | #include <sys/malloc.h> |
48 | #include <sys/kernel.h> | | 48 | #include <sys/kernel.h> |
49 | #include <sys/socket.h> | | 49 | #include <sys/socket.h> |
50 | #include <sys/ioctl.h> | | 50 | #include <sys/ioctl.h> |
51 | #include <sys/errno.h> | | 51 | #include <sys/errno.h> |
52 | #include <sys/device.h> | | 52 | #include <sys/device.h> |
| @@ -102,65 +102,65 @@ static int tlp_srom_size(struct tulip_so | | | @@ -102,65 +102,65 @@ static int tlp_srom_size(struct tulip_so |
102 | | | 102 | |
103 | static int tlp_enable(struct tulip_softc *); | | 103 | static int tlp_enable(struct tulip_softc *); |
104 | static void tlp_disable(struct tulip_softc *); | | 104 | static void tlp_disable(struct tulip_softc *); |
105 | | | 105 | |
106 | static void tlp_filter_setup(struct tulip_softc *); | | 106 | static void tlp_filter_setup(struct tulip_softc *); |
107 | static void tlp_winb_filter_setup(struct tulip_softc *); | | 107 | static void tlp_winb_filter_setup(struct tulip_softc *); |
108 | static void tlp_al981_filter_setup(struct tulip_softc *); | | 108 | static void tlp_al981_filter_setup(struct tulip_softc *); |
109 | static void tlp_asix_filter_setup(struct tulip_softc *); | | 109 | static void tlp_asix_filter_setup(struct tulip_softc *); |
110 | | | 110 | |
111 | static void tlp_rxintr(struct tulip_softc *); | | 111 | static void tlp_rxintr(struct tulip_softc *); |
112 | static void tlp_txintr(struct tulip_softc *); | | 112 | static void tlp_txintr(struct tulip_softc *); |
113 | | | 113 | |
114 | static void tlp_mii_tick(void *); | | 114 | static void tlp_mii_tick(void *); |
115 | static void tlp_mii_statchg(struct device *); | | 115 | static void tlp_mii_statchg(device_t); |
116 | static void tlp_winb_mii_statchg(struct device *); | | 116 | static void tlp_winb_mii_statchg(device_t); |
117 | static void tlp_dm9102_mii_statchg(struct device *); | | 117 | static void tlp_dm9102_mii_statchg(device_t); |
118 | | | 118 | |
119 | static void tlp_mii_getmedia(struct tulip_softc *, struct ifmediareq *); | | 119 | static void tlp_mii_getmedia(struct tulip_softc *, struct ifmediareq *); |
120 | static int tlp_mii_setmedia(struct tulip_softc *); | | 120 | static int tlp_mii_setmedia(struct tulip_softc *); |
121 | | | 121 | |
122 | static int tlp_bitbang_mii_readreg(struct device *, int, int); | | 122 | static int tlp_bitbang_mii_readreg(device_t, int, int); |
123 | static void tlp_bitbang_mii_writereg(struct device *, int, int, int); | | 123 | static void tlp_bitbang_mii_writereg(device_t, int, int, int); |
124 | | | 124 | |
125 | static int tlp_pnic_mii_readreg(struct device *, int, int); | | 125 | static int tlp_pnic_mii_readreg(device_t, int, int); |
126 | static void tlp_pnic_mii_writereg(struct device *, int, int, int); | | 126 | static void tlp_pnic_mii_writereg(device_t, int, int, int); |
127 | | | 127 | |
128 | static int tlp_al981_mii_readreg(struct device *, int, int); | | 128 | static int tlp_al981_mii_readreg(device_t, int, int); |
129 | static void tlp_al981_mii_writereg(struct device *, int, int, int); | | 129 | static void tlp_al981_mii_writereg(device_t, int, int, int); |
130 | | | 130 | |
131 | static void tlp_2114x_preinit(struct tulip_softc *); | | 131 | static void tlp_2114x_preinit(struct tulip_softc *); |
132 | static void tlp_2114x_mii_preinit(struct tulip_softc *); | | 132 | static void tlp_2114x_mii_preinit(struct tulip_softc *); |
133 | static void tlp_pnic_preinit(struct tulip_softc *); | | 133 | static void tlp_pnic_preinit(struct tulip_softc *); |
134 | static void tlp_dm9102_preinit(struct tulip_softc *); | | 134 | static void tlp_dm9102_preinit(struct tulip_softc *); |
135 | static void tlp_asix_preinit(struct tulip_softc *); | | 135 | static void tlp_asix_preinit(struct tulip_softc *); |
136 | | | 136 | |
137 | static void tlp_21140_reset(struct tulip_softc *); | | 137 | static void tlp_21140_reset(struct tulip_softc *); |
138 | static void tlp_21142_reset(struct tulip_softc *); | | 138 | static void tlp_21142_reset(struct tulip_softc *); |
139 | static void tlp_pmac_reset(struct tulip_softc *); | | 139 | static void tlp_pmac_reset(struct tulip_softc *); |
140 | #if 0 | | 140 | #if 0 |
141 | static void tlp_dm9102_reset(struct tulip_softc *); | | 141 | static void tlp_dm9102_reset(struct tulip_softc *); |
142 | #endif | | 142 | #endif |
143 | | | 143 | |
144 | static void tlp_2114x_nway_tick(void *); | | 144 | static void tlp_2114x_nway_tick(void *); |
145 | | | 145 | |
146 | #define tlp_mchash(addr, sz) \ | | 146 | #define tlp_mchash(addr, sz) \ |
147 | (ether_crc32_le((addr), ETHER_ADDR_LEN) & ((sz) - 1)) | | 147 | (ether_crc32_le((addr), ETHER_ADDR_LEN) & ((sz) - 1)) |
148 | | | 148 | |
149 | /* | | 149 | /* |
150 | * MII bit-bang glue. | | 150 | * MII bit-bang glue. |
151 | */ | | 151 | */ |
152 | static u_int32_t tlp_sio_mii_bitbang_read(struct device *); | | 152 | static uint32_t tlp_sio_mii_bitbang_read(device_t); |
153 | static void tlp_sio_mii_bitbang_write(struct device *, u_int32_t); | | 153 | static void tlp_sio_mii_bitbang_write(device_t, uint32_t); |
154 | | | 154 | |
155 | static const struct mii_bitbang_ops tlp_sio_mii_bitbang_ops = { | | 155 | static const struct mii_bitbang_ops tlp_sio_mii_bitbang_ops = { |
156 | tlp_sio_mii_bitbang_read, | | 156 | tlp_sio_mii_bitbang_read, |
157 | tlp_sio_mii_bitbang_write, | | 157 | tlp_sio_mii_bitbang_write, |
158 | { | | 158 | { |
159 | MIIROM_MDO, /* MII_BIT_MDO */ | | 159 | MIIROM_MDO, /* MII_BIT_MDO */ |
160 | MIIROM_MDI, /* MII_BIT_MDI */ | | 160 | MIIROM_MDI, /* MII_BIT_MDI */ |
161 | MIIROM_MDC, /* MII_BIT_MDC */ | | 161 | MIIROM_MDC, /* MII_BIT_MDC */ |
162 | 0, /* MII_BIT_DIR_HOST_PHY */ | | 162 | 0, /* MII_BIT_DIR_HOST_PHY */ |
163 | MIIROM_MIIDIR, /* MII_BIT_DIR_PHY_HOST */ | | 163 | MIIROM_MIIDIR, /* MII_BIT_DIR_PHY_HOST */ |
164 | } | | 164 | } |
165 | }; | | 165 | }; |
166 | | | 166 | |
| @@ -177,27 +177,27 @@ static void tlp_print_stats(struct tulip | | | @@ -177,27 +177,27 @@ static void tlp_print_stats(struct tulip |
177 | | | 177 | |
178 | /* | | 178 | /* |
179 | * Can be used to debug the SROM-related things, including contents. | | 179 | * Can be used to debug the SROM-related things, including contents. |
180 | * Initialized so that it's patchable. | | 180 | * Initialized so that it's patchable. |
181 | */ | | 181 | */ |
182 | int tlp_srom_debug = 0; | | 182 | int tlp_srom_debug = 0; |
183 | | | 183 | |
184 | /* | | 184 | /* |
185 | * tlp_attach: | | 185 | * tlp_attach: |
186 | * | | 186 | * |
187 | * Attach a Tulip interface to the system. | | 187 | * Attach a Tulip interface to the system. |
188 | */ | | 188 | */ |
189 | void | | 189 | void |
190 | tlp_attach(struct tulip_softc *sc, const u_int8_t *enaddr) | | 190 | tlp_attach(struct tulip_softc *sc, const uint8_t *enaddr) |
191 | { | | 191 | { |
192 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 192 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
193 | device_t self = &sc->sc_dev; | | 193 | device_t self = &sc->sc_dev; |
194 | int i, error; | | 194 | int i, error; |
195 | | | 195 | |
196 | callout_init(&sc->sc_nway_callout, 0); | | 196 | callout_init(&sc->sc_nway_callout, 0); |
197 | callout_init(&sc->sc_tick_callout, 0); | | 197 | callout_init(&sc->sc_tick_callout, 0); |
198 | | | 198 | |
199 | /* | | 199 | /* |
200 | * NOTE: WE EXPECT THE FRONT-END TO INITIALIZE sc_regshift! | | 200 | * NOTE: WE EXPECT THE FRONT-END TO INITIALIZE sc_regshift! |
201 | */ | | 201 | */ |
202 | | | 202 | |
203 | /* | | 203 | /* |
| @@ -563,27 +563,27 @@ tlp_attach(struct tulip_softc *sc, const | | | @@ -563,27 +563,27 @@ tlp_attach(struct tulip_softc *sc, const |
563 | sizeof(struct tulip_control_data)); | | 563 | sizeof(struct tulip_control_data)); |
564 | fail_1: | | 564 | fail_1: |
565 | bus_dmamem_free(sc->sc_dmat, &sc->sc_cdseg, sc->sc_cdnseg); | | 565 | bus_dmamem_free(sc->sc_dmat, &sc->sc_cdseg, sc->sc_cdnseg); |
566 | fail_0: | | 566 | fail_0: |
567 | return; | | 567 | return; |
568 | } | | 568 | } |
569 | | | 569 | |
570 | /* | | 570 | /* |
571 | * tlp_activate: | | 571 | * tlp_activate: |
572 | * | | 572 | * |
573 | * Handle device activation/deactivation requests. | | 573 | * Handle device activation/deactivation requests. |
574 | */ | | 574 | */ |
575 | int | | 575 | int |
576 | tlp_activate(struct device *self, enum devact act) | | 576 | tlp_activate(device_t self, enum devact act) |
577 | { | | 577 | { |
578 | struct tulip_softc *sc = (void *) self; | | 578 | struct tulip_softc *sc = (void *) self; |
579 | int s, error = 0; | | 579 | int s, error = 0; |
580 | | | 580 | |
581 | s = splnet(); | | 581 | s = splnet(); |
582 | switch (act) { | | 582 | switch (act) { |
583 | case DVACT_ACTIVATE: | | 583 | case DVACT_ACTIVATE: |
584 | error = EOPNOTSUPP; | | 584 | error = EOPNOTSUPP; |
585 | break; | | 585 | break; |
586 | | | 586 | |
587 | case DVACT_DEACTIVATE: | | 587 | case DVACT_DEACTIVATE: |
588 | if (sc->sc_flags & TULIPF_HAS_MII) | | 588 | if (sc->sc_flags & TULIPF_HAS_MII) |
589 | mii_activate(&sc->sc_mii, act, MII_PHY_ANY, | | 589 | mii_activate(&sc->sc_mii, act, MII_PHY_ANY, |
| @@ -1021,27 +1021,27 @@ tlp_ioctl(struct ifnet *ifp, u_long cmd, | | | @@ -1021,27 +1021,27 @@ tlp_ioctl(struct ifnet *ifp, u_long cmd, |
1021 | return (error); | | 1021 | return (error); |
1022 | } | | 1022 | } |
1023 | | | 1023 | |
1024 | /* | | 1024 | /* |
1025 | * tlp_intr: | | 1025 | * tlp_intr: |
1026 | * | | 1026 | * |
1027 | * Interrupt service routine. | | 1027 | * Interrupt service routine. |
1028 | */ | | 1028 | */ |
1029 | int | | 1029 | int |
1030 | tlp_intr(void *arg) | | 1030 | tlp_intr(void *arg) |
1031 | { | | 1031 | { |
1032 | struct tulip_softc *sc = arg; | | 1032 | struct tulip_softc *sc = arg; |
1033 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 1033 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
1034 | u_int32_t status, rxstatus, txstatus; | | 1034 | uint32_t status, rxstatus, txstatus; |
1035 | int handled = 0, txthresh; | | 1035 | int handled = 0, txthresh; |
1036 | | | 1036 | |
1037 | DPRINTF(sc, ("%s: tlp_intr\n", device_xname(&sc->sc_dev))); | | 1037 | DPRINTF(sc, ("%s: tlp_intr\n", device_xname(&sc->sc_dev))); |
1038 | | | 1038 | |
1039 | #ifdef DEBUG | | 1039 | #ifdef DEBUG |
1040 | if (TULIP_IS_ENABLED(sc) == 0) | | 1040 | if (TULIP_IS_ENABLED(sc) == 0) |
1041 | panic("%s: tlp_intr: not enabled", device_xname(&sc->sc_dev)); | | 1041 | panic("%s: tlp_intr: not enabled", device_xname(&sc->sc_dev)); |
1042 | #endif | | 1042 | #endif |
1043 | | | 1043 | |
1044 | /* | | 1044 | /* |
1045 | * If the interface isn't running, the interrupt couldn't | | 1045 | * If the interface isn't running, the interrupt couldn't |
1046 | * possibly have come from us. | | 1046 | * possibly have come from us. |
1047 | */ | | 1047 | */ |
| @@ -1215,27 +1215,27 @@ tlp_intr(void *arg) | | | @@ -1215,27 +1215,27 @@ tlp_intr(void *arg) |
1215 | | | 1215 | |
1216 | /* | | 1216 | /* |
1217 | * tlp_rxintr: | | 1217 | * tlp_rxintr: |
1218 | * | | 1218 | * |
1219 | * Helper; handle receive interrupts. | | 1219 | * Helper; handle receive interrupts. |
1220 | */ | | 1220 | */ |
1221 | static void | | 1221 | static void |
1222 | tlp_rxintr(struct tulip_softc *sc) | | 1222 | tlp_rxintr(struct tulip_softc *sc) |
1223 | { | | 1223 | { |
1224 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 1224 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
1225 | struct ether_header *eh; | | 1225 | struct ether_header *eh; |
1226 | struct tulip_rxsoft *rxs; | | 1226 | struct tulip_rxsoft *rxs; |
1227 | struct mbuf *m; | | 1227 | struct mbuf *m; |
1228 | u_int32_t rxstat, errors; | | 1228 | uint32_t rxstat, errors; |
1229 | int i, len; | | 1229 | int i, len; |
1230 | | | 1230 | |
1231 | for (i = sc->sc_rxptr;; i = TULIP_NEXTRX(i)) { | | 1231 | for (i = sc->sc_rxptr;; i = TULIP_NEXTRX(i)) { |
1232 | rxs = &sc->sc_rxsoft[i]; | | 1232 | rxs = &sc->sc_rxsoft[i]; |
1233 | | | 1233 | |
1234 | TULIP_CDRXSYNC(sc, i, | | 1234 | TULIP_CDRXSYNC(sc, i, |
1235 | BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); | | 1235 | BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); |
1236 | | | 1236 | |
1237 | rxstat = le32toh(sc->sc_rxdescs[i].td_status); | | 1237 | rxstat = le32toh(sc->sc_rxdescs[i].td_status); |
1238 | | | 1238 | |
1239 | if (rxstat & TDSTAT_OWN) { | | 1239 | if (rxstat & TDSTAT_OWN) { |
1240 | /* | | 1240 | /* |
1241 | * We have processed all of the receive buffers. | | 1241 | * We have processed all of the receive buffers. |
| @@ -1419,27 +1419,27 @@ tlp_rxintr(struct tulip_softc *sc) | | | @@ -1419,27 +1419,27 @@ tlp_rxintr(struct tulip_softc *sc) |
1419 | sc->sc_rxptr = i; | | 1419 | sc->sc_rxptr = i; |
1420 | } | | 1420 | } |
1421 | | | 1421 | |
1422 | /* | | 1422 | /* |
1423 | * tlp_txintr: | | 1423 | * tlp_txintr: |
1424 | * | | 1424 | * |
1425 | * Helper; handle transmit interrupts. | | 1425 | * Helper; handle transmit interrupts. |
1426 | */ | | 1426 | */ |
1427 | static void | | 1427 | static void |
1428 | tlp_txintr(struct tulip_softc *sc) | | 1428 | tlp_txintr(struct tulip_softc *sc) |
1429 | { | | 1429 | { |
1430 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 1430 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
1431 | struct tulip_txsoft *txs; | | 1431 | struct tulip_txsoft *txs; |
1432 | u_int32_t txstat; | | 1432 | uint32_t txstat; |
1433 | | | 1433 | |
1434 | DPRINTF(sc, ("%s: tlp_txintr: sc_flags 0x%08x\n", | | 1434 | DPRINTF(sc, ("%s: tlp_txintr: sc_flags 0x%08x\n", |
1435 | device_xname(&sc->sc_dev), sc->sc_flags)); | | 1435 | device_xname(&sc->sc_dev), sc->sc_flags)); |
1436 | | | 1436 | |
1437 | ifp->if_flags &= ~IFF_OACTIVE; | | 1437 | ifp->if_flags &= ~IFF_OACTIVE; |
1438 | | | 1438 | |
1439 | /* | | 1439 | /* |
1440 | * Go through our Tx list and free mbufs for those | | 1440 | * Go through our Tx list and free mbufs for those |
1441 | * frames that have been transmitted. | | 1441 | * frames that have been transmitted. |
1442 | */ | | 1442 | */ |
1443 | while ((txs = SIMPLEQ_FIRST(&sc->sc_txdirtyq)) != NULL) { | | 1443 | while ((txs = SIMPLEQ_FIRST(&sc->sc_txdirtyq)) != NULL) { |
1444 | TULIP_CDTXSYNC(sc, txs->txs_lastdesc, | | 1444 | TULIP_CDTXSYNC(sc, txs->txs_lastdesc, |
1445 | txs->txs_ndescs, | | 1445 | txs->txs_ndescs, |
| @@ -1890,46 +1890,46 @@ tlp_init(struct ifnet *ifp) | | | @@ -1890,46 +1890,46 @@ tlp_init(struct ifnet *ifp) |
1890 | bus_addr_t cpa = TULIP_CSR_OFFSET(sc, CSR_WINB_CPA0); | | 1890 | bus_addr_t cpa = TULIP_CSR_OFFSET(sc, CSR_WINB_CPA0); |
1891 | | | 1891 | |
1892 | for (i = 0; i < ETHER_ADDR_LEN; i++) { | | 1892 | for (i = 0; i < ETHER_ADDR_LEN; i++) { |
1893 | bus_space_write_1(sc->sc_st, sc->sc_sh, | | 1893 | bus_space_write_1(sc->sc_st, sc->sc_sh, |
1894 | cpa + i, CLLADDR(ifp->if_sadl)[i]); | | 1894 | cpa + i, CLLADDR(ifp->if_sadl)[i]); |
1895 | } | | 1895 | } |
1896 | break; | | 1896 | break; |
1897 | } | | 1897 | } |
1898 | | | 1898 | |
1899 | case TULIP_CHIP_AL981: | | 1899 | case TULIP_CHIP_AL981: |
1900 | case TULIP_CHIP_AN983: | | 1900 | case TULIP_CHIP_AN983: |
1901 | case TULIP_CHIP_AN985: | | 1901 | case TULIP_CHIP_AN985: |
1902 | { | | 1902 | { |
1903 | u_int32_t reg; | | 1903 | uint32_t reg; |
1904 | const u_int8_t *enaddr = CLLADDR(ifp->if_sadl); | | 1904 | const uint8_t *enaddr = CLLADDR(ifp->if_sadl); |
1905 | | | 1905 | |
1906 | reg = enaddr[0] | | | 1906 | reg = enaddr[0] | |
1907 | (enaddr[1] << 8) | | | 1907 | (enaddr[1] << 8) | |
1908 | (enaddr[2] << 16) | | | 1908 | (enaddr[2] << 16) | |
1909 | (enaddr[3] << 24); | | 1909 | (enaddr[3] << 24); |
1910 | bus_space_write_4(sc->sc_st, sc->sc_sh, CSR_ADM_PAR0, reg); | | 1910 | bus_space_write_4(sc->sc_st, sc->sc_sh, CSR_ADM_PAR0, reg); |
1911 | | | 1911 | |
1912 | reg = enaddr[4] | | | 1912 | reg = enaddr[4] | |
1913 | (enaddr[5] << 8); | | 1913 | (enaddr[5] << 8); |
1914 | bus_space_write_4(sc->sc_st, sc->sc_sh, CSR_ADM_PAR1, reg); | | 1914 | bus_space_write_4(sc->sc_st, sc->sc_sh, CSR_ADM_PAR1, reg); |
1915 | break; | | 1915 | break; |
1916 | } | | 1916 | } |
1917 | | | 1917 | |
1918 | case TULIP_CHIP_AX88140: | | 1918 | case TULIP_CHIP_AX88140: |
1919 | case TULIP_CHIP_AX88141: | | 1919 | case TULIP_CHIP_AX88141: |
1920 | { | | 1920 | { |
1921 | u_int32_t reg; | | 1921 | uint32_t reg; |
1922 | const u_int8_t *enaddr = CLLADDR(ifp->if_sadl); | | 1922 | const uint8_t *enaddr = CLLADDR(ifp->if_sadl); |
1923 | | | 1923 | |
1924 | reg = enaddr[0] | | | 1924 | reg = enaddr[0] | |
1925 | (enaddr[1] << 8) | | | 1925 | (enaddr[1] << 8) | |
1926 | (enaddr[2] << 16) | | | 1926 | (enaddr[2] << 16) | |
1927 | (enaddr[3] << 24); | | 1927 | (enaddr[3] << 24); |
1928 | TULIP_WRITE(sc, CSR_AX_FILTIDX, AX_FILTIDX_PAR0); | | 1928 | TULIP_WRITE(sc, CSR_AX_FILTIDX, AX_FILTIDX_PAR0); |
1929 | TULIP_WRITE(sc, CSR_AX_FILTDATA, reg); | | 1929 | TULIP_WRITE(sc, CSR_AX_FILTDATA, reg); |
1930 | | | 1930 | |
1931 | reg = enaddr[4] | (enaddr[5] << 8); | | 1931 | reg = enaddr[4] | (enaddr[5] << 8); |
1932 | TULIP_WRITE(sc, CSR_AX_FILTIDX, AX_FILTIDX_PAR1); | | 1932 | TULIP_WRITE(sc, CSR_AX_FILTIDX, AX_FILTIDX_PAR1); |
1933 | TULIP_WRITE(sc, CSR_AX_FILTDATA, reg); | | 1933 | TULIP_WRITE(sc, CSR_AX_FILTDATA, reg); |
1934 | break; | | 1934 | break; |
1935 | } | | 1935 | } |
| @@ -2098,27 +2098,27 @@ tlp_stop(struct ifnet *ifp, int disable) | | | @@ -2098,27 +2098,27 @@ tlp_stop(struct ifnet *ifp, int disable) |
2098 | do { \ | | 2098 | do { \ |
2099 | TULIP_WRITE((sc), CSR_MIIROM, (x)); \ | | 2099 | TULIP_WRITE((sc), CSR_MIIROM, (x)); \ |
2100 | delay(2); \ | | 2100 | delay(2); \ |
2101 | } while (0) | | 2101 | } while (0) |
2102 | | | 2102 | |
2103 | /* | | 2103 | /* |
2104 | * tlp_srom_idle: | | 2104 | * tlp_srom_idle: |
2105 | * | | 2105 | * |
2106 | * Put the SROM in idle state. | | 2106 | * Put the SROM in idle state. |
2107 | */ | | 2107 | */ |
2108 | static void | | 2108 | static void |
2109 | tlp_srom_idle(struct tulip_softc *sc) | | 2109 | tlp_srom_idle(struct tulip_softc *sc) |
2110 | { | | 2110 | { |
2111 | u_int32_t miirom; | | 2111 | uint32_t miirom; |
2112 | int i; | | 2112 | int i; |
2113 | | | 2113 | |
2114 | miirom = MIIROM_SR; | | 2114 | miirom = MIIROM_SR; |
2115 | SROM_EMIT(sc, miirom); | | 2115 | SROM_EMIT(sc, miirom); |
2116 | | | 2116 | |
2117 | miirom |= MIIROM_RD; | | 2117 | miirom |= MIIROM_RD; |
2118 | SROM_EMIT(sc, miirom); | | 2118 | SROM_EMIT(sc, miirom); |
2119 | | | 2119 | |
2120 | miirom |= MIIROM_SROMCS; | | 2120 | miirom |= MIIROM_SROMCS; |
2121 | SROM_EMIT(sc, miirom); | | 2121 | SROM_EMIT(sc, miirom); |
2122 | | | 2122 | |
2123 | SROM_EMIT(sc, miirom|MIIROM_SROMSK); | | 2123 | SROM_EMIT(sc, miirom|MIIROM_SROMSK); |
2124 | | | 2124 | |
| @@ -2134,27 +2134,27 @@ tlp_srom_idle(struct tulip_softc *sc) | | | @@ -2134,27 +2134,27 @@ tlp_srom_idle(struct tulip_softc *sc) |
2134 | SROM_EMIT(sc, miirom); | | 2134 | SROM_EMIT(sc, miirom); |
2135 | | | 2135 | |
2136 | SROM_EMIT(sc, 0); | | 2136 | SROM_EMIT(sc, 0); |
2137 | } | | 2137 | } |
2138 | | | 2138 | |
2139 | /* | | 2139 | /* |
2140 | * tlp_srom_size: | | 2140 | * tlp_srom_size: |
2141 | * | | 2141 | * |
2142 | * Determine the number of address bits in the SROM. | | 2142 | * Determine the number of address bits in the SROM. |
2143 | */ | | 2143 | */ |
2144 | static int | | 2144 | static int |
2145 | tlp_srom_size(struct tulip_softc *sc) | | 2145 | tlp_srom_size(struct tulip_softc *sc) |
2146 | { | | 2146 | { |
2147 | u_int32_t miirom; | | 2147 | uint32_t miirom; |
2148 | int x; | | 2148 | int x; |
2149 | | | 2149 | |
2150 | /* Select the SROM. */ | | 2150 | /* Select the SROM. */ |
2151 | miirom = MIIROM_SR; | | 2151 | miirom = MIIROM_SR; |
2152 | SROM_EMIT(sc, miirom); | | 2152 | SROM_EMIT(sc, miirom); |
2153 | | | 2153 | |
2154 | miirom |= MIIROM_RD; | | 2154 | miirom |= MIIROM_RD; |
2155 | SROM_EMIT(sc, miirom); | | 2155 | SROM_EMIT(sc, miirom); |
2156 | | | 2156 | |
2157 | /* Send CHIP SELECT for one clock tick. */ | | 2157 | /* Send CHIP SELECT for one clock tick. */ |
2158 | miirom |= MIIROM_SROMCS; | | 2158 | miirom |= MIIROM_SROMCS; |
2159 | SROM_EMIT(sc, miirom); | | 2159 | SROM_EMIT(sc, miirom); |
2160 | | | 2160 | |
| @@ -2197,28 +2197,28 @@ tlp_srom_size(struct tulip_softc *sc) | | | @@ -2197,28 +2197,28 @@ tlp_srom_size(struct tulip_softc *sc) |
2197 | return (x); | | 2197 | return (x); |
2198 | } | | 2198 | } |
2199 | } | | 2199 | } |
2200 | | | 2200 | |
2201 | /* | | 2201 | /* |
2202 | * tlp_read_srom: | | 2202 | * tlp_read_srom: |
2203 | * | | 2203 | * |
2204 | * Read the Tulip SROM. | | 2204 | * Read the Tulip SROM. |
2205 | */ | | 2205 | */ |
2206 | int | | 2206 | int |
2207 | tlp_read_srom(struct tulip_softc *sc) | | 2207 | tlp_read_srom(struct tulip_softc *sc) |
2208 | { | | 2208 | { |
2209 | int size; | | 2209 | int size; |
2210 | u_int32_t miirom; | | 2210 | uint32_t miirom; |
2211 | u_int16_t datain; | | 2211 | uint16_t datain; |
2212 | int i, x; | | 2212 | int i, x; |
2213 | | | 2213 | |
2214 | tlp_srom_idle(sc); | | 2214 | tlp_srom_idle(sc); |
2215 | | | 2215 | |
2216 | sc->sc_srom_addrbits = tlp_srom_size(sc); | | 2216 | sc->sc_srom_addrbits = tlp_srom_size(sc); |
2217 | if (sc->sc_srom_addrbits == 0) | | 2217 | if (sc->sc_srom_addrbits == 0) |
2218 | return (0); | | 2218 | return (0); |
2219 | size = TULIP_ROM_SIZE(sc->sc_srom_addrbits); | | 2219 | size = TULIP_ROM_SIZE(sc->sc_srom_addrbits); |
2220 | sc->sc_srom = malloc(size, M_DEVBUF, M_NOWAIT); | | 2220 | sc->sc_srom = malloc(size, M_DEVBUF, M_NOWAIT); |
2221 | | | 2221 | |
2222 | /* Select the SROM. */ | | 2222 | /* Select the SROM. */ |
2223 | miirom = MIIROM_SR; | | 2223 | miirom = MIIROM_SR; |
2224 | SROM_EMIT(sc, miirom); | | 2224 | SROM_EMIT(sc, miirom); |
| @@ -2332,56 +2332,56 @@ tlp_add_rxbuf(struct tulip_softc *sc, in | | | @@ -2332,56 +2332,56 @@ tlp_add_rxbuf(struct tulip_softc *sc, in |
2332 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | | 2332 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); |
2333 | | | 2333 | |
2334 | TULIP_INIT_RXDESC(sc, idx); | | 2334 | TULIP_INIT_RXDESC(sc, idx); |
2335 | | | 2335 | |
2336 | return (0); | | 2336 | return (0); |
2337 | } | | 2337 | } |
2338 | | | 2338 | |
2339 | /* | | 2339 | /* |
2340 | * tlp_srom_crcok: | | 2340 | * tlp_srom_crcok: |
2341 | * | | 2341 | * |
2342 | * Check the CRC of the Tulip SROM. | | 2342 | * Check the CRC of the Tulip SROM. |
2343 | */ | | 2343 | */ |
2344 | int | | 2344 | int |
2345 | tlp_srom_crcok(const u_int8_t *romdata) | | 2345 | tlp_srom_crcok(const uint8_t *romdata) |
2346 | { | | 2346 | { |
2347 | u_int32_t crc; | | 2347 | uint32_t crc; |
2348 | | | 2348 | |
2349 | crc = ether_crc32_le(romdata, TULIP_ROM_CRC32_CHECKSUM); | | 2349 | crc = ether_crc32_le(romdata, TULIP_ROM_CRC32_CHECKSUM); |
2350 | crc = (crc & 0xffff) ^ 0xffff; | | 2350 | crc = (crc & 0xffff) ^ 0xffff; |
2351 | if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM)) | | 2351 | if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM)) |
2352 | return (1); | | 2352 | return (1); |
2353 | | | 2353 | |
2354 | /* | | 2354 | /* |
2355 | * Try an alternate checksum. | | 2355 | * Try an alternate checksum. |
2356 | */ | | 2356 | */ |
2357 | crc = ether_crc32_le(romdata, TULIP_ROM_CRC32_CHECKSUM1); | | 2357 | crc = ether_crc32_le(romdata, TULIP_ROM_CRC32_CHECKSUM1); |
2358 | crc = (crc & 0xffff) ^ 0xffff; | | 2358 | crc = (crc & 0xffff) ^ 0xffff; |
2359 | if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM1)) | | 2359 | if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM1)) |
2360 | return (1); | | 2360 | return (1); |
2361 | | | 2361 | |
2362 | return (0); | | 2362 | return (0); |
2363 | } | | 2363 | } |
2364 | | | 2364 | |
2365 | /* | | 2365 | /* |
2366 | * tlp_isv_srom: | | 2366 | * tlp_isv_srom: |
2367 | * | | 2367 | * |
2368 | * Check to see if the SROM is in the new standardized format. | | 2368 | * Check to see if the SROM is in the new standardized format. |
2369 | */ | | 2369 | */ |
2370 | int | | 2370 | int |
2371 | tlp_isv_srom(const u_int8_t *romdata) | | 2371 | tlp_isv_srom(const uint8_t *romdata) |
2372 | { | | 2372 | { |
2373 | int i; | | 2373 | int i; |
2374 | u_int16_t cksum; | | 2374 | uint16_t cksum; |
2375 | | | 2375 | |
2376 | if (tlp_srom_crcok(romdata)) { | | 2376 | if (tlp_srom_crcok(romdata)) { |
2377 | /* | | 2377 | /* |
2378 | * SROM CRC checks out; must be in the new format. | | 2378 | * SROM CRC checks out; must be in the new format. |
2379 | */ | | 2379 | */ |
2380 | return (1); | | 2380 | return (1); |
2381 | } | | 2381 | } |
2382 | | | 2382 | |
2383 | cksum = TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM); | | 2383 | cksum = TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM); |
2384 | if (cksum == 0xffff || cksum == 0) { | | 2384 | if (cksum == 0xffff || cksum == 0) { |
2385 | /* | | 2385 | /* |
2386 | * No checksum present. Check the SROM ID; 18 bytes of 0 | | 2386 | * No checksum present. Check the SROM ID; 18 bytes of 0 |
2387 | * followed by 1 (version) followed by the number of | | 2387 | * followed by 1 (version) followed by the number of |
| @@ -2397,27 +2397,27 @@ tlp_isv_srom(const u_int8_t *romdata) | | | @@ -2397,27 +2397,27 @@ tlp_isv_srom(const u_int8_t *romdata) |
2397 | return (0); | | 2397 | return (0); |
2398 | return (1); | | 2398 | return (1); |
2399 | } | | 2399 | } |
2400 | | | 2400 | |
2401 | return (0); | | 2401 | return (0); |
2402 | } | | 2402 | } |
2403 | | | 2403 | |
2404 | /* | | 2404 | /* |
2405 | * tlp_isv_srom_enaddr: | | 2405 | * tlp_isv_srom_enaddr: |
2406 | * | | 2406 | * |
2407 | * Get the Ethernet address from an ISV SROM. | | 2407 | * Get the Ethernet address from an ISV SROM. |
2408 | */ | | 2408 | */ |
2409 | int | | 2409 | int |
2410 | tlp_isv_srom_enaddr(struct tulip_softc *sc, u_int8_t *enaddr) | | 2410 | tlp_isv_srom_enaddr(struct tulip_softc *sc, uint8_t *enaddr) |
2411 | { | | 2411 | { |
2412 | int i, devcnt; | | 2412 | int i, devcnt; |
2413 | | | 2413 | |
2414 | if (tlp_isv_srom(sc->sc_srom) == 0) | | 2414 | if (tlp_isv_srom(sc->sc_srom) == 0) |
2415 | return (0); | | 2415 | return (0); |
2416 | | | 2416 | |
2417 | devcnt = sc->sc_srom[TULIP_ROM_CHIP_COUNT]; | | 2417 | devcnt = sc->sc_srom[TULIP_ROM_CHIP_COUNT]; |
2418 | for (i = 0; i < devcnt; i++) { | | 2418 | for (i = 0; i < devcnt; i++) { |
2419 | if (sc->sc_srom[TULIP_ROM_CHIP_COUNT] == 1) | | 2419 | if (sc->sc_srom[TULIP_ROM_CHIP_COUNT] == 1) |
2420 | break; | | 2420 | break; |
2421 | if (sc->sc_srom[TULIP_ROM_CHIPn_DEVICE_NUMBER(i)] == | | 2421 | if (sc->sc_srom[TULIP_ROM_CHIPn_DEVICE_NUMBER(i)] == |
2422 | sc->sc_devno) | | 2422 | sc->sc_devno) |
2423 | break; | | 2423 | break; |
| @@ -2431,32 +2431,32 @@ tlp_isv_srom_enaddr(struct tulip_softc * | | | @@ -2431,32 +2431,32 @@ tlp_isv_srom_enaddr(struct tulip_softc * |
2431 | enaddr[5] += i; | | 2431 | enaddr[5] += i; |
2432 | | | 2432 | |
2433 | return (1); | | 2433 | return (1); |
2434 | } | | 2434 | } |
2435 | | | 2435 | |
2436 | /* | | 2436 | /* |
2437 | * tlp_parse_old_srom: | | 2437 | * tlp_parse_old_srom: |
2438 | * | | 2438 | * |
2439 | * Parse old-format SROMs. | | 2439 | * Parse old-format SROMs. |
2440 | * | | 2440 | * |
2441 | * This routine is largely lifted from Matt Thomas's `de' driver. | | 2441 | * This routine is largely lifted from Matt Thomas's `de' driver. |
2442 | */ | | 2442 | */ |
2443 | int | | 2443 | int |
2444 | tlp_parse_old_srom(struct tulip_softc *sc, u_int8_t *enaddr) | | 2444 | tlp_parse_old_srom(struct tulip_softc *sc, uint8_t *enaddr) |
2445 | { | | 2445 | { |
2446 | static const u_int8_t testpat[] = | | 2446 | static const uint8_t testpat[] = |
2447 | { 0xff, 0, 0x55, 0xaa, 0xff, 0, 0x55, 0xaa }; | | 2447 | { 0xff, 0, 0x55, 0xaa, 0xff, 0, 0x55, 0xaa }; |
2448 | int i; | | 2448 | int i; |
2449 | u_int32_t cksum; | | 2449 | uint32_t cksum; |
2450 | | | 2450 | |
2451 | if (memcmp(&sc->sc_srom[0], &sc->sc_srom[16], 8) != 0) { | | 2451 | if (memcmp(&sc->sc_srom[0], &sc->sc_srom[16], 8) != 0) { |
2452 | /* | | 2452 | /* |
2453 | * Phobos G100 interfaces have the address at | | 2453 | * Phobos G100 interfaces have the address at |
2454 | * offsets 0 and 20, but each pair of bytes is | | 2454 | * offsets 0 and 20, but each pair of bytes is |
2455 | * swapped. | | 2455 | * swapped. |
2456 | */ | | 2456 | */ |
2457 | if (sc->sc_srom_addrbits == 6 && | | 2457 | if (sc->sc_srom_addrbits == 6 && |
2458 | sc->sc_srom[1] == 0x00 && | | 2458 | sc->sc_srom[1] == 0x00 && |
2459 | sc->sc_srom[0] == 0x60 && | | 2459 | sc->sc_srom[0] == 0x60 && |
2460 | sc->sc_srom[3] == 0xf5 && | | 2460 | sc->sc_srom[3] == 0xf5 && |
2461 | memcmp(&sc->sc_srom[0], &sc->sc_srom[20], 6) == 0) { | | 2461 | memcmp(&sc->sc_srom[0], &sc->sc_srom[20], 6) == 0) { |
2462 | for (i = 0; i < 6; i += 2) { | | 2462 | for (i = 0; i < 6; i += 2) { |
| @@ -2528,66 +2528,66 @@ tlp_parse_old_srom(struct tulip_softc *s | | | @@ -2528,66 +2528,66 @@ tlp_parse_old_srom(struct tulip_softc *s |
2528 | * Standard DEC Address ROM test. | | 2528 | * Standard DEC Address ROM test. |
2529 | */ | | 2529 | */ |
2530 | | | 2530 | |
2531 | if (memcmp(&sc->sc_srom[24], testpat, 8) != 0) | | 2531 | if (memcmp(&sc->sc_srom[24], testpat, 8) != 0) |
2532 | return (0); | | 2532 | return (0); |
2533 | | | 2533 | |
2534 | for (i = 0; i < 8; i++) { | | 2534 | for (i = 0; i < 8; i++) { |
2535 | if (sc->sc_srom[i] != sc->sc_srom[15 - i]) | | 2535 | if (sc->sc_srom[i] != sc->sc_srom[15 - i]) |
2536 | return (0); | | 2536 | return (0); |
2537 | } | | 2537 | } |
2538 | | | 2538 | |
2539 | memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN); | | 2539 | memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN); |
2540 | | | 2540 | |
2541 | cksum = *(u_int16_t *) &enaddr[0]; | | 2541 | cksum = *(uint16_t *) &enaddr[0]; |
2542 | | | 2542 | |
2543 | cksum <<= 1; | | 2543 | cksum <<= 1; |
2544 | if (cksum > 0xffff) | | 2544 | if (cksum > 0xffff) |
2545 | cksum -= 0xffff; | | 2545 | cksum -= 0xffff; |
2546 | | | 2546 | |
2547 | cksum += *(u_int16_t *) &enaddr[2]; | | 2547 | cksum += *(uint16_t *) &enaddr[2]; |
2548 | if (cksum > 0xffff) | | 2548 | if (cksum > 0xffff) |
2549 | cksum -= 0xffff; | | 2549 | cksum -= 0xffff; |
2550 | | | 2550 | |
2551 | cksum <<= 1; | | 2551 | cksum <<= 1; |
2552 | if (cksum > 0xffff) | | 2552 | if (cksum > 0xffff) |
2553 | cksum -= 0xffff; | | 2553 | cksum -= 0xffff; |
2554 | | | 2554 | |
2555 | cksum += *(u_int16_t *) &enaddr[4]; | | 2555 | cksum += *(uint16_t *) &enaddr[4]; |
2556 | if (cksum >= 0xffff) | | 2556 | if (cksum >= 0xffff) |
2557 | cksum -= 0xffff; | | 2557 | cksum -= 0xffff; |
2558 | | | 2558 | |
2559 | if (cksum != *(u_int16_t *) &sc->sc_srom[6]) | | 2559 | if (cksum != *(uint16_t *) &sc->sc_srom[6]) |
2560 | return (0); | | 2560 | return (0); |
2561 | | | 2561 | |
2562 | return (1); | | 2562 | return (1); |
2563 | } | | 2563 | } |
2564 | | | 2564 | |
2565 | /* | | 2565 | /* |
2566 | * tlp_filter_setup: | | 2566 | * tlp_filter_setup: |
2567 | * | | 2567 | * |
2568 | * Set the Tulip's receive filter. | | 2568 | * Set the Tulip's receive filter. |
2569 | */ | | 2569 | */ |
2570 | static void | | 2570 | static void |
2571 | tlp_filter_setup(struct tulip_softc *sc) | | 2571 | tlp_filter_setup(struct tulip_softc *sc) |
2572 | { | | 2572 | { |
2573 | struct ethercom *ec = &sc->sc_ethercom; | | 2573 | struct ethercom *ec = &sc->sc_ethercom; |
2574 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 2574 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
2575 | struct ether_multi *enm; | | 2575 | struct ether_multi *enm; |
2576 | struct ether_multistep step; | | 2576 | struct ether_multistep step; |
2577 | volatile u_int32_t *sp; | | 2577 | volatile uint32_t *sp; |
2578 | struct tulip_txsoft *txs; | | 2578 | struct tulip_txsoft *txs; |
2579 | u_int8_t enaddr[ETHER_ADDR_LEN]; | | 2579 | uint8_t enaddr[ETHER_ADDR_LEN]; |
2580 | u_int32_t hash, hashsize; | | 2580 | uint32_t hash, hashsize; |
2581 | int cnt, nexttx; | | 2581 | int cnt, nexttx; |
2582 | | | 2582 | |
2583 | DPRINTF(sc, ("%s: tlp_filter_setup: sc_flags 0x%08x\n", | | 2583 | DPRINTF(sc, ("%s: tlp_filter_setup: sc_flags 0x%08x\n", |
2584 | device_xname(&sc->sc_dev), sc->sc_flags)); | | 2584 | device_xname(&sc->sc_dev), sc->sc_flags)); |
2585 | | | 2585 | |
2586 | memcpy(enaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN); | | 2586 | memcpy(enaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN); |
2587 | | | 2587 | |
2588 | /* | | 2588 | /* |
2589 | * If there are transmissions pending, wait until they have | | 2589 | * If there are transmissions pending, wait until they have |
2590 | * completed. | | 2590 | * completed. |
2591 | */ | | 2591 | */ |
2592 | if (! SIMPLEQ_EMPTY(&sc->sc_txdirtyq) || | | 2592 | if (! SIMPLEQ_EMPTY(&sc->sc_txdirtyq) || |
2593 | (sc->sc_flags & TULIPF_DOING_SETUP) != 0) { | | 2593 | (sc->sc_flags & TULIPF_DOING_SETUP) != 0) { |
| @@ -2832,27 +2832,27 @@ tlp_filter_setup(struct tulip_softc *sc) | | | @@ -2832,27 +2832,27 @@ tlp_filter_setup(struct tulip_softc *sc) |
2832 | | | 2832 | |
2833 | /* | | 2833 | /* |
2834 | * tlp_winb_filter_setup: | | 2834 | * tlp_winb_filter_setup: |
2835 | * | | 2835 | * |
2836 | * Set the Winbond 89C840F's receive filter. | | 2836 | * Set the Winbond 89C840F's receive filter. |
2837 | */ | | 2837 | */ |
2838 | static void | | 2838 | static void |
2839 | tlp_winb_filter_setup(struct tulip_softc *sc) | | 2839 | tlp_winb_filter_setup(struct tulip_softc *sc) |
2840 | { | | 2840 | { |
2841 | struct ethercom *ec = &sc->sc_ethercom; | | 2841 | struct ethercom *ec = &sc->sc_ethercom; |
2842 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 2842 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
2843 | struct ether_multi *enm; | | 2843 | struct ether_multi *enm; |
2844 | struct ether_multistep step; | | 2844 | struct ether_multistep step; |
2845 | u_int32_t hash, mchash[2]; | | 2845 | uint32_t hash, mchash[2]; |
2846 | | | 2846 | |
2847 | DPRINTF(sc, ("%s: tlp_winb_filter_setup: sc_flags 0x%08x\n", | | 2847 | DPRINTF(sc, ("%s: tlp_winb_filter_setup: sc_flags 0x%08x\n", |
2848 | device_xname(&sc->sc_dev), sc->sc_flags)); | | 2848 | device_xname(&sc->sc_dev), sc->sc_flags)); |
2849 | | | 2849 | |
2850 | sc->sc_opmode &= ~(OPMODE_WINB_APP|OPMODE_WINB_AMP|OPMODE_WINB_ABP); | | 2850 | sc->sc_opmode &= ~(OPMODE_WINB_APP|OPMODE_WINB_AMP|OPMODE_WINB_ABP); |
2851 | | | 2851 | |
2852 | if (ifp->if_flags & IFF_MULTICAST) | | 2852 | if (ifp->if_flags & IFF_MULTICAST) |
2853 | sc->sc_opmode |= OPMODE_WINB_AMP; | | 2853 | sc->sc_opmode |= OPMODE_WINB_AMP; |
2854 | | | 2854 | |
2855 | if (ifp->if_flags & IFF_BROADCAST) | | 2855 | if (ifp->if_flags & IFF_BROADCAST) |
2856 | sc->sc_opmode |= OPMODE_WINB_ABP; | | 2856 | sc->sc_opmode |= OPMODE_WINB_ABP; |
2857 | | | 2857 | |
2858 | if (ifp->if_flags & IFF_PROMISC) { | | 2858 | if (ifp->if_flags & IFF_PROMISC) { |
| @@ -2903,27 +2903,27 @@ tlp_winb_filter_setup(struct tulip_softc | | | @@ -2903,27 +2903,27 @@ tlp_winb_filter_setup(struct tulip_softc |
2903 | | | 2903 | |
2904 | /* | | 2904 | /* |
2905 | * tlp_al981_filter_setup: | | 2905 | * tlp_al981_filter_setup: |
2906 | * | | 2906 | * |
2907 | * Set the ADMtek AL981's receive filter. | | 2907 | * Set the ADMtek AL981's receive filter. |
2908 | */ | | 2908 | */ |
2909 | static void | | 2909 | static void |
2910 | tlp_al981_filter_setup(struct tulip_softc *sc) | | 2910 | tlp_al981_filter_setup(struct tulip_softc *sc) |
2911 | { | | 2911 | { |
2912 | struct ethercom *ec = &sc->sc_ethercom; | | 2912 | struct ethercom *ec = &sc->sc_ethercom; |
2913 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 2913 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
2914 | struct ether_multi *enm; | | 2914 | struct ether_multi *enm; |
2915 | struct ether_multistep step; | | 2915 | struct ether_multistep step; |
2916 | u_int32_t hash, mchash[2]; | | 2916 | uint32_t hash, mchash[2]; |
2917 | | | 2917 | |
2918 | /* | | 2918 | /* |
2919 | * If the chip is running, we need to reset the interface, | | 2919 | * If the chip is running, we need to reset the interface, |
2920 | * and will revisit here (with IFF_RUNNING) clear. The | | 2920 | * and will revisit here (with IFF_RUNNING) clear. The |
2921 | * chip seems to really not like to have its multicast | | 2921 | * chip seems to really not like to have its multicast |
2922 | * filter programmed without a reset. | | 2922 | * filter programmed without a reset. |
2923 | */ | | 2923 | */ |
2924 | if (ifp->if_flags & IFF_RUNNING) { | | 2924 | if (ifp->if_flags & IFF_RUNNING) { |
2925 | (void) tlp_init(ifp); | | 2925 | (void) tlp_init(ifp); |
2926 | return; | | 2926 | return; |
2927 | } | | 2927 | } |
2928 | | | 2928 | |
2929 | DPRINTF(sc, ("%s: tlp_al981_filter_setup: sc_flags 0x%08x\n", | | 2929 | DPRINTF(sc, ("%s: tlp_al981_filter_setup: sc_flags 0x%08x\n", |
| @@ -2973,27 +2973,27 @@ tlp_al981_filter_setup(struct tulip_soft | | | @@ -2973,27 +2973,27 @@ tlp_al981_filter_setup(struct tulip_soft |
2973 | | | 2973 | |
2974 | /* | | 2974 | /* |
2975 | * tlp_asix_filter_setup: | | 2975 | * tlp_asix_filter_setup: |
2976 | * | | 2976 | * |
2977 | * Set the ASIX AX8814x recieve filter. | | 2977 | * Set the ASIX AX8814x recieve filter. |
2978 | */ | | 2978 | */ |
2979 | static void | | 2979 | static void |
2980 | tlp_asix_filter_setup(struct tulip_softc *sc) | | 2980 | tlp_asix_filter_setup(struct tulip_softc *sc) |
2981 | { | | 2981 | { |
2982 | struct ethercom *ec = &sc->sc_ethercom; | | 2982 | struct ethercom *ec = &sc->sc_ethercom; |
2983 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 2983 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
2984 | struct ether_multi *enm; | | 2984 | struct ether_multi *enm; |
2985 | struct ether_multistep step; | | 2985 | struct ether_multistep step; |
2986 | u_int32_t hash, mchash[2]; | | 2986 | uint32_t hash, mchash[2]; |
2987 | | | 2987 | |
2988 | DPRINTF(sc, ("%s: tlp_asix_filter_setup: sc_flags 0x%08x\n", | | 2988 | DPRINTF(sc, ("%s: tlp_asix_filter_setup: sc_flags 0x%08x\n", |
2989 | device_xname(&sc->sc_dev), sc->sc_flags)); | | 2989 | device_xname(&sc->sc_dev), sc->sc_flags)); |
2990 | | | 2990 | |
2991 | sc->sc_opmode &= ~(OPMODE_PM|OPMODE_AX_RB|OPMODE_PR); | | 2991 | sc->sc_opmode &= ~(OPMODE_PM|OPMODE_AX_RB|OPMODE_PR); |
2992 | | | 2992 | |
2993 | if (ifp->if_flags & IFF_MULTICAST) | | 2993 | if (ifp->if_flags & IFF_MULTICAST) |
2994 | sc->sc_opmode |= OPMODE_PM; | | 2994 | sc->sc_opmode |= OPMODE_PM; |
2995 | | | 2995 | |
2996 | if (ifp->if_flags & IFF_BROADCAST) | | 2996 | if (ifp->if_flags & IFF_BROADCAST) |
2997 | sc->sc_opmode |= OPMODE_AX_RB; | | 2997 | sc->sc_opmode |= OPMODE_AX_RB; |
2998 | | | 2998 | |
2999 | if (ifp->if_flags & IFF_PROMISC) { | | 2999 | if (ifp->if_flags & IFF_PROMISC) { |
| @@ -3038,27 +3038,27 @@ setit: | | | @@ -3038,27 +3038,27 @@ setit: |
3038 | TULIP_WRITE(sc, CSR_AX_FILTDATA, mchash[1]); | | 3038 | TULIP_WRITE(sc, CSR_AX_FILTDATA, mchash[1]); |
3039 | TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode); | | 3039 | TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode); |
3040 | DPRINTF(sc, ("%s: tlp_asix_filter_setup: returning\n", | | 3040 | DPRINTF(sc, ("%s: tlp_asix_filter_setup: returning\n", |
3041 | device_xname(&sc->sc_dev))); | | 3041 | device_xname(&sc->sc_dev))); |
3042 | } | | 3042 | } |
3043 | | | 3043 | |
3044 | | | 3044 | |
3045 | /* | | 3045 | /* |
3046 | * tlp_idle: | | 3046 | * tlp_idle: |
3047 | * | | 3047 | * |
3048 | * Cause the transmit and/or receive processes to go idle. | | 3048 | * Cause the transmit and/or receive processes to go idle. |
3049 | */ | | 3049 | */ |
3050 | void | | 3050 | void |
3051 | tlp_idle(struct tulip_softc *sc, u_int32_t bits) | | 3051 | tlp_idle(struct tulip_softc *sc, uint32_t bits) |
3052 | { | | 3052 | { |
3053 | static const char * const tlp_tx_state_names[] = { | | 3053 | static const char * const tlp_tx_state_names[] = { |
3054 | "STOPPED", | | 3054 | "STOPPED", |
3055 | "RUNNING - FETCH", | | 3055 | "RUNNING - FETCH", |
3056 | "RUNNING - WAIT", | | 3056 | "RUNNING - WAIT", |
3057 | "RUNNING - READING", | | 3057 | "RUNNING - READING", |
3058 | "-- RESERVED --", | | 3058 | "-- RESERVED --", |
3059 | "RUNNING - SETUP", | | 3059 | "RUNNING - SETUP", |
3060 | "SUSPENDED", | | 3060 | "SUSPENDED", |
3061 | "RUNNING - CLOSE", | | 3061 | "RUNNING - CLOSE", |
3062 | }; | | 3062 | }; |
3063 | static const char * const tlp_rx_state_names[] = { | | 3063 | static const char * const tlp_rx_state_names[] = { |
3064 | "STOPPED", | | 3064 | "STOPPED", |
| @@ -3082,27 +3082,27 @@ tlp_idle(struct tulip_softc *sc, u_int32 | | | @@ -3082,27 +3082,27 @@ tlp_idle(struct tulip_softc *sc, u_int32 |
3082 | }; | | 3082 | }; |
3083 | static const char * const dm9102_rx_state_names[] = { | | 3083 | static const char * const dm9102_rx_state_names[] = { |
3084 | "STOPPED", | | 3084 | "STOPPED", |
3085 | "RUNNING - FETCH", | | 3085 | "RUNNING - FETCH", |
3086 | "RUNNING - WAIT", | | 3086 | "RUNNING - WAIT", |
3087 | "RUNNING - QUEUE", | | 3087 | "RUNNING - QUEUE", |
3088 | "RUNNING - CLOSE - CLEAR OWNER", | | 3088 | "RUNNING - CLOSE - CLEAR OWNER", |
3089 | "RUNNING - CLOSE - WRITE STATUS", | | 3089 | "RUNNING - CLOSE - WRITE STATUS", |
3090 | "SUSPENDED", | | 3090 | "SUSPENDED", |
3091 | "RUNNING - FLUSH", | | 3091 | "RUNNING - FLUSH", |
3092 | }; | | 3092 | }; |
3093 | | | 3093 | |
3094 | const char * const *tx_state_names, * const *rx_state_names; | | 3094 | const char * const *tx_state_names, * const *rx_state_names; |
3095 | u_int32_t csr, ackmask = 0; | | 3095 | uint32_t csr, ackmask = 0; |
3096 | int i; | | 3096 | int i; |
3097 | | | 3097 | |
3098 | switch (sc->sc_chip) { | | 3098 | switch (sc->sc_chip) { |
3099 | case TULIP_CHIP_DM9102: | | 3099 | case TULIP_CHIP_DM9102: |
3100 | case TULIP_CHIP_DM9102A: | | 3100 | case TULIP_CHIP_DM9102A: |
3101 | tx_state_names = dm9102_tx_state_names; | | 3101 | tx_state_names = dm9102_tx_state_names; |
3102 | rx_state_names = dm9102_rx_state_names; | | 3102 | rx_state_names = dm9102_rx_state_names; |
3103 | break; | | 3103 | break; |
3104 | | | 3104 | |
3105 | default: | | 3105 | default: |
3106 | tx_state_names = tlp_tx_state_names; | | 3106 | tx_state_names = tlp_tx_state_names; |
3107 | rx_state_names = tlp_rx_state_names; | | 3107 | rx_state_names = tlp_rx_state_names; |
3108 | break; | | 3108 | break; |
| @@ -3219,27 +3219,27 @@ tlp_mii_tick(void *arg) | | | @@ -3219,27 +3219,27 @@ tlp_mii_tick(void *arg) |
3219 | s = splnet(); | | 3219 | s = splnet(); |
3220 | mii_tick(&sc->sc_mii); | | 3220 | mii_tick(&sc->sc_mii); |
3221 | splx(s); | | 3221 | splx(s); |
3222 | | | 3222 | |
3223 | callout_reset(&sc->sc_tick_callout, hz, sc->sc_tick, sc); | | 3223 | callout_reset(&sc->sc_tick_callout, hz, sc->sc_tick, sc); |
3224 | } | | 3224 | } |
3225 | | | 3225 | |
3226 | /* | | 3226 | /* |
3227 | * tlp_mii_statchg: [mii interface function] | | 3227 | * tlp_mii_statchg: [mii interface function] |
3228 | * | | 3228 | * |
3229 | * Callback from PHY when media changes. | | 3229 | * Callback from PHY when media changes. |
3230 | */ | | 3230 | */ |
3231 | static void | | 3231 | static void |
3232 | tlp_mii_statchg(struct device *self) | | 3232 | tlp_mii_statchg(device_t self) |
3233 | { | | 3233 | { |
3234 | struct tulip_softc *sc = (struct tulip_softc *)self; | | 3234 | struct tulip_softc *sc = (struct tulip_softc *)self; |
3235 | | | 3235 | |
3236 | /* Idle the transmit and receive processes. */ | | 3236 | /* Idle the transmit and receive processes. */ |
3237 | tlp_idle(sc, OPMODE_ST|OPMODE_SR); | | 3237 | tlp_idle(sc, OPMODE_ST|OPMODE_SR); |
3238 | | | 3238 | |
3239 | sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD|OPMODE_HBD); | | 3239 | sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD|OPMODE_HBD); |
3240 | | | 3240 | |
3241 | if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_10_T) | | 3241 | if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_10_T) |
3242 | sc->sc_opmode |= OPMODE_TTM; | | 3242 | sc->sc_opmode |= OPMODE_TTM; |
3243 | else | | 3243 | else |
3244 | sc->sc_opmode |= OPMODE_HBD; | | 3244 | sc->sc_opmode |= OPMODE_HBD; |
3245 | | | 3245 | |
| @@ -3250,27 +3250,27 @@ tlp_mii_statchg(struct device *self) | | | @@ -3250,27 +3250,27 @@ tlp_mii_statchg(struct device *self) |
3250 | * Write new OPMODE bits. This also restarts the transmit | | 3250 | * Write new OPMODE bits. This also restarts the transmit |
3251 | * and receive processes. | | 3251 | * and receive processes. |
3252 | */ | | 3252 | */ |
3253 | TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode); | | 3253 | TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode); |
3254 | } | | 3254 | } |
3255 | | | 3255 | |
3256 | /* | | 3256 | /* |
3257 | * tlp_winb_mii_statchg: [mii interface function] | | 3257 | * tlp_winb_mii_statchg: [mii interface function] |
3258 | * | | 3258 | * |
3259 | * Callback from PHY when media changes. This version is | | 3259 | * Callback from PHY when media changes. This version is |
3260 | * for the Winbond 89C840F, which has different OPMODE bits. | | 3260 | * for the Winbond 89C840F, which has different OPMODE bits. |
3261 | */ | | 3261 | */ |
3262 | static void | | 3262 | static void |
3263 | tlp_winb_mii_statchg(struct device *self) | | 3263 | tlp_winb_mii_statchg(device_t self) |
3264 | { | | 3264 | { |
3265 | struct tulip_softc *sc = (struct tulip_softc *)self; | | 3265 | struct tulip_softc *sc = (struct tulip_softc *)self; |
3266 | | | 3266 | |
3267 | /* Idle the transmit and receive processes. */ | | 3267 | /* Idle the transmit and receive processes. */ |
3268 | tlp_idle(sc, OPMODE_ST|OPMODE_SR); | | 3268 | tlp_idle(sc, OPMODE_ST|OPMODE_SR); |
3269 | | | 3269 | |
3270 | sc->sc_opmode &= ~(OPMODE_WINB_FES|OPMODE_FD); | | 3270 | sc->sc_opmode &= ~(OPMODE_WINB_FES|OPMODE_FD); |
3271 | | | 3271 | |
3272 | if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_100_TX) | | 3272 | if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_100_TX) |
3273 | sc->sc_opmode |= OPMODE_WINB_FES; | | 3273 | sc->sc_opmode |= OPMODE_WINB_FES; |
3274 | | | 3274 | |
3275 | if (sc->sc_mii.mii_media_active & IFM_FDX) | | 3275 | if (sc->sc_mii.mii_media_active & IFM_FDX) |
3276 | sc->sc_opmode |= OPMODE_FD; | | 3276 | sc->sc_opmode |= OPMODE_FD; |
| @@ -3279,27 +3279,27 @@ tlp_winb_mii_statchg(struct device *self | | | @@ -3279,27 +3279,27 @@ tlp_winb_mii_statchg(struct device *self |
3279 | * Write new OPMODE bits. This also restarts the transmit | | 3279 | * Write new OPMODE bits. This also restarts the transmit |
3280 | * and receive processes. | | 3280 | * and receive processes. |
3281 | */ | | 3281 | */ |
3282 | TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode); | | 3282 | TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode); |
3283 | } | | 3283 | } |
3284 | | | 3284 | |
3285 | /* | | 3285 | /* |
3286 | * tlp_dm9102_mii_statchg: [mii interface function] | | 3286 | * tlp_dm9102_mii_statchg: [mii interface function] |
3287 | * | | 3287 | * |
3288 | * Callback from PHY when media changes. This version is | | 3288 | * Callback from PHY when media changes. This version is |
3289 | * for the DM9102. | | 3289 | * for the DM9102. |
3290 | */ | | 3290 | */ |
3291 | static void | | 3291 | static void |
3292 | tlp_dm9102_mii_statchg(struct device *self) | | 3292 | tlp_dm9102_mii_statchg(device_t self) |
3293 | { | | 3293 | { |
3294 | struct tulip_softc *sc = (struct tulip_softc *)self; | | 3294 | struct tulip_softc *sc = (struct tulip_softc *)self; |
3295 | | | 3295 | |
3296 | /* | | 3296 | /* |
3297 | * Don't idle the transmit and receive processes, here. It | | 3297 | * Don't idle the transmit and receive processes, here. It |
3298 | * seems to fail, and just causes excess noise. | | 3298 | * seems to fail, and just causes excess noise. |
3299 | */ | | 3299 | */ |
3300 | sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD); | | 3300 | sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD); |
3301 | | | 3301 | |
3302 | if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) != IFM_100_TX) | | 3302 | if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) != IFM_100_TX) |
3303 | sc->sc_opmode |= OPMODE_TTM; | | 3303 | sc->sc_opmode |= OPMODE_TTM; |
3304 | | | 3304 | |
3305 | if (sc->sc_mii.mii_media_active & IFM_FDX) | | 3305 | if (sc->sc_mii.mii_media_active & IFM_FDX) |
| @@ -3350,82 +3350,82 @@ tlp_mii_setmedia(struct tulip_softc *sc) | | | @@ -3350,82 +3350,82 @@ tlp_mii_setmedia(struct tulip_softc *sc) |
3350 | break; | | 3350 | break; |
3351 | } | | 3351 | } |
3352 | if ((rc = mii_mediachg(&sc->sc_mii)) == ENXIO) | | 3352 | if ((rc = mii_mediachg(&sc->sc_mii)) == ENXIO) |
3353 | return 0; | | 3353 | return 0; |
3354 | return rc; | | 3354 | return rc; |
3355 | } | | 3355 | } |
3356 | | | 3356 | |
3357 | /* | | 3357 | /* |
3358 | * tlp_bitbang_mii_readreg: | | 3358 | * tlp_bitbang_mii_readreg: |
3359 | * | | 3359 | * |
3360 | * Read a PHY register via bit-bang'ing the MII. | | 3360 | * Read a PHY register via bit-bang'ing the MII. |
3361 | */ | | 3361 | */ |
3362 | static int | | 3362 | static int |
3363 | tlp_bitbang_mii_readreg(struct device *self, int phy, int reg) | | 3363 | tlp_bitbang_mii_readreg(device_t self, int phy, int reg) |
3364 | { | | 3364 | { |
3365 | struct tulip_softc *sc = (void *) self; | | 3365 | struct tulip_softc *sc = (void *) self; |
3366 | | | 3366 | |
3367 | return (mii_bitbang_readreg(self, sc->sc_bitbang_ops, phy, reg)); | | 3367 | return (mii_bitbang_readreg(self, sc->sc_bitbang_ops, phy, reg)); |
3368 | } | | 3368 | } |
3369 | | | 3369 | |
3370 | /* | | 3370 | /* |
3371 | * tlp_bitbang_mii_writereg: | | 3371 | * tlp_bitbang_mii_writereg: |
3372 | * | | 3372 | * |
3373 | * Write a PHY register via bit-bang'ing the MII. | | 3373 | * Write a PHY register via bit-bang'ing the MII. |
3374 | */ | | 3374 | */ |
3375 | static void | | 3375 | static void |
3376 | tlp_bitbang_mii_writereg(struct device *self, int phy, int reg, int val) | | 3376 | tlp_bitbang_mii_writereg(device_t self, int phy, int reg, int val) |
3377 | { | | 3377 | { |
3378 | struct tulip_softc *sc = (void *) self; | | 3378 | struct tulip_softc *sc = (void *) self; |
3379 | | | 3379 | |
3380 | mii_bitbang_writereg(self, sc->sc_bitbang_ops, phy, reg, val); | | 3380 | mii_bitbang_writereg(self, sc->sc_bitbang_ops, phy, reg, val); |
3381 | } | | 3381 | } |
3382 | | | 3382 | |
3383 | /* | | 3383 | /* |
3384 | * tlp_sio_mii_bitbang_read: | | 3384 | * tlp_sio_mii_bitbang_read: |
3385 | * | | 3385 | * |
3386 | * Read the MII serial port for the MII bit-bang module. | | 3386 | * Read the MII serial port for the MII bit-bang module. |
3387 | */ | | 3387 | */ |
3388 | static u_int32_t | | 3388 | static uint32_t |
3389 | tlp_sio_mii_bitbang_read(struct device *self) | | 3389 | tlp_sio_mii_bitbang_read(device_t self) |
3390 | { | | 3390 | { |
3391 | struct tulip_softc *sc = (void *) self; | | 3391 | struct tulip_softc *sc = (void *) self; |
3392 | | | 3392 | |
3393 | return (TULIP_READ(sc, CSR_MIIROM)); | | 3393 | return (TULIP_READ(sc, CSR_MIIROM)); |
3394 | } | | 3394 | } |
3395 | | | 3395 | |
3396 | /* | | 3396 | /* |
3397 | * tlp_sio_mii_bitbang_write: | | 3397 | * tlp_sio_mii_bitbang_write: |
3398 | * | | 3398 | * |
3399 | * Write the MII serial port for the MII bit-bang module. | | 3399 | * Write the MII serial port for the MII bit-bang module. |
3400 | */ | | 3400 | */ |
3401 | static void | | 3401 | static void |
3402 | tlp_sio_mii_bitbang_write(struct device *self, u_int32_t val) | | 3402 | tlp_sio_mii_bitbang_write(device_t self, uint32_t val) |
3403 | { | | 3403 | { |
3404 | struct tulip_softc *sc = (void *) self; | | 3404 | struct tulip_softc *sc = (void *) self; |
3405 | | | 3405 | |
3406 | TULIP_WRITE(sc, CSR_MIIROM, val); | | 3406 | TULIP_WRITE(sc, CSR_MIIROM, val); |
3407 | } | | 3407 | } |
3408 | | | 3408 | |
3409 | /* | | 3409 | /* |
3410 | * tlp_pnic_mii_readreg: | | 3410 | * tlp_pnic_mii_readreg: |
3411 | * | | 3411 | * |
3412 | * Read a PHY register on the Lite-On PNIC. | | 3412 | * Read a PHY register on the Lite-On PNIC. |
3413 | */ | | 3413 | */ |
3414 | static int | | 3414 | static int |
3415 | tlp_pnic_mii_readreg(struct device *self, int phy, int reg) | | 3415 | tlp_pnic_mii_readreg(device_t self, int phy, int reg) |
3416 | { | | 3416 | { |
3417 | struct tulip_softc *sc = (void *) self; | | 3417 | struct tulip_softc *sc = (void *) self; |
3418 | u_int32_t val; | | 3418 | uint32_t val; |
3419 | int i; | | 3419 | int i; |
3420 | | | 3420 | |
3421 | TULIP_WRITE(sc, CSR_PNIC_MII, | | 3421 | TULIP_WRITE(sc, CSR_PNIC_MII, |
3422 | PNIC_MII_MBO | PNIC_MII_RESERVED | | | 3422 | PNIC_MII_MBO | PNIC_MII_RESERVED | |
3423 | PNIC_MII_READ | (phy << PNIC_MII_PHYSHIFT) | | | 3423 | PNIC_MII_READ | (phy << PNIC_MII_PHYSHIFT) | |
3424 | (reg << PNIC_MII_REGSHIFT)); | | 3424 | (reg << PNIC_MII_REGSHIFT)); |
3425 | | | 3425 | |
3426 | for (i = 0; i < 1000; i++) { | | 3426 | for (i = 0; i < 1000; i++) { |
3427 | delay(10); | | 3427 | delay(10); |
3428 | val = TULIP_READ(sc, CSR_PNIC_MII); | | 3428 | val = TULIP_READ(sc, CSR_PNIC_MII); |
3429 | if ((val & PNIC_MII_BUSY) == 0) { | | 3429 | if ((val & PNIC_MII_BUSY) == 0) { |
3430 | if ((val & PNIC_MII_DATA) == PNIC_MII_DATA) | | 3430 | if ((val & PNIC_MII_DATA) == PNIC_MII_DATA) |
3431 | return (0); | | 3431 | return (0); |
| @@ -3433,27 +3433,27 @@ tlp_pnic_mii_readreg(struct device *self | | | @@ -3433,27 +3433,27 @@ tlp_pnic_mii_readreg(struct device *self |
3433 | return (val & PNIC_MII_DATA); | | 3433 | return (val & PNIC_MII_DATA); |
3434 | } | | 3434 | } |
3435 | } | | 3435 | } |
3436 | printf("%s: MII read timed out\n", device_xname(&sc->sc_dev)); | | 3436 | printf("%s: MII read timed out\n", device_xname(&sc->sc_dev)); |
3437 | return (0); | | 3437 | return (0); |
3438 | } | | 3438 | } |
3439 | | | 3439 | |
3440 | /* | | 3440 | /* |
3441 | * tlp_pnic_mii_writereg: | | 3441 | * tlp_pnic_mii_writereg: |
3442 | * | | 3442 | * |
3443 | * Write a PHY register on the Lite-On PNIC. | | 3443 | * Write a PHY register on the Lite-On PNIC. |
3444 | */ | | 3444 | */ |
3445 | static void | | 3445 | static void |
3446 | tlp_pnic_mii_writereg(struct device *self, int phy, int reg, int val) | | 3446 | tlp_pnic_mii_writereg(device_t self, int phy, int reg, int val) |
3447 | { | | 3447 | { |
3448 | struct tulip_softc *sc = (void *) self; | | 3448 | struct tulip_softc *sc = (void *) self; |
3449 | int i; | | 3449 | int i; |
3450 | | | 3450 | |
3451 | TULIP_WRITE(sc, CSR_PNIC_MII, | | 3451 | TULIP_WRITE(sc, CSR_PNIC_MII, |
3452 | PNIC_MII_MBO | PNIC_MII_RESERVED | | | 3452 | PNIC_MII_MBO | PNIC_MII_RESERVED | |
3453 | PNIC_MII_WRITE | (phy << PNIC_MII_PHYSHIFT) | | | 3453 | PNIC_MII_WRITE | (phy << PNIC_MII_PHYSHIFT) | |
3454 | (reg << PNIC_MII_REGSHIFT) | val); | | 3454 | (reg << PNIC_MII_REGSHIFT) | val); |
3455 | | | 3455 | |
3456 | for (i = 0; i < 1000; i++) { | | 3456 | for (i = 0; i < 1000; i++) { |
3457 | delay(10); | | 3457 | delay(10); |
3458 | if (TULIP_ISSET(sc, CSR_PNIC_MII, PNIC_MII_BUSY) == 0) | | 3458 | if (TULIP_ISSET(sc, CSR_PNIC_MII, PNIC_MII_BUSY) == 0) |
3459 | return; | | 3459 | return; |
| @@ -3474,48 +3474,48 @@ static const bus_addr_t tlp_al981_phy_re | | | @@ -3474,48 +3474,48 @@ static const bus_addr_t tlp_al981_phy_re |
3474 | CSR_ADM_XCIIS, | | 3474 | CSR_ADM_XCIIS, |
3475 | CSR_ADM_XIE, | | 3475 | CSR_ADM_XIE, |
3476 | CSR_ADM_100CTR, | | 3476 | CSR_ADM_100CTR, |
3477 | }; | | 3477 | }; |
3478 | static const int tlp_al981_phy_regmap_size = sizeof(tlp_al981_phy_regmap) / | | 3478 | static const int tlp_al981_phy_regmap_size = sizeof(tlp_al981_phy_regmap) / |
3479 | sizeof(tlp_al981_phy_regmap[0]); | | 3479 | sizeof(tlp_al981_phy_regmap[0]); |
3480 | | | 3480 | |
3481 | /* | | 3481 | /* |
3482 | * tlp_al981_mii_readreg: | | 3482 | * tlp_al981_mii_readreg: |
3483 | * | | 3483 | * |
3484 | * Read a PHY register on the ADMtek AL981. | | 3484 | * Read a PHY register on the ADMtek AL981. |
3485 | */ | | 3485 | */ |
3486 | static int | | 3486 | static int |
3487 | tlp_al981_mii_readreg(struct device *self, int phy, int reg) | | 3487 | tlp_al981_mii_readreg(device_t self, int phy, int reg) |
3488 | { | | 3488 | { |
3489 | struct tulip_softc *sc = (struct tulip_softc *)self; | | 3489 | struct tulip_softc *sc = (struct tulip_softc *)self; |
3490 | | | 3490 | |
3491 | /* AL981 only has an internal PHY. */ | | 3491 | /* AL981 only has an internal PHY. */ |
3492 | if (phy != 0) | | 3492 | if (phy != 0) |
3493 | return (0); | | 3493 | return (0); |
3494 | | | 3494 | |
3495 | if (reg >= tlp_al981_phy_regmap_size) | | 3495 | if (reg >= tlp_al981_phy_regmap_size) |
3496 | return (0); | | 3496 | return (0); |
3497 | | | 3497 | |
3498 | return (bus_space_read_4(sc->sc_st, sc->sc_sh, | | 3498 | return (bus_space_read_4(sc->sc_st, sc->sc_sh, |
3499 | tlp_al981_phy_regmap[reg]) & 0xffff); | | 3499 | tlp_al981_phy_regmap[reg]) & 0xffff); |
3500 | } | | 3500 | } |
3501 | | | 3501 | |
3502 | /* | | 3502 | /* |
3503 | * tlp_al981_mii_writereg: | | 3503 | * tlp_al981_mii_writereg: |
3504 | * | | 3504 | * |
3505 | * Write a PHY register on the ADMtek AL981. | | 3505 | * Write a PHY register on the ADMtek AL981. |
3506 | */ | | 3506 | */ |
3507 | static void | | 3507 | static void |
3508 | tlp_al981_mii_writereg(struct device *self, int phy, int reg, int val) | | 3508 | tlp_al981_mii_writereg(device_t self, int phy, int reg, int val) |
3509 | { | | 3509 | { |
3510 | struct tulip_softc *sc = (struct tulip_softc *)self; | | 3510 | struct tulip_softc *sc = (struct tulip_softc *)self; |
3511 | | | 3511 | |
3512 | /* AL981 only has an internal PHY. */ | | 3512 | /* AL981 only has an internal PHY. */ |
3513 | if (phy != 0) | | 3513 | if (phy != 0) |
3514 | return; | | 3514 | return; |
3515 | | | 3515 | |
3516 | if (reg >= tlp_al981_phy_regmap_size) | | 3516 | if (reg >= tlp_al981_phy_regmap_size) |
3517 | return; | | 3517 | return; |
3518 | | | 3518 | |
3519 | bus_space_write_4(sc->sc_st, sc->sc_sh, | | 3519 | bus_space_write_4(sc->sc_st, sc->sc_sh, |
3520 | tlp_al981_phy_regmap[reg], val); | | 3520 | tlp_al981_phy_regmap[reg], val); |
3521 | } | | 3521 | } |
| @@ -3675,27 +3675,27 @@ tlp_21140_reset(struct tulip_softc *sc) | | | @@ -3675,27 +3675,27 @@ tlp_21140_reset(struct tulip_softc *sc) |
3675 | } | | 3675 | } |
3676 | } | | 3676 | } |
3677 | | | 3677 | |
3678 | /* | | 3678 | /* |
3679 | * tlp_21142_reset: | | 3679 | * tlp_21142_reset: |
3680 | * | | 3680 | * |
3681 | * Issue a reset sequence on the 21142 via the GPIO facility. | | 3681 | * Issue a reset sequence on the 21142 via the GPIO facility. |
3682 | */ | | 3682 | */ |
3683 | static void | | 3683 | static void |
3684 | tlp_21142_reset(struct tulip_softc *sc) | | 3684 | tlp_21142_reset(struct tulip_softc *sc) |
3685 | { | | 3685 | { |
3686 | struct ifmedia_entry *ife = sc->sc_mii.mii_media.ifm_cur; | | 3686 | struct ifmedia_entry *ife = sc->sc_mii.mii_media.ifm_cur; |
3687 | struct tulip_21x4x_media *tm = ife->ifm_aux; | | 3687 | struct tulip_21x4x_media *tm = ife->ifm_aux; |
3688 | const u_int8_t *cp; | | 3688 | const uint8_t *cp; |
3689 | int i; | | 3689 | int i; |
3690 | | | 3690 | |
3691 | cp = &sc->sc_srom[tm->tm_reset_offset]; | | 3691 | cp = &sc->sc_srom[tm->tm_reset_offset]; |
3692 | for (i = 0; i < tm->tm_reset_length; i++, cp += 2) { | | 3692 | for (i = 0; i < tm->tm_reset_length; i++, cp += 2) { |
3693 | delay(10); | | 3693 | delay(10); |
3694 | TULIP_WRITE(sc, CSR_SIAGEN, TULIP_ROM_GETW(cp, 0) << 16); | | 3694 | TULIP_WRITE(sc, CSR_SIAGEN, TULIP_ROM_GETW(cp, 0) << 16); |
3695 | } | | 3695 | } |
3696 | | | 3696 | |
3697 | cp = &sc->sc_srom[tm->tm_gp_offset]; | | 3697 | cp = &sc->sc_srom[tm->tm_gp_offset]; |
3698 | for (i = 0; i < tm->tm_gp_length; i++, cp += 2) { | | 3698 | for (i = 0; i < tm->tm_gp_length; i++, cp += 2) { |
3699 | delay(10); | | 3699 | delay(10); |
3700 | TULIP_WRITE(sc, CSR_SIAGEN, TULIP_ROM_GETW(cp, 0) << 16); | | 3700 | TULIP_WRITE(sc, CSR_SIAGEN, TULIP_ROM_GETW(cp, 0) << 16); |
3701 | } | | 3701 | } |
| @@ -3925,39 +3925,39 @@ static const struct tulip_srom_to_ifmedi | | | @@ -3925,39 +3925,39 @@ static const struct tulip_srom_to_ifmedi |
3925 | { 0, | | 3925 | { 0, |
3926 | 0, | | 3926 | 0, |
3927 | 0 }, | | 3927 | 0 }, |
3928 | | | 3928 | |
3929 | { 0, | | 3929 | { 0, |
3930 | 0, | | 3930 | 0, |
3931 | 0 }, | | 3931 | 0 }, |
3932 | | | 3932 | |
3933 | { 0, | | 3933 | { 0, |
3934 | 0, | | 3934 | 0, |
3935 | 0 } }, | | 3935 | 0 } }, |
3936 | }; | | 3936 | }; |
3937 | | | 3937 | |
3938 | static const struct tulip_srom_to_ifmedia *tlp_srom_to_ifmedia(u_int8_t); | | 3938 | static const struct tulip_srom_to_ifmedia *tlp_srom_to_ifmedia(uint8_t); |
3939 | static void tlp_srom_media_info(struct tulip_softc *, | | 3939 | static void tlp_srom_media_info(struct tulip_softc *, |
3940 | const struct tulip_srom_to_ifmedia *, | | 3940 | const struct tulip_srom_to_ifmedia *, |
3941 | struct tulip_21x4x_media *); | | 3941 | struct tulip_21x4x_media *); |
3942 | static void tlp_add_srom_media(struct tulip_softc *, int, | | 3942 | static void tlp_add_srom_media(struct tulip_softc *, int, |
3943 | void (*)(struct tulip_softc *, struct ifmediareq *), | | 3943 | void (*)(struct tulip_softc *, struct ifmediareq *), |
3944 | int (*)(struct tulip_softc *), const u_int8_t *, int); | | 3944 | int (*)(struct tulip_softc *), const uint8_t *, int); |
3945 | static void tlp_print_media(struct tulip_softc *); | | 3945 | static void tlp_print_media(struct tulip_softc *); |
3946 | static void tlp_nway_activate(struct tulip_softc *, int); | | 3946 | static void tlp_nway_activate(struct tulip_softc *, int); |
3947 | static void tlp_get_minst(struct tulip_softc *); | | 3947 | static void tlp_get_minst(struct tulip_softc *); |
3948 | | | 3948 | |
3949 | static const struct tulip_srom_to_ifmedia * | | 3949 | static const struct tulip_srom_to_ifmedia * |
3950 | tlp_srom_to_ifmedia(u_int8_t sm) | | 3950 | tlp_srom_to_ifmedia(uint8_t sm) |
3951 | { | | 3951 | { |
3952 | const struct tulip_srom_to_ifmedia *tsti; | | 3952 | const struct tulip_srom_to_ifmedia *tsti; |
3953 | | | 3953 | |
3954 | for (tsti = tulip_srom_to_ifmedia_table; | | 3954 | for (tsti = tulip_srom_to_ifmedia_table; |
3955 | tsti->tsti_name != NULL; tsti++) { | | 3955 | tsti->tsti_name != NULL; tsti++) { |
3956 | if (tsti->tsti_srom == sm) | | 3956 | if (tsti->tsti_srom == sm) |
3957 | return (tsti); | | 3957 | return (tsti); |
3958 | } | | 3958 | } |
3959 | | | 3959 | |
3960 | return (NULL); | | 3960 | return (NULL); |
3961 | } | | 3961 | } |
3962 | | | 3962 | |
3963 | static void | | 3963 | static void |
| @@ -3989,27 +3989,27 @@ tlp_srom_media_info(struct tulip_softc * | | | @@ -3989,27 +3989,27 @@ tlp_srom_media_info(struct tulip_softc * |
3989 | case TULIP_CHIP_MX98725: | | 3989 | case TULIP_CHIP_MX98725: |
3990 | tm->tm_sia = tsti->tsti_21142; /* struct assignment */ | | 3990 | tm->tm_sia = tsti->tsti_21142; /* struct assignment */ |
3991 | break; | | 3991 | break; |
3992 | | | 3992 | |
3993 | default: | | 3993 | default: |
3994 | /* Nothing. */ | | 3994 | /* Nothing. */ |
3995 | break; | | 3995 | break; |
3996 | } | | 3996 | } |
3997 | } | | 3997 | } |
3998 | | | 3998 | |
3999 | static void | | 3999 | static void |
4000 | tlp_add_srom_media(struct tulip_softc *sc, int type, | | 4000 | tlp_add_srom_media(struct tulip_softc *sc, int type, |
4001 | void (*get)(struct tulip_softc *, struct ifmediareq *), | | 4001 | void (*get)(struct tulip_softc *, struct ifmediareq *), |
4002 | int (*set)(struct tulip_softc *), const u_int8_t *list, | | 4002 | int (*set)(struct tulip_softc *), const uint8_t *list, |
4003 | int cnt) | | 4003 | int cnt) |
4004 | { | | 4004 | { |
4005 | struct tulip_21x4x_media *tm; | | 4005 | struct tulip_21x4x_media *tm; |
4006 | const struct tulip_srom_to_ifmedia *tsti; | | 4006 | const struct tulip_srom_to_ifmedia *tsti; |
4007 | int i; | | 4007 | int i; |
4008 | | | 4008 | |
4009 | for (i = 0; i < cnt; i++) { | | 4009 | for (i = 0; i < cnt; i++) { |
4010 | tsti = tlp_srom_to_ifmedia(list[i]); | | 4010 | tsti = tlp_srom_to_ifmedia(list[i]); |
4011 | tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO); | | 4011 | tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO); |
4012 | tlp_srom_media_info(sc, tsti, tm); | | 4012 | tlp_srom_media_info(sc, tsti, tm); |
4013 | tm->tm_type = type; | | 4013 | tm->tm_type = type; |
4014 | tm->tm_get = get; | | 4014 | tm->tm_get = get; |
4015 | tm->tm_set = set; | | 4015 | tm->tm_set = set; |
| @@ -4084,27 +4084,27 @@ tlp_get_minst(struct tulip_softc *sc) | | | @@ -4084,27 +4084,27 @@ tlp_get_minst(struct tulip_softc *sc) |
4084 | * SIA Utility functions. | | 4084 | * SIA Utility functions. |
4085 | */ | | 4085 | */ |
4086 | static void tlp_sia_update_link(struct tulip_softc *); | | 4086 | static void tlp_sia_update_link(struct tulip_softc *); |
4087 | static void tlp_sia_get(struct tulip_softc *, struct ifmediareq *); | | 4087 | static void tlp_sia_get(struct tulip_softc *, struct ifmediareq *); |
4088 | static int tlp_sia_set(struct tulip_softc *); | | 4088 | static int tlp_sia_set(struct tulip_softc *); |
4089 | static int tlp_sia_media(struct tulip_softc *, struct ifmedia_entry *); | | 4089 | static int tlp_sia_media(struct tulip_softc *, struct ifmedia_entry *); |
4090 | static void tlp_sia_fixup(struct tulip_softc *); | | 4090 | static void tlp_sia_fixup(struct tulip_softc *); |
4091 | | | 4091 | |
4092 | static void | | 4092 | static void |
4093 | tlp_sia_update_link(struct tulip_softc *sc) | | 4093 | tlp_sia_update_link(struct tulip_softc *sc) |
4094 | { | | 4094 | { |
4095 | struct ifmedia_entry *ife; | | 4095 | struct ifmedia_entry *ife; |
4096 | struct tulip_21x4x_media *tm; | | 4096 | struct tulip_21x4x_media *tm; |
4097 | u_int32_t siastat; | | 4097 | uint32_t siastat; |
4098 | | | 4098 | |
4099 | ife = TULIP_CURRENT_MEDIA(sc); | | 4099 | ife = TULIP_CURRENT_MEDIA(sc); |
4100 | tm = ife->ifm_aux; | | 4100 | tm = ife->ifm_aux; |
4101 | | | 4101 | |
4102 | sc->sc_flags &= ~(TULIPF_LINK_UP|TULIPF_LINK_VALID); | | 4102 | sc->sc_flags &= ~(TULIPF_LINK_UP|TULIPF_LINK_VALID); |
4103 | | | 4103 | |
4104 | siastat = TULIP_READ(sc, CSR_SIASTAT); | | 4104 | siastat = TULIP_READ(sc, CSR_SIASTAT); |
4105 | | | 4105 | |
4106 | /* | | 4106 | /* |
4107 | * Note that when we do SIA link tests, we are assuming that | | 4107 | * Note that when we do SIA link tests, we are assuming that |
4108 | * the chip is really in the mode that the current media setting | | 4108 | * the chip is really in the mode that the current media setting |
4109 | * reflects. If we're not, then the link tests will not be | | 4109 | * reflects. If we're not, then the link tests will not be |
4110 | * accurate! | | 4110 | * accurate! |
| @@ -4179,27 +4179,27 @@ tlp_sia_get(struct tulip_softc *sc, stru | | | @@ -4179,27 +4179,27 @@ tlp_sia_get(struct tulip_softc *sc, stru |
4179 | | | 4179 | |
4180 | if (sc->sc_flags & TULIPF_LINK_VALID) | | 4180 | if (sc->sc_flags & TULIPF_LINK_VALID) |
4181 | ifmr->ifm_status |= IFM_AVALID; | | 4181 | ifmr->ifm_status |= IFM_AVALID; |
4182 | if (sc->sc_flags & TULIPF_LINK_UP) | | 4182 | if (sc->sc_flags & TULIPF_LINK_UP) |
4183 | ifmr->ifm_status |= IFM_ACTIVE; | | 4183 | ifmr->ifm_status |= IFM_ACTIVE; |
4184 | ifmr->ifm_active = ife->ifm_media; | | 4184 | ifmr->ifm_active = ife->ifm_media; |
4185 | } | | 4185 | } |
4186 | | | 4186 | |
4187 | static void | | 4187 | static void |
4188 | tlp_sia_fixup(struct tulip_softc *sc) | | 4188 | tlp_sia_fixup(struct tulip_softc *sc) |
4189 | { | | 4189 | { |
4190 | struct ifmedia_entry *ife; | | 4190 | struct ifmedia_entry *ife; |
4191 | struct tulip_21x4x_media *tm; | | 4191 | struct tulip_21x4x_media *tm; |
4192 | u_int32_t siaconn, siatxrx, siagen; | | 4192 | uint32_t siaconn, siatxrx, siagen; |
4193 | | | 4193 | |
4194 | switch (sc->sc_chip) { | | 4194 | switch (sc->sc_chip) { |
4195 | case TULIP_CHIP_82C115: | | 4195 | case TULIP_CHIP_82C115: |
4196 | case TULIP_CHIP_MX98713A: | | 4196 | case TULIP_CHIP_MX98713A: |
4197 | case TULIP_CHIP_MX98715: | | 4197 | case TULIP_CHIP_MX98715: |
4198 | case TULIP_CHIP_MX98715A: | | 4198 | case TULIP_CHIP_MX98715A: |
4199 | case TULIP_CHIP_MX98715AEC_X: | | 4199 | case TULIP_CHIP_MX98715AEC_X: |
4200 | case TULIP_CHIP_MX98725: | | 4200 | case TULIP_CHIP_MX98725: |
4201 | siaconn = PMAC_SIACONN_MASK; | | 4201 | siaconn = PMAC_SIACONN_MASK; |
4202 | siatxrx = PMAC_SIATXRX_MASK; | | 4202 | siatxrx = PMAC_SIATXRX_MASK; |
4203 | siagen = PMAC_SIAGEN_MASK; | | 4203 | siagen = PMAC_SIAGEN_MASK; |
4204 | break; | | 4204 | break; |
4205 | | | 4205 | |
| @@ -4366,27 +4366,27 @@ const struct tulip_mediasw tlp_21040_tp_ | | | @@ -4366,27 +4366,27 @@ const struct tulip_mediasw tlp_21040_tp_ |
4366 | }; | | 4366 | }; |
4367 | | | 4367 | |
4368 | const struct tulip_mediasw tlp_21040_auibnc_mediasw = { | | 4368 | const struct tulip_mediasw tlp_21040_auibnc_mediasw = { |
4369 | tlp_21040_auibnc_tmsw_init, tlp_sia_get, tlp_sia_set | | 4369 | tlp_21040_auibnc_tmsw_init, tlp_sia_get, tlp_sia_set |
4370 | }; | | 4370 | }; |
4371 | | | 4371 | |
4372 | const struct tulip_mediasw tlp_21041_mediasw = { | | 4372 | const struct tulip_mediasw tlp_21041_mediasw = { |
4373 | tlp_21041_tmsw_init, tlp_sia_get, tlp_sia_set | | 4373 | tlp_21041_tmsw_init, tlp_sia_get, tlp_sia_set |
4374 | }; | | 4374 | }; |
4375 | | | 4375 | |
4376 | static void | | 4376 | static void |
4377 | tlp_21040_tmsw_init(struct tulip_softc *sc) | | 4377 | tlp_21040_tmsw_init(struct tulip_softc *sc) |
4378 | { | | 4378 | { |
4379 | static const u_int8_t media[] = { | | 4379 | static const uint8_t media[] = { |
4380 | TULIP_ROM_MB_MEDIA_TP, | | 4380 | TULIP_ROM_MB_MEDIA_TP, |
4381 | TULIP_ROM_MB_MEDIA_TP_FDX, | | 4381 | TULIP_ROM_MB_MEDIA_TP_FDX, |
4382 | TULIP_ROM_MB_MEDIA_AUI, | | 4382 | TULIP_ROM_MB_MEDIA_AUI, |
4383 | }; | | 4383 | }; |
4384 | struct tulip_21x4x_media *tm; | | 4384 | struct tulip_21x4x_media *tm; |
4385 | | | 4385 | |
4386 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, | | 4386 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, |
4387 | tlp_mediastatus); | | 4387 | tlp_mediastatus); |
4388 | | | 4388 | |
4389 | tlp_add_srom_media(sc, 0, NULL, NULL, media, 3); | | 4389 | tlp_add_srom_media(sc, 0, NULL, NULL, media, 3); |
4390 | | | 4390 | |
4391 | /* | | 4391 | /* |
4392 | * No SROM type for External SIA. | | 4392 | * No SROM type for External SIA. |
| @@ -4403,72 +4403,72 @@ tlp_21040_tmsw_init(struct tulip_softc * | | | @@ -4403,72 +4403,72 @@ tlp_21040_tmsw_init(struct tulip_softc * |
4403 | /* | | 4403 | /* |
4404 | * XXX Autosense not yet supported. | | 4404 | * XXX Autosense not yet supported. |
4405 | */ | | 4405 | */ |
4406 | | | 4406 | |
4407 | /* XXX This should be auto-sense. */ | | 4407 | /* XXX This should be auto-sense. */ |
4408 | ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T); | | 4408 | ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T); |
4409 | | | 4409 | |
4410 | tlp_print_media(sc); | | 4410 | tlp_print_media(sc); |
4411 | } | | 4411 | } |
4412 | | | 4412 | |
4413 | static void | | 4413 | static void |
4414 | tlp_21040_tp_tmsw_init(struct tulip_softc *sc) | | 4414 | tlp_21040_tp_tmsw_init(struct tulip_softc *sc) |
4415 | { | | 4415 | { |
4416 | static const u_int8_t media[] = { | | 4416 | static const uint8_t media[] = { |
4417 | TULIP_ROM_MB_MEDIA_TP, | | 4417 | TULIP_ROM_MB_MEDIA_TP, |
4418 | TULIP_ROM_MB_MEDIA_TP_FDX, | | 4418 | TULIP_ROM_MB_MEDIA_TP_FDX, |
4419 | }; | | 4419 | }; |
4420 | | | 4420 | |
4421 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, | | 4421 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, |
4422 | tlp_mediastatus); | | 4422 | tlp_mediastatus); |
4423 | | | 4423 | |
4424 | tlp_add_srom_media(sc, 0, NULL, NULL, media, 2); | | 4424 | tlp_add_srom_media(sc, 0, NULL, NULL, media, 2); |
4425 | | | 4425 | |
4426 | ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T); | | 4426 | ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T); |
4427 | | | 4427 | |
4428 | tlp_print_media(sc); | | 4428 | tlp_print_media(sc); |
4429 | } | | 4429 | } |
4430 | | | 4430 | |
4431 | static void | | 4431 | static void |
4432 | tlp_21040_auibnc_tmsw_init(struct tulip_softc *sc) | | 4432 | tlp_21040_auibnc_tmsw_init(struct tulip_softc *sc) |
4433 | { | | 4433 | { |
4434 | static const u_int8_t media[] = { | | 4434 | static const uint8_t media[] = { |
4435 | TULIP_ROM_MB_MEDIA_AUI, | | 4435 | TULIP_ROM_MB_MEDIA_AUI, |
4436 | }; | | 4436 | }; |
4437 | | | 4437 | |
4438 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, | | 4438 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, |
4439 | tlp_mediastatus); | | 4439 | tlp_mediastatus); |
4440 | | | 4440 | |
4441 | tlp_add_srom_media(sc, 0, NULL, NULL, media, 1); | | 4441 | tlp_add_srom_media(sc, 0, NULL, NULL, media, 1); |
4442 | | | 4442 | |
4443 | ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_5); | | 4443 | ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_5); |
4444 | | | 4444 | |
4445 | tlp_print_media(sc); | | 4445 | tlp_print_media(sc); |
4446 | } | | 4446 | } |
4447 | | | 4447 | |
4448 | static void | | 4448 | static void |
4449 | tlp_21041_tmsw_init(struct tulip_softc *sc) | | 4449 | tlp_21041_tmsw_init(struct tulip_softc *sc) |
4450 | { | | 4450 | { |
4451 | static const u_int8_t media[] = { | | 4451 | static const uint8_t media[] = { |
4452 | TULIP_ROM_MB_MEDIA_TP, | | 4452 | TULIP_ROM_MB_MEDIA_TP, |
4453 | TULIP_ROM_MB_MEDIA_TP_FDX, | | 4453 | TULIP_ROM_MB_MEDIA_TP_FDX, |
4454 | TULIP_ROM_MB_MEDIA_BNC, | | 4454 | TULIP_ROM_MB_MEDIA_BNC, |
4455 | TULIP_ROM_MB_MEDIA_AUI, | | 4455 | TULIP_ROM_MB_MEDIA_AUI, |
4456 | }; | | 4456 | }; |
4457 | int i, defmedia, devcnt, leaf_offset, mb_offset, m_cnt; | | 4457 | int i, defmedia, devcnt, leaf_offset, mb_offset, m_cnt; |
4458 | const struct tulip_srom_to_ifmedia *tsti; | | 4458 | const struct tulip_srom_to_ifmedia *tsti; |
4459 | struct tulip_21x4x_media *tm; | | 4459 | struct tulip_21x4x_media *tm; |
4460 | u_int16_t romdef; | | 4460 | uint16_t romdef; |
4461 | u_int8_t mb; | | 4461 | uint8_t mb; |
4462 | | | 4462 | |
4463 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, | | 4463 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, |
4464 | tlp_mediastatus); | | 4464 | tlp_mediastatus); |
4465 | | | 4465 | |
4466 | if (tlp_isv_srom(sc->sc_srom) == 0) { | | 4466 | if (tlp_isv_srom(sc->sc_srom) == 0) { |
4467 | not_isv_srom: | | 4467 | not_isv_srom: |
4468 | /* | | 4468 | /* |
4469 | * If we have a board without the standard 21041 SROM format, | | 4469 | * If we have a board without the standard 21041 SROM format, |
4470 | * we just assume all media are present and try and pick a | | 4470 | * we just assume all media are present and try and pick a |
4471 | * reasonable default. | | 4471 | * reasonable default. |
4472 | */ | | 4472 | */ |
4473 | tlp_add_srom_media(sc, 0, NULL, NULL, media, 4); | | 4473 | tlp_add_srom_media(sc, 0, NULL, NULL, media, 4); |
4474 | | | 4474 | |
| @@ -4591,43 +4591,43 @@ tlp_21041_tmsw_init(struct tulip_softc * | | | @@ -4591,43 +4591,43 @@ tlp_21041_tmsw_init(struct tulip_softc * |
4591 | */ | | 4591 | */ |
4592 | static void tlp_2114x_isv_tmsw_init(struct tulip_softc *); | | 4592 | static void tlp_2114x_isv_tmsw_init(struct tulip_softc *); |
4593 | static void tlp_2114x_isv_tmsw_get(struct tulip_softc *, | | 4593 | static void tlp_2114x_isv_tmsw_get(struct tulip_softc *, |
4594 | struct ifmediareq *); | | 4594 | struct ifmediareq *); |
4595 | static int tlp_2114x_isv_tmsw_set(struct tulip_softc *); | | 4595 | static int tlp_2114x_isv_tmsw_set(struct tulip_softc *); |
4596 | | | 4596 | |
4597 | const struct tulip_mediasw tlp_2114x_isv_mediasw = { | | 4597 | const struct tulip_mediasw tlp_2114x_isv_mediasw = { |
4598 | tlp_2114x_isv_tmsw_init, tlp_2114x_isv_tmsw_get, tlp_2114x_isv_tmsw_set | | 4598 | tlp_2114x_isv_tmsw_init, tlp_2114x_isv_tmsw_get, tlp_2114x_isv_tmsw_set |
4599 | }; | | 4599 | }; |
4600 | | | 4600 | |
4601 | static void tlp_2114x_nway_get(struct tulip_softc *, struct ifmediareq *); | | 4601 | static void tlp_2114x_nway_get(struct tulip_softc *, struct ifmediareq *); |
4602 | static int tlp_2114x_nway_set(struct tulip_softc *); | | 4602 | static int tlp_2114x_nway_set(struct tulip_softc *); |
4603 | | | 4603 | |
4604 | static void tlp_2114x_nway_statchg(struct device *); | | 4604 | static void tlp_2114x_nway_statchg(device_t); |
4605 | static int tlp_2114x_nway_service(struct tulip_softc *, int); | | 4605 | static int tlp_2114x_nway_service(struct tulip_softc *, int); |
4606 | static void tlp_2114x_nway_auto(struct tulip_softc *); | | 4606 | static void tlp_2114x_nway_auto(struct tulip_softc *); |
4607 | static void tlp_2114x_nway_status(struct tulip_softc *); | | 4607 | static void tlp_2114x_nway_status(struct tulip_softc *); |
4608 | | | 4608 | |
4609 | static void | | 4609 | static void |
4610 | tlp_2114x_isv_tmsw_init(struct tulip_softc *sc) | | 4610 | tlp_2114x_isv_tmsw_init(struct tulip_softc *sc) |
4611 | { | | 4611 | { |
4612 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 4612 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
4613 | struct ifmedia_entry *ife; | | 4613 | struct ifmedia_entry *ife; |
4614 | struct mii_softc *phy; | | 4614 | struct mii_softc *phy; |
4615 | struct tulip_21x4x_media *tm; | | 4615 | struct tulip_21x4x_media *tm; |
4616 | const struct tulip_srom_to_ifmedia *tsti; | | 4616 | const struct tulip_srom_to_ifmedia *tsti; |
4617 | int i, devcnt, leaf_offset, m_cnt, type, length; | | 4617 | int i, devcnt, leaf_offset, m_cnt, type, length; |
4618 | int defmedia, miidef; | | 4618 | int defmedia, miidef; |
4619 | u_int16_t word; | | 4619 | uint16_t word; |
4620 | u_int8_t *cp, *ncp; | | 4620 | uint8_t *cp, *ncp; |
4621 | | | 4621 | |
4622 | defmedia = miidef = 0; | | 4622 | defmedia = miidef = 0; |
4623 | | | 4623 | |
4624 | sc->sc_mii.mii_ifp = ifp; | | 4624 | sc->sc_mii.mii_ifp = ifp; |
4625 | sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg; | | 4625 | sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg; |
4626 | sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg; | | 4626 | sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg; |
4627 | sc->sc_mii.mii_statchg = sc->sc_statchg; | | 4627 | sc->sc_mii.mii_statchg = sc->sc_statchg; |
4628 | | | 4628 | |
4629 | /* | | 4629 | /* |
4630 | * Ignore `instance'; we may get a mixture of SIA and MII | | 4630 | * Ignore `instance'; we may get a mixture of SIA and MII |
4631 | * media, and `instance' is used to isolate or select the | | 4631 | * media, and `instance' is used to isolate or select the |
4632 | * PHY on the MII as appropriate. Note that duplicate media | | 4632 | * PHY on the MII as appropriate. Note that duplicate media |
4633 | * are disallowed, so ignoring `instance' is safe. | | 4633 | * are disallowed, so ignoring `instance' is safe. |
| @@ -5154,27 +5154,27 @@ tlp_2114x_nway_get(struct tulip_softc *s | | | @@ -5154,27 +5154,27 @@ tlp_2114x_nway_get(struct tulip_softc *s |
5154 | (void) tlp_2114x_nway_service(sc, MII_POLLSTAT); | | 5154 | (void) tlp_2114x_nway_service(sc, MII_POLLSTAT); |
5155 | ifmr->ifm_status = sc->sc_mii.mii_media_status; | | 5155 | ifmr->ifm_status = sc->sc_mii.mii_media_status; |
5156 | ifmr->ifm_active = sc->sc_mii.mii_media_active; | | 5156 | ifmr->ifm_active = sc->sc_mii.mii_media_active; |
5157 | } | | 5157 | } |
5158 | | | 5158 | |
5159 | static int | | 5159 | static int |
5160 | tlp_2114x_nway_set(struct tulip_softc *sc) | | 5160 | tlp_2114x_nway_set(struct tulip_softc *sc) |
5161 | { | | 5161 | { |
5162 | | | 5162 | |
5163 | return (tlp_2114x_nway_service(sc, MII_MEDIACHG)); | | 5163 | return (tlp_2114x_nway_service(sc, MII_MEDIACHG)); |
5164 | } | | 5164 | } |
5165 | | | 5165 | |
5166 | static void | | 5166 | static void |
5167 | tlp_2114x_nway_statchg(struct device *self) | | 5167 | tlp_2114x_nway_statchg(device_t self) |
5168 | { | | 5168 | { |
5169 | struct tulip_softc *sc = (struct tulip_softc *)self; | | 5169 | struct tulip_softc *sc = (struct tulip_softc *)self; |
5170 | struct mii_data *mii = &sc->sc_mii; | | 5170 | struct mii_data *mii = &sc->sc_mii; |
5171 | struct ifmedia_entry *ife; | | 5171 | struct ifmedia_entry *ife; |
5172 | | | 5172 | |
5173 | if (IFM_SUBTYPE(mii->mii_media_active) == IFM_NONE) | | 5173 | if (IFM_SUBTYPE(mii->mii_media_active) == IFM_NONE) |
5174 | return; | | 5174 | return; |
5175 | | | 5175 | |
5176 | if ((ife = ifmedia_match(&mii->mii_media, mii->mii_media_active, | | 5176 | if ((ife = ifmedia_match(&mii->mii_media, mii->mii_media_active, |
5177 | mii->mii_media.ifm_mask)) == NULL) { | | 5177 | mii->mii_media.ifm_mask)) == NULL) { |
5178 | printf("tlp_2114x_nway_statchg: no match for media 0x%x/0x%x\n", | | 5178 | printf("tlp_2114x_nway_statchg: no match for media 0x%x/0x%x\n", |
5179 | mii->mii_media_active, ~mii->mii_media.ifm_mask); | | 5179 | mii->mii_media_active, ~mii->mii_media.ifm_mask); |
5180 | panic("tlp_2114x_nway_statchg"); | | 5180 | panic("tlp_2114x_nway_statchg"); |
| @@ -5466,27 +5466,27 @@ tlp_sio_mii_tmsw_init(struct tulip_softc | | | @@ -5466,27 +5466,27 @@ tlp_sio_mii_tmsw_init(struct tulip_softc |
5466 | } | | 5466 | } |
5467 | | | 5467 | |
5468 | /* | | 5468 | /* |
5469 | * Lite-On PNIC media switch. Must handle MII or internal NWAY. | | 5469 | * Lite-On PNIC media switch. Must handle MII or internal NWAY. |
5470 | */ | | 5470 | */ |
5471 | static void tlp_pnic_tmsw_init(struct tulip_softc *); | | 5471 | static void tlp_pnic_tmsw_init(struct tulip_softc *); |
5472 | static void tlp_pnic_tmsw_get(struct tulip_softc *, struct ifmediareq *); | | 5472 | static void tlp_pnic_tmsw_get(struct tulip_softc *, struct ifmediareq *); |
5473 | static int tlp_pnic_tmsw_set(struct tulip_softc *); | | 5473 | static int tlp_pnic_tmsw_set(struct tulip_softc *); |
5474 | | | 5474 | |
5475 | const struct tulip_mediasw tlp_pnic_mediasw = { | | 5475 | const struct tulip_mediasw tlp_pnic_mediasw = { |
5476 | tlp_pnic_tmsw_init, tlp_pnic_tmsw_get, tlp_pnic_tmsw_set | | 5476 | tlp_pnic_tmsw_init, tlp_pnic_tmsw_get, tlp_pnic_tmsw_set |
5477 | }; | | 5477 | }; |
5478 | | | 5478 | |
5479 | static void tlp_pnic_nway_statchg(struct device *); | | 5479 | static void tlp_pnic_nway_statchg(device_t); |
5480 | static void tlp_pnic_nway_tick(void *); | | 5480 | static void tlp_pnic_nway_tick(void *); |
5481 | static int tlp_pnic_nway_service(struct tulip_softc *, int); | | 5481 | static int tlp_pnic_nway_service(struct tulip_softc *, int); |
5482 | static void tlp_pnic_nway_reset(struct tulip_softc *); | | 5482 | static void tlp_pnic_nway_reset(struct tulip_softc *); |
5483 | static int tlp_pnic_nway_auto(struct tulip_softc *, int); | | 5483 | static int tlp_pnic_nway_auto(struct tulip_softc *, int); |
5484 | static void tlp_pnic_nway_auto_timeout(void *); | | 5484 | static void tlp_pnic_nway_auto_timeout(void *); |
5485 | static void tlp_pnic_nway_status(struct tulip_softc *); | | 5485 | static void tlp_pnic_nway_status(struct tulip_softc *); |
5486 | static void tlp_pnic_nway_acomp(struct tulip_softc *); | | 5486 | static void tlp_pnic_nway_acomp(struct tulip_softc *); |
5487 | | | 5487 | |
5488 | static void | | 5488 | static void |
5489 | tlp_pnic_tmsw_init(struct tulip_softc *sc) | | 5489 | tlp_pnic_tmsw_init(struct tulip_softc *sc) |
5490 | { | | 5490 | { |
5491 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 5491 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
5492 | const char *sep = ""; | | 5492 | const char *sep = ""; |
| @@ -5577,27 +5577,27 @@ tlp_pnic_tmsw_set(struct tulip_softc *sc | | | @@ -5577,27 +5577,27 @@ tlp_pnic_tmsw_set(struct tulip_softc *sc |
5577 | return (tlp_mii_setmedia(sc)); | | 5577 | return (tlp_mii_setmedia(sc)); |
5578 | } | | 5578 | } |
5579 | | | 5579 | |
5580 | if (ifp->if_flags & IFF_UP) { | | 5580 | if (ifp->if_flags & IFF_UP) { |
5581 | mii->mii_media_status = 0; | | 5581 | mii->mii_media_status = 0; |
5582 | mii->mii_media_active = IFM_NONE; | | 5582 | mii->mii_media_active = IFM_NONE; |
5583 | return (tlp_pnic_nway_service(sc, MII_MEDIACHG)); | | 5583 | return (tlp_pnic_nway_service(sc, MII_MEDIACHG)); |
5584 | } | | 5584 | } |
5585 | | | 5585 | |
5586 | return (0); | | 5586 | return (0); |
5587 | } | | 5587 | } |
5588 | | | 5588 | |
5589 | static void | | 5589 | static void |
5590 | tlp_pnic_nway_statchg(struct device *self) | | 5590 | tlp_pnic_nway_statchg(device_t self) |
5591 | { | | 5591 | { |
5592 | struct tulip_softc *sc = (struct tulip_softc *)self; | | 5592 | struct tulip_softc *sc = (struct tulip_softc *)self; |
5593 | | | 5593 | |
5594 | /* Idle the transmit and receive processes. */ | | 5594 | /* Idle the transmit and receive processes. */ |
5595 | tlp_idle(sc, OPMODE_ST|OPMODE_SR); | | 5595 | tlp_idle(sc, OPMODE_ST|OPMODE_SR); |
5596 | | | 5596 | |
5597 | sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD|OPMODE_PS|OPMODE_PCS| | | 5597 | sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD|OPMODE_PS|OPMODE_PCS| |
5598 | OPMODE_SCR|OPMODE_HBD); | | 5598 | OPMODE_SCR|OPMODE_HBD); |
5599 | | | 5599 | |
5600 | if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_10_T) { | | 5600 | if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_10_T) { |
5601 | sc->sc_opmode |= OPMODE_TTM; | | 5601 | sc->sc_opmode |= OPMODE_TTM; |
5602 | TULIP_WRITE(sc, CSR_GPP, | | 5602 | TULIP_WRITE(sc, CSR_GPP, |
5603 | GPP_PNIC_OUT(GPP_PNIC_PIN_SPEED_RLY, 0) | | | 5603 | GPP_PNIC_OUT(GPP_PNIC_PIN_SPEED_RLY, 0) | |
| @@ -5716,27 +5716,27 @@ static void | | | @@ -5716,27 +5716,27 @@ static void |
5716 | tlp_pnic_nway_reset(struct tulip_softc *sc) | | 5716 | tlp_pnic_nway_reset(struct tulip_softc *sc) |
5717 | { | | 5717 | { |
5718 | | | 5718 | |
5719 | TULIP_WRITE(sc, CSR_PNIC_NWAY, PNIC_NWAY_RS); | | 5719 | TULIP_WRITE(sc, CSR_PNIC_NWAY, PNIC_NWAY_RS); |
5720 | delay(100); | | 5720 | delay(100); |
5721 | TULIP_WRITE(sc, CSR_PNIC_NWAY, 0); | | 5721 | TULIP_WRITE(sc, CSR_PNIC_NWAY, 0); |
5722 | } | | 5722 | } |
5723 | | | 5723 | |
5724 | static int | | 5724 | static int |
5725 | tlp_pnic_nway_auto(struct tulip_softc *sc, int waitfor) | | 5725 | tlp_pnic_nway_auto(struct tulip_softc *sc, int waitfor) |
5726 | { | | 5726 | { |
5727 | struct mii_data *mii = &sc->sc_mii; | | 5727 | struct mii_data *mii = &sc->sc_mii; |
5728 | struct ifmedia_entry *ife = mii->mii_media.ifm_cur; | | 5728 | struct ifmedia_entry *ife = mii->mii_media.ifm_cur; |
5729 | u_int32_t reg; | | 5729 | uint32_t reg; |
5730 | int i; | | 5730 | int i; |
5731 | | | 5731 | |
5732 | if ((sc->sc_flags & TULIPF_DOINGAUTO) == 0) | | 5732 | if ((sc->sc_flags & TULIPF_DOINGAUTO) == 0) |
5733 | TULIP_WRITE(sc, CSR_PNIC_NWAY, ife->ifm_data); | | 5733 | TULIP_WRITE(sc, CSR_PNIC_NWAY, ife->ifm_data); |
5734 | | | 5734 | |
5735 | if (waitfor) { | | 5735 | if (waitfor) { |
5736 | /* Wait 500ms for it to complete. */ | | 5736 | /* Wait 500ms for it to complete. */ |
5737 | for (i = 0; i < 500; i++) { | | 5737 | for (i = 0; i < 500; i++) { |
5738 | reg = TULIP_READ(sc, CSR_PNIC_NWAY); | | 5738 | reg = TULIP_READ(sc, CSR_PNIC_NWAY); |
5739 | if (reg & PNIC_NWAY_LPAR_MASK) { | | 5739 | if (reg & PNIC_NWAY_LPAR_MASK) { |
5740 | tlp_pnic_nway_acomp(sc); | | 5740 | tlp_pnic_nway_acomp(sc); |
5741 | return (0); | | 5741 | return (0); |
5742 | } | | 5742 | } |
| @@ -5762,49 +5762,49 @@ tlp_pnic_nway_auto(struct tulip_softc *s | | | @@ -5762,49 +5762,49 @@ tlp_pnic_nway_auto(struct tulip_softc *s |
5762 | */ | | 5762 | */ |
5763 | if ((sc->sc_flags & TULIPF_DOINGAUTO) == 0) { | | 5763 | if ((sc->sc_flags & TULIPF_DOINGAUTO) == 0) { |
5764 | sc->sc_flags |= TULIPF_DOINGAUTO; | | 5764 | sc->sc_flags |= TULIPF_DOINGAUTO; |
5765 | callout_reset(&sc->sc_nway_callout, hz >> 1, | | 5765 | callout_reset(&sc->sc_nway_callout, hz >> 1, |
5766 | tlp_pnic_nway_auto_timeout, sc); | | 5766 | tlp_pnic_nway_auto_timeout, sc); |
5767 | } | | 5767 | } |
5768 | return (EJUSTRETURN); | | 5768 | return (EJUSTRETURN); |
5769 | } | | 5769 | } |
5770 | | | 5770 | |
5771 | static void | | 5771 | static void |
5772 | tlp_pnic_nway_auto_timeout(void *arg) | | 5772 | tlp_pnic_nway_auto_timeout(void *arg) |
5773 | { | | 5773 | { |
5774 | struct tulip_softc *sc = arg; | | 5774 | struct tulip_softc *sc = arg; |
5775 | u_int32_t reg; | | 5775 | uint32_t reg; |
5776 | int s; | | 5776 | int s; |
5777 | | | 5777 | |
5778 | s = splnet(); | | 5778 | s = splnet(); |
5779 | sc->sc_flags &= ~TULIPF_DOINGAUTO; | | 5779 | sc->sc_flags &= ~TULIPF_DOINGAUTO; |
5780 | reg = TULIP_READ(sc, CSR_PNIC_NWAY); | | 5780 | reg = TULIP_READ(sc, CSR_PNIC_NWAY); |
5781 | #if 0 | | 5781 | #if 0 |
5782 | if ((reg & PNIC_NWAY_LPAR_MASK) == 0) | | 5782 | if ((reg & PNIC_NWAY_LPAR_MASK) == 0) |
5783 | aprint_error_dev(&sc->sc_dev, "autonegotiation failed to complete\n"); | | 5783 | aprint_error_dev(&sc->sc_dev, "autonegotiation failed to complete\n"); |
5784 | #endif | | 5784 | #endif |
5785 | | | 5785 | |
5786 | tlp_pnic_nway_acomp(sc); | | 5786 | tlp_pnic_nway_acomp(sc); |
5787 | | | 5787 | |
5788 | /* Update the media status. */ | | 5788 | /* Update the media status. */ |
5789 | (void) tlp_pnic_nway_service(sc, MII_POLLSTAT); | | 5789 | (void) tlp_pnic_nway_service(sc, MII_POLLSTAT); |
5790 | splx(s); | | 5790 | splx(s); |
5791 | } | | 5791 | } |
5792 | | | 5792 | |
5793 | static void | | 5793 | static void |
5794 | tlp_pnic_nway_status(struct tulip_softc *sc) | | 5794 | tlp_pnic_nway_status(struct tulip_softc *sc) |
5795 | { | | 5795 | { |
5796 | struct mii_data *mii = &sc->sc_mii; | | 5796 | struct mii_data *mii = &sc->sc_mii; |
5797 | u_int32_t reg; | | 5797 | uint32_t reg; |
5798 | | | 5798 | |
5799 | mii->mii_media_status = IFM_AVALID; | | 5799 | mii->mii_media_status = IFM_AVALID; |
5800 | mii->mii_media_active = IFM_ETHER; | | 5800 | mii->mii_media_active = IFM_ETHER; |
5801 | | | 5801 | |
5802 | reg = TULIP_READ(sc, CSR_PNIC_NWAY); | | 5802 | reg = TULIP_READ(sc, CSR_PNIC_NWAY); |
5803 | | | 5803 | |
5804 | if (sc->sc_flags & TULIPF_LINK_UP) | | 5804 | if (sc->sc_flags & TULIPF_LINK_UP) |
5805 | mii->mii_media_status |= IFM_ACTIVE; | | 5805 | mii->mii_media_status |= IFM_ACTIVE; |
5806 | | | 5806 | |
5807 | if (reg & PNIC_NWAY_NW) { | | 5807 | if (reg & PNIC_NWAY_NW) { |
5808 | if ((reg & PNIC_NWAY_LPAR_MASK) == 0) { | | 5808 | if ((reg & PNIC_NWAY_LPAR_MASK) == 0) { |
5809 | /* Erg, still trying, I guess... */ | | 5809 | /* Erg, still trying, I guess... */ |
5810 | mii->mii_media_active |= IFM_NONE; | | 5810 | mii->mii_media_active |= IFM_NONE; |
| @@ -5829,27 +5829,27 @@ tlp_pnic_nway_status(struct tulip_softc | | | @@ -5829,27 +5829,27 @@ tlp_pnic_nway_status(struct tulip_softc |
5829 | } else { | | 5829 | } else { |
5830 | if (reg & PNIC_NWAY_100) | | 5830 | if (reg & PNIC_NWAY_100) |
5831 | mii->mii_media_active |= IFM_100_TX; | | 5831 | mii->mii_media_active |= IFM_100_TX; |
5832 | else | | 5832 | else |
5833 | mii->mii_media_active |= IFM_10_T; | | 5833 | mii->mii_media_active |= IFM_10_T; |
5834 | if (reg & PNIC_NWAY_FD) | | 5834 | if (reg & PNIC_NWAY_FD) |
5835 | mii->mii_media_active |= IFM_FDX; | | 5835 | mii->mii_media_active |= IFM_FDX; |
5836 | } | | 5836 | } |
5837 | } | | 5837 | } |
5838 | | | 5838 | |
5839 | static void | | 5839 | static void |
5840 | tlp_pnic_nway_acomp(struct tulip_softc *sc) | | 5840 | tlp_pnic_nway_acomp(struct tulip_softc *sc) |
5841 | { | | 5841 | { |
5842 | u_int32_t reg; | | 5842 | uint32_t reg; |
5843 | | | 5843 | |
5844 | reg = TULIP_READ(sc, CSR_PNIC_NWAY); | | 5844 | reg = TULIP_READ(sc, CSR_PNIC_NWAY); |
5845 | reg &= ~(PNIC_NWAY_FD|PNIC_NWAY_100|PNIC_NWAY_RN); | | 5845 | reg &= ~(PNIC_NWAY_FD|PNIC_NWAY_100|PNIC_NWAY_RN); |
5846 | | | 5846 | |
5847 | if (reg & (PNIC_NWAY_LPAR100TXFDX|PNIC_NWAY_LPAR100TX)) | | 5847 | if (reg & (PNIC_NWAY_LPAR100TXFDX|PNIC_NWAY_LPAR100TX)) |
5848 | reg |= PNIC_NWAY_100; | | 5848 | reg |= PNIC_NWAY_100; |
5849 | if (reg & (PNIC_NWAY_LPAR10TFDX|PNIC_NWAY_LPAR100TXFDX)) | | 5849 | if (reg & (PNIC_NWAY_LPAR10TFDX|PNIC_NWAY_LPAR100TXFDX)) |
5850 | reg |= PNIC_NWAY_FD; | | 5850 | reg |= PNIC_NWAY_FD; |
5851 | | | 5851 | |
5852 | TULIP_WRITE(sc, CSR_PNIC_NWAY, reg); | | 5852 | TULIP_WRITE(sc, CSR_PNIC_NWAY, reg); |
5853 | } | | 5853 | } |
5854 | | | 5854 | |
5855 | /* | | 5855 | /* |
| @@ -5869,27 +5869,27 @@ tlp_pnic_nway_acomp(struct tulip_softc * | | | @@ -5869,27 +5869,27 @@ tlp_pnic_nway_acomp(struct tulip_softc * |
5869 | static void tlp_pmac_tmsw_init(struct tulip_softc *); | | 5869 | static void tlp_pmac_tmsw_init(struct tulip_softc *); |
5870 | | | 5870 | |
5871 | const struct tulip_mediasw tlp_pmac_mediasw = { | | 5871 | const struct tulip_mediasw tlp_pmac_mediasw = { |
5872 | tlp_pmac_tmsw_init, tlp_2114x_isv_tmsw_get, tlp_2114x_isv_tmsw_set | | 5872 | tlp_pmac_tmsw_init, tlp_2114x_isv_tmsw_get, tlp_2114x_isv_tmsw_set |
5873 | }; | | 5873 | }; |
5874 | | | 5874 | |
5875 | const struct tulip_mediasw tlp_pmac_mii_mediasw = { | | 5875 | const struct tulip_mediasw tlp_pmac_mii_mediasw = { |
5876 | tlp_pmac_tmsw_init, tlp_mii_getmedia, tlp_mii_setmedia | | 5876 | tlp_pmac_tmsw_init, tlp_mii_getmedia, tlp_mii_setmedia |
5877 | }; | | 5877 | }; |
5878 | | | 5878 | |
5879 | static void | | 5879 | static void |
5880 | tlp_pmac_tmsw_init(struct tulip_softc *sc) | | 5880 | tlp_pmac_tmsw_init(struct tulip_softc *sc) |
5881 | { | | 5881 | { |
5882 | static const u_int8_t media[] = { | | 5882 | static const uint8_t media[] = { |
5883 | TULIP_ROM_MB_MEDIA_TP, | | 5883 | TULIP_ROM_MB_MEDIA_TP, |
5884 | TULIP_ROM_MB_MEDIA_TP_FDX, | | 5884 | TULIP_ROM_MB_MEDIA_TP_FDX, |
5885 | TULIP_ROM_MB_MEDIA_100TX, | | 5885 | TULIP_ROM_MB_MEDIA_100TX, |
5886 | TULIP_ROM_MB_MEDIA_100TX_FDX, | | 5886 | TULIP_ROM_MB_MEDIA_100TX_FDX, |
5887 | }; | | 5887 | }; |
5888 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 5888 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
5889 | struct tulip_21x4x_media *tm; | | 5889 | struct tulip_21x4x_media *tm; |
5890 | | | 5890 | |
5891 | sc->sc_mii.mii_ifp = ifp; | | 5891 | sc->sc_mii.mii_ifp = ifp; |
5892 | sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg; | | 5892 | sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg; |
5893 | sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg; | | 5893 | sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg; |
5894 | sc->sc_mii.mii_statchg = sc->sc_statchg; | | 5894 | sc->sc_mii.mii_statchg = sc->sc_statchg; |
5895 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, | | 5895 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, |
| @@ -6023,27 +6023,27 @@ static void tlp_dm9102_tmsw_init(struct | | | @@ -6023,27 +6023,27 @@ static void tlp_dm9102_tmsw_init(struct |
6023 | static void tlp_dm9102_tmsw_getmedia(struct tulip_softc *, | | 6023 | static void tlp_dm9102_tmsw_getmedia(struct tulip_softc *, |
6024 | struct ifmediareq *); | | 6024 | struct ifmediareq *); |
6025 | static int tlp_dm9102_tmsw_setmedia(struct tulip_softc *); | | 6025 | static int tlp_dm9102_tmsw_setmedia(struct tulip_softc *); |
6026 | | | 6026 | |
6027 | const struct tulip_mediasw tlp_dm9102_mediasw = { | | 6027 | const struct tulip_mediasw tlp_dm9102_mediasw = { |
6028 | tlp_dm9102_tmsw_init, tlp_dm9102_tmsw_getmedia, | | 6028 | tlp_dm9102_tmsw_init, tlp_dm9102_tmsw_getmedia, |
6029 | tlp_dm9102_tmsw_setmedia | | 6029 | tlp_dm9102_tmsw_setmedia |
6030 | }; | | 6030 | }; |
6031 | | | 6031 | |
6032 | static void | | 6032 | static void |
6033 | tlp_dm9102_tmsw_init(struct tulip_softc *sc) | | 6033 | tlp_dm9102_tmsw_init(struct tulip_softc *sc) |
6034 | { | | 6034 | { |
6035 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 6035 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
6036 | u_int32_t opmode; | | 6036 | uint32_t opmode; |
6037 | | | 6037 | |
6038 | sc->sc_mii.mii_ifp = ifp; | | 6038 | sc->sc_mii.mii_ifp = ifp; |
6039 | sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg; | | 6039 | sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg; |
6040 | sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg; | | 6040 | sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg; |
6041 | sc->sc_mii.mii_statchg = sc->sc_statchg; | | 6041 | sc->sc_mii.mii_statchg = sc->sc_statchg; |
6042 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, | | 6042 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, |
6043 | tlp_mediastatus); | | 6043 | tlp_mediastatus); |
6044 | | | 6044 | |
6045 | /* PHY block already reset via tlp_reset(). */ | | 6045 | /* PHY block already reset via tlp_reset(). */ |
6046 | | | 6046 | |
6047 | /* | | 6047 | /* |
6048 | * Configure OPMODE properly for the internal MII interface. | | 6048 | * Configure OPMODE properly for the internal MII interface. |
6049 | */ | | 6049 | */ |
| @@ -6106,27 +6106,27 @@ static void tlp_asix_tmsw_init(struct tu | | | @@ -6106,27 +6106,27 @@ static void tlp_asix_tmsw_init(struct tu |
6106 | static void tlp_asix_tmsw_getmedia(struct tulip_softc *, | | 6106 | static void tlp_asix_tmsw_getmedia(struct tulip_softc *, |
6107 | struct ifmediareq *); | | 6107 | struct ifmediareq *); |
6108 | static int tlp_asix_tmsw_setmedia(struct tulip_softc *); | | 6108 | static int tlp_asix_tmsw_setmedia(struct tulip_softc *); |
6109 | | | 6109 | |
6110 | const struct tulip_mediasw tlp_asix_mediasw = { | | 6110 | const struct tulip_mediasw tlp_asix_mediasw = { |
6111 | tlp_asix_tmsw_init, tlp_asix_tmsw_getmedia, | | 6111 | tlp_asix_tmsw_init, tlp_asix_tmsw_getmedia, |
6112 | tlp_asix_tmsw_setmedia | | 6112 | tlp_asix_tmsw_setmedia |
6113 | }; | | 6113 | }; |
6114 | | | 6114 | |
6115 | static void | | 6115 | static void |
6116 | tlp_asix_tmsw_init(struct tulip_softc *sc) | | 6116 | tlp_asix_tmsw_init(struct tulip_softc *sc) |
6117 | { | | 6117 | { |
6118 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 6118 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
6119 | u_int32_t opmode; | | 6119 | uint32_t opmode; |
6120 | | | 6120 | |
6121 | sc->sc_mii.mii_ifp = ifp; | | 6121 | sc->sc_mii.mii_ifp = ifp; |
6122 | sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg; | | 6122 | sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg; |
6123 | sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg; | | 6123 | sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg; |
6124 | sc->sc_mii.mii_statchg = sc->sc_statchg; | | 6124 | sc->sc_mii.mii_statchg = sc->sc_statchg; |
6125 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, | | 6125 | ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange, |
6126 | tlp_mediastatus); | | 6126 | tlp_mediastatus); |
6127 | | | 6127 | |
6128 | /* | | 6128 | /* |
6129 | * Configure OPMODE properly for the internal MII interface. | | 6129 | * Configure OPMODE properly for the internal MII interface. |
6130 | */ | | 6130 | */ |
6131 | switch (sc->sc_chip) { | | 6131 | switch (sc->sc_chip) { |
6132 | case TULIP_CHIP_AX88140: | | 6132 | case TULIP_CHIP_AX88140: |