2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Herb Peyerl.
16 * 4. The name of Herb Peyerl may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * if_ep.c,v 1.19 1995/01/24 20:53:45 davidg Exp
34 * Modified from the FreeBSD 1.1.5.1 version by:
36 * INRIA - Sophia Antipolis, France
37 * avega@sophia.inria.fr
43 * Promiscuous mode added and interrupt logic slightly changed
44 * to reduce the number of adapter failures. Transceiver select
45 * logic changed to use value from EEPROM. Autoconfiguration
49 * Chelindbank (Chelyabinsk, Russia)
50 * babkin@hq.icb.chel.su
54 * Pccard support for 3C589 by:
60 * MAINTAINER: Matthew N. Dodd <winter@jurai.net>
64 #include <sys/param.h>
65 #include <sys/systm.h>
67 #include <sys/socket.h>
68 #include <sys/sockio.h>
72 #include <machine/bus.h>
73 #include <machine/resource.h>
77 #include <net/if_arp.h>
78 #include <net/if_media.h>
79 #include <net/ethernet.h>
83 #include <dev/ep/if_epreg.h>
84 #include <dev/ep/if_epvar.h>
86 /* Exported variables */
87 devclass_t ep_devclass;
90 static char * ep_conn_type[] = {"UTP", "AUI", "???", "BNC"};
91 static int if_media2ep_media[] = { 0, 0, 0, UTP, BNC, AUI };
94 static int ep_media2if_media[] =
95 { IFM_10_T, IFM_10_5, IFM_NONE, IFM_10_2, IFM_NONE };
98 static void ep_if_init __P((void *));
99 static int ep_if_ioctl __P((struct ifnet *, u_long, caddr_t));
100 static void ep_if_start __P((struct ifnet *));
101 static void ep_if_watchdog __P((struct ifnet *));
103 /* if_media functions */
104 static int ep_ifmedia_upd __P((struct ifnet *));
105 static void ep_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
107 static void epstop __P((struct ep_softc *));
108 static void epread __P((struct ep_softc *));
109 static int eeprom_rdy __P((struct ep_softc *));
111 #define EP_FTST(sc, f) (sc->stat & (f))
112 #define EP_FSET(sc, f) (sc->stat |= (f))
113 #define EP_FRST(sc, f) (sc->stat &= ~(f))
121 for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) {
124 if (i >= MAX_EEPROMBUSY) {
125 printf("ep%d: eeprom failed to come ready.\n", sc->unit);
132 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
142 outw(BASE + EP_W0_EEPROM_COMMAND, (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
145 return (inw(BASE + EP_W0_EEPROM_DATA));
149 ep_get_macaddr(sc, addr)
150 struct ep_softc * sc;
154 u_int16_t * macaddr = (u_int16_t *)addr;
157 for(i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) {
158 macaddr[i] = htons(get_e(sc, i));
165 ep_alloc(device_t dev)
167 struct ep_softc * sc = device_get_softc(dev);
172 sc->iobase = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
173 0, ~0, 1, RF_ACTIVE);
175 device_printf(dev, "No I/O space?!\n");
181 sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
182 0, ~0, 1, RF_ACTIVE);
184 device_printf(dev, "No irq?!\n");
190 sc->unit = device_get_unit(dev);
191 sc->stat = 0; /* 16 bit access */
193 sc->ep_io_addr = rman_get_start(sc->iobase);
195 sc->ep_btag = rman_get_bustag(sc->iobase);
196 sc->ep_bhandle = rman_get_bushandle(sc->iobase);
198 sc->ep_connectors = 0;
199 sc->ep_connector = 0;
203 sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID);
204 sc->epb.res_cfg = get_e(sc, EEPROM_RESOURCE_CFG);
212 struct ep_softc * sc;
217 config = inw(BASE + EP_W0_CONFIG_CTRL);
219 sc->ep_connectors |= AUI;
221 sc->ep_connectors |= BNC;
223 sc->ep_connectors |= UTP;
225 if (!(sc->ep_connectors & 7)) {
227 device_printf(sc->dev, "no connectors!\n");
231 * This works for most of the cards so we'll do it here.
232 * The cards that require something different can override
235 sc->ep_connector = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS;
241 ep_free(device_t dev)
243 struct ep_softc * sc = device_get_softc(dev);
246 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->iobase);
248 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
255 struct ep_softc * sc;
257 struct ifnet * ifp = NULL;
258 struct ifmedia * ifm = NULL;
265 ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
268 * Setup the station address
270 p = (u_short *)&sc->arpcom.ac_enaddr;
272 for (i = 0; i < 3; i++) {
273 outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));
276 device_printf(sc->dev, "Ethernet address %6D\n",
277 sc->arpcom.ac_enaddr, ":");
279 ifp = &sc->arpcom.ac_if;
280 attached = (ifp->if_softc != 0);
283 ifp->if_unit = sc->unit;
285 ifp->if_mtu = ETHERMTU;
286 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
287 ifp->if_output = ether_output;
288 ifp->if_start = ep_if_start;
289 ifp->if_ioctl = ep_if_ioctl;
290 ifp->if_watchdog = ep_if_watchdog;
291 ifp->if_init = ep_if_init;
292 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
294 if (!sc->epb.mii_trans) {
295 ifmedia_init(&sc->ifmedia, 0, ep_ifmedia_upd, ep_ifmedia_sts);
297 if (sc->ep_connectors & AUI)
298 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_5, 0, NULL);
299 if (sc->ep_connectors & UTP)
300 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL);
301 if (sc->ep_connectors & BNC)
302 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_2, 0, NULL);
303 if (!sc->ep_connectors)
304 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_NONE, 0, NULL);
306 ifmedia_set(&sc->ifmedia, IFM_ETHER|ep_media2if_media[sc->ep_connector]);
309 ifm->ifm_media = ifm->ifm_cur->ifm_media;
314 ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
316 #ifdef EP_LOCAL_STATS
317 sc->rx_no_first = sc->rx_no_mbuf = sc->rx_bpf_disc =
318 sc->rx_overrunf = sc->rx_overrunl = sc->tx_underrun = 0;
320 EP_FSET(sc, F_RX_FIRST);
321 sc->top = sc->mcur = 0;
329 * The order in here seems important. Otherwise we may not receive
336 struct ep_softc *sc = xsc;
337 register struct ifnet *ifp = &sc->arpcom.ac_if;
344 if (ifp->if_addrlist == (struct ifaddr *) 0)
349 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
352 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
354 outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP);
357 /* Disable the card */
358 outw(BASE + EP_W0_CONFIG_CTRL, 0);
360 /* Enable the card */
361 outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ);
365 /* Reload the ether_addr. */
366 for (i = 0; i < 6; i++)
367 outb(BASE + EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
369 outw(BASE + EP_COMMAND, RX_RESET);
370 outw(BASE + EP_COMMAND, TX_RESET);
371 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
373 /* Window 1 is operating window */
375 for (i = 0; i < 31; i++)
376 inb(BASE + EP_W1_TX_STATUS);
378 /* get rid of stray intr's */
379 outw(BASE + EP_COMMAND, ACK_INTR | 0xff);
381 outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_5_INTS);
383 outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
385 if (ifp->if_flags & IFF_PROMISC)
386 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
387 FIL_GROUP | FIL_BRDCST | FIL_ALL);
389 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
390 FIL_GROUP | FIL_BRDCST);
392 if (!sc->epb.mii_trans) {
396 outw(BASE + EP_COMMAND, RX_ENABLE);
397 outw(BASE + EP_COMMAND, TX_ENABLE);
399 ifp->if_flags |= IFF_RUNNING;
400 ifp->if_flags &= ~IFF_OACTIVE; /* just in case */
402 #ifdef EP_LOCAL_STATS
403 sc->rx_no_first = sc->rx_no_mbuf =
404 sc->rx_overrunf = sc->rx_overrunl = sc->tx_underrun = 0;
406 EP_FSET(sc, F_RX_FIRST);
409 sc->top = sc->mcur = 0;
411 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
412 outw(BASE + EP_COMMAND, SET_TX_START_THRESH | 16);
415 * Store up a bunch of mbuf's for use later. (MAX_MBS). First we free up
416 * any that we had in case we're being called from intr or somewhere
430 struct ep_softc *sc = ifp->if_softc;
440 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
441 if (ifp->if_flags & IFF_OACTIVE) {
446 /* Sneak a peek at the next packet */
447 m = ifp->if_snd.ifq_head;
451 for (len = 0, top = m; m; m = m->m_next)
457 * The 3c509 automatically pads short packets to minimum ethernet length,
458 * but we drop packets that are too large. Perhaps we should truncate
461 if (len + pad > ETHER_MAX_LEN) {
462 /* packet is obviously too large: toss it */
464 IF_DEQUEUE(&ifp->if_snd, m);
468 if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
469 /* no room in FIFO */
470 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4));
472 if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
473 ifp->if_flags |= IFF_OACTIVE;
477 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | EP_THRESH_DISABLE);
480 IF_DEQUEUE(&ifp->if_snd, m);
484 outw(BASE + EP_W1_TX_PIO_WR_1, len);
485 outw(BASE + EP_W1_TX_PIO_WR_1, 0x0); /* Second dword meaningless */
487 if (EP_FTST(sc, F_ACCESS_32_BITS)) {
488 for (top = m; m != 0; m = m->m_next) {
490 outsl(BASE + EP_W1_TX_PIO_WR_1,
491 mtod(m, caddr_t), m->m_len / 4);
493 outsb(BASE + EP_W1_TX_PIO_WR_1,
494 mtod(m, caddr_t) + (m->m_len & (~3)), m->m_len & 3);
497 for (top = m; m != 0; m = m->m_next) {
499 outsw(BASE + EP_W1_TX_PIO_WR_1,
500 mtod(m, caddr_t), m->m_len / 2);
502 outb(BASE + EP_W1_TX_PIO_WR_1,
503 *(mtod(m, caddr_t) + m->m_len - 1));
508 outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */
521 * Is another packet coming in? We don't want to overflow the tiny RX
525 if (inw(BASE + EP_W1_RX_STATUS) & RX_BYTES_MASK) {
527 * we check if we have packets left, in that case we prepare to come
530 if (ifp->if_snd.ifq_head) {
531 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
549 sc = (struct ep_softc *)arg;
552 * quick fix: Try to detect an interrupt when the card goes away.
554 if (sc->gone || inw(BASE + EP_STATUS) == 0xffff) {
559 ifp = &sc->arpcom.ac_if;
561 outw(BASE + EP_COMMAND, SET_INTR_MASK); /* disable all Ints */
565 while ((status = inw(BASE + EP_STATUS)) & S_5_INTS) {
567 /* first acknowledge all interrupt sources */
568 outw(BASE + EP_COMMAND, ACK_INTR | (status & S_MASK));
570 if (status & (S_RX_COMPLETE | S_RX_EARLY))
572 if (status & S_TX_AVAIL) {
575 ifp->if_flags &= ~IFF_OACTIVE;
577 inw(BASE + EP_W1_FREE_TX);
580 if (status & S_CARD_FAILURE) {
582 #ifdef EP_LOCAL_STATS
583 printf("\nep%d:\n\tStatus: %x\n", sc->unit, status);
585 printf("\tFIFO Diagnostic: %x\n", inw(BASE + EP_W4_FIFO_DIAG));
586 printf("\tStat: %x\n", sc->stat);
587 printf("\tIpackets=%d, Opackets=%d\n",
588 ifp->if_ipackets, ifp->if_opackets);
589 printf("\tNOF=%d, NOMB=%d, RXOF=%d, RXOL=%d, TXU=%d\n",
590 sc->rx_no_first, sc->rx_no_mbuf, sc->rx_overrunf,
591 sc->rx_overrunl, sc->tx_underrun);
595 printf("ep%d: Status: %x (input buffer overflow)\n", sc->unit, status);
605 if (status & S_TX_COMPLETE) {
607 /* we need ACK. we do it at the end */
609 * We need to read TX_STATUS until we get a 0 status in order to
610 * turn off the interrupt flag.
612 while ((status = inb(BASE + EP_W1_TX_STATUS)) & TXS_COMPLETE) {
613 if (status & TXS_SUCCES_INTR_REQ);
614 else if (status & (TXS_UNDERRUN | TXS_JABBER | TXS_MAX_COLLISION)) {
615 outw(BASE + EP_COMMAND, TX_RESET);
616 if (status & TXS_UNDERRUN) {
617 #ifdef EP_LOCAL_STATS
621 if (status & TXS_JABBER);
622 else /* TXS_MAX_COLLISION - we shouldn't get here */
623 ++ifp->if_collisions;
626 outw(BASE + EP_COMMAND, TX_ENABLE);
628 * To have a tx_avail_int but giving the chance to the
631 if (ifp->if_snd.ifq_head) {
632 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
635 outb(BASE + EP_W1_TX_STATUS, 0x0); /* pops up the next
638 ifp->if_flags &= ~IFF_OACTIVE;
640 inw(BASE + EP_W1_FREE_TX);
642 } /* end TX_COMPLETE */
645 outw(BASE + EP_COMMAND, C_INTR_LATCH); /* ACK int Latch */
647 if ((status = inw(BASE + EP_STATUS)) & S_5_INTS)
651 outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
658 register struct ep_softc *sc;
660 struct ether_header *eh;
661 struct mbuf *top, *mcur, *m;
665 short rx_fifo2, status;
666 register short rx_fifo;
668 ifp = &sc->arpcom.ac_if;
669 status = inw(BASE + EP_W1_RX_STATUS);
673 if (status & ERR_RX) {
675 if (status & ERR_RX_OVERRUN) {
677 * we can think the rx latency is actually greather than we
680 #ifdef EP_LOCAL_STATS
681 if (EP_FTST(sc, F_RX_FIRST))
689 rx_fifo = rx_fifo2 = status & RX_BYTES_MASK;
691 if (EP_FTST(sc, F_RX_FIRST)) {
692 MGETHDR(m, M_DONTWAIT, MT_DATA);
695 if (rx_fifo >= MINCLSIZE)
696 MCLGET(m, M_DONTWAIT);
697 sc->top = sc->mcur = top = m;
698 #define EROUND ((sizeof(struct ether_header) + 3) & ~3)
699 #define EOFF (EROUND - sizeof(struct ether_header))
702 /* Read what should be the header. */
703 insw(BASE + EP_W1_RX_PIO_RD_1,
704 mtod(top, caddr_t), sizeof(struct ether_header) / 2);
705 top->m_len = sizeof(struct ether_header);
706 rx_fifo -= sizeof(struct ether_header);
707 sc->cur_len = rx_fifo2;
709 /* come here if we didn't have a complete packet last time */
712 sc->cur_len += rx_fifo2;
715 /* Reads what is left in the RX FIFO */
716 while (rx_fifo > 0) {
717 lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
718 if (lenthisone == 0) { /* no room in this one */
720 MGET(m, M_DONTWAIT, MT_DATA);
723 if (rx_fifo >= MINCLSIZE)
724 MCLGET(m, M_DONTWAIT);
727 lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
729 if (EP_FTST(sc, F_ACCESS_32_BITS)) { /* default for EISA configured cards*/
730 insl(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len,
732 m->m_len += (lenthisone & ~3);
734 insb(BASE + EP_W1_RX_PIO_RD_1,
735 mtod(m, caddr_t) + m->m_len,
737 m->m_len += (lenthisone & 3);
739 insw(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len,
741 m->m_len += lenthisone;
743 *(mtod(m, caddr_t) + m->m_len - 1) = inb(BASE + EP_W1_RX_PIO_RD_1);
745 rx_fifo -= lenthisone;
748 if (status & ERR_RX_INCOMPLETE) { /* we haven't received the complete
751 #ifdef EP_LOCAL_STATS
752 sc->rx_no_first++; /* to know how often we come here */
754 EP_FRST(sc, F_RX_FIRST);
755 if (!((status = inw(BASE + EP_W1_RX_STATUS)) & ERR_RX_INCOMPLETE)) {
756 /* we see if by now, the packet has completly arrived */
759 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_NEXT_EARLY_THRESH);
762 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
764 EP_FSET(sc, F_RX_FIRST);
765 top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
766 top->m_pkthdr.len = sc->cur_len;
768 eh = mtod(top, struct ether_header *);
769 m_adj(top, sizeof(struct ether_header));
770 ether_input(ifp, eh, top);
772 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
773 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
777 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
781 #ifdef EP_LOCAL_STATS
785 EP_FSET(sc, F_RX_FIRST);
786 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
787 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
794 struct ep_softc * sc = ifp->if_softc;
798 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
800 outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP);
803 switch (IFM_SUBTYPE(sc->ifmedia.ifm_media)) {
805 if (sc->ep_connectors & UTP) {
806 i = ACF_CONNECTOR_UTP;
808 outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP);
812 if (sc->ep_connectors & BNC) {
813 i = ACF_CONNECTOR_BNC;
814 outw(BASE + EP_COMMAND, START_TRANSCEIVER);
815 DELAY(DELAY_MULTIPLE * 1000);
819 if (sc->ep_connectors & AUI)
820 i = ACF_CONNECTOR_AUI;
823 i = sc->ep_connector;
824 device_printf(sc->dev,
825 "strange connector type in EEPROM: assuming AUI\n");
829 j = inw(BASE + EP_W0_ADDRESS_CFG) & 0x3fff;
830 outw(BASE + EP_W0_ADDRESS_CFG, j | (i << ACF_CONNECTOR_BITS));
836 ep_ifmedia_sts(ifp, ifmr)
838 struct ifmediareq * ifmr;
840 struct ep_softc * sc = ifp->if_softc;
842 ifmr->ifm_active = sc->ifmedia.ifm_media;
848 ep_if_ioctl(ifp, cmd, data)
853 struct ep_softc * sc = ifp->if_softc;
854 struct ifreq * ifr = (struct ifreq *)data;
863 error = ether_ioctl(ifp, cmd, data);
867 if (((ifp->if_flags & IFF_UP) == 0) &&
868 (ifp->if_flags & IFF_RUNNING)) {
869 ifp->if_flags &= ~IFF_RUNNING;
872 /* reinitialize card on any parameter change */
878 bcopy((caddr_t) sc->sc_addr, (caddr_t) & ifr->ifr_data,
879 sizeof(sc->sc_addr));
885 * The Etherlink III has no programmable multicast
886 * filter. We always initialize the card to be
887 * promiscuous to multicast, since we're always a
888 * member of the ALL-SYSTEMS group, so there's no
889 * need to process SIOC*MULTI requests.
895 if (!sc->epb.mii_trans) {
896 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
915 struct ep_softc *sc = ifp->if_softc;
918 printf("ep: watchdog\n");
920 log(LOG_ERR, "ep%d: watchdog\n", ifp->if_unit);
928 ifp->if_flags &= ~IFF_OACTIVE;
930 ep_intr(ifp->if_softc);
941 outw(BASE + EP_COMMAND, RX_DISABLE);
942 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
943 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
945 outw(BASE + EP_COMMAND, TX_DISABLE);
946 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
949 outw(BASE + EP_COMMAND, RX_RESET);
950 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
951 outw(BASE + EP_COMMAND, TX_RESET);
952 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
954 outw(BASE + EP_COMMAND, C_INTR_LATCH);
955 outw(BASE + EP_COMMAND, SET_RD_0_MASK);
956 outw(BASE + EP_COMMAND, SET_INTR_MASK);
957 outw(BASE + EP_COMMAND, SET_RX_FILTER);