Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/sys/dev/ic Pull up revisions 1.59-1.63, 1.65 (requested ...



details:   https://anonhg.NetBSD.org/src/rev/6d4a8226cfc1
branches:  netbsd-1-4
changeset: 470292:6d4a8226cfc1
user:      he <he%NetBSD.org@localhost>
date:      Sun Feb 06 17:39:39 2000 +0000

description:
Pull up revisions 1.59-1.63,1.65 (requested by enami):
  Add support for the 3Com 3c574.  Partially based on PR#8331.

diffstat:

 sys/dev/ic/elink3.c |  168 +++++++++++++++++++++++++++++++++++----------------
 1 files changed, 116 insertions(+), 52 deletions(-)

diffs (truncated from 388 to 300 lines):

diff -r ec6f123a9422 -r 6d4a8226cfc1 sys/dev/ic/elink3.c
--- a/sys/dev/ic/elink3.c       Sun Feb 06 17:30:01 2000 +0000
+++ b/sys/dev/ic/elink3.c       Sun Feb 06 17:39:39 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elink3.c,v 1.54.2.1 1999/04/27 00:04:51 perry Exp $    */
+/*     $NetBSD: elink3.c,v 1.54.2.2 2000/02/06 17:39:39 he Exp $       */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -202,17 +202,18 @@
 
 static void eptxstat __P((struct ep_softc *));
 static int epstatus __P((struct ep_softc *));
-void epinit __P((struct ep_softc *));
-int epioctl __P((struct ifnet *, u_long, caddr_t));
-void epstart __P((struct ifnet *));
-void epwatchdog __P((struct ifnet *));
-void epreset __P((struct ep_softc *));
+void   epinit __P((struct ep_softc *));
+int    epioctl __P((struct ifnet *, u_long, caddr_t));
+void   epstart __P((struct ifnet *));
+void   epwatchdog __P((struct ifnet *));
+void   epreset __P((struct ep_softc *));
 static void epshutdown __P((void *));
 void   epread __P((struct ep_softc *));
 struct mbuf *epget __P((struct ep_softc *, int));
 void   epmbuffill __P((void *));
 void   epmbufempty __P((struct ep_softc *));
 void   epsetfilter __P((struct ep_softc *));
+void   ep_roadrunner_mii_enable __P((struct ep_softc *));
 void   epsetmedia __P((struct ep_softc *));
 
 /* ifmedia callbacks */
@@ -233,6 +234,7 @@
 void   ep_mii_sendbits __P((struct ep_softc *, u_int32_t, int));
 
 static int epbusyeeprom __P((struct ep_softc *));
+u_int16_t ep_read_eeprom __P((struct ep_softc *, u_int16_t));
 static inline void ep_reset_cmd __P((struct ep_softc *sc, 
                                        u_int cmd, u_int arg));
 static inline void ep_finish_reset __P((bus_space_tag_t, bus_space_handle_t));
@@ -275,12 +277,12 @@
 ep_finish_reset(iot, ioh)
        bus_space_tag_t iot;
        bus_space_handle_t ioh;
-
 {
        int i;
 
        for (i = 0; i < 10000; i++) {
-               if ((bus_space_read_2(iot, ioh, ELINK_STATUS) & S_COMMAND_IN_PROGRESS) == 0)
+               if ((bus_space_read_2(iot, ioh, ELINK_STATUS) &
+                   S_COMMAND_IN_PROGRESS) == 0)
                        break;
                DELAY(10);
        }
@@ -319,7 +321,8 @@
         * is about right.
         */
        for (i = 0; i < 8000; i++) {
-               if  ((bus_space_read_2(iot, ioh, ELINK_STATUS) & S_COMMAND_IN_PROGRESS) == 0)
+               if ((bus_space_read_2(iot, ioh, ELINK_STATUS) &
+                   S_COMMAND_IN_PROGRESS) == 0)
                    return;
        }
 
@@ -353,17 +356,10 @@
 
        if (enaddr == NULL) {
                /*
-                * Read the station address from the eeprom
+                * Read the station address from the eeprom.
                 */
                for (i = 0; i < 3; i++) {
-                       u_int16_t x;
-                       if (epbusyeeprom(sc))
-                               return;         /* XXX why is eeprom busy? */
-                       bus_space_write_2(iot, ioh, ELINK_W0_EEPROM_COMMAND,
-                                         READ_EEPROM | i);
-                       if (epbusyeeprom(sc))
-                               return;         /* XXX why is eeprom busy? */
-                       x = bus_space_read_2(iot, ioh, ELINK_W0_EEPROM_DATA);
+                       u_int16_t x = ep_read_eeprom(sc, i);
                        myla[(i << 1)] = x >> 8;
                        myla[(i << 1) + 1] = x;
                }
@@ -383,7 +379,7 @@
         * threshold value was shifted or not.
         */
        bus_space_write_2(iot, ioh, ELINK_COMMAND,
-                         SET_TX_AVAIL_THRESH | ELINK_LARGEWIN_PROBE ); 
+           SET_TX_AVAIL_THRESH | ELINK_LARGEWIN_PROBE); 
        GO_WINDOW(5);
        i = bus_space_read_2(iot, ioh, ELINK_W5_TX_AVAIL_THRESH);
        GO_WINDOW(1);
@@ -459,8 +455,14 @@
         * Now, determine which media we have.
         */
        switch (sc->ep_chipset) {
+       case ELINK_CHIPSET_ROADRUNNER:
+               if (sc->ep_flags & ELINK_FLAGS_MII) {
+                       ep_roadrunner_mii_enable(sc);
+                       GO_WINDOW(0);
+               }
+               /* FALLTHROUGH */
+
        case ELINK_CHIPSET_BOOMERANG:
-       case ELINK_CHIPSET_ROADRUNNER:
                /*
                 * If the device has MII, probe it.  We won't be using
                 * any `native' media in this case, only PHYs.  If
@@ -493,13 +495,12 @@
        GO_WINDOW(1);           /* Window 1 is operating window */
 
 #if NBPFILTER > 0
-       bpfattach(&sc->sc_ethercom.ec_if.if_bpf, ifp, DLT_EN10MB,
-                 sizeof(struct ether_header));
+       bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
 #endif
 
 #if NRND > 0
        rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
-                         RND_TYPE_NET, 0);
+           RND_TYPE_NET, 0);
 #endif
 
        sc->tx_start_thresh = 20;       /* probably a good starting point. */
@@ -536,7 +537,8 @@
 
        GO_WINDOW(3);
        config0 = (u_int)bus_space_read_2(iot, ioh, ELINK_W3_INTERNAL_CONFIG);
-       config1 = (u_int)bus_space_read_2(iot, ioh, ELINK_W3_INTERNAL_CONFIG + 2);
+       config1 = (u_int)bus_space_read_2(iot, ioh,
+           ELINK_W3_INTERNAL_CONFIG + 2);
        GO_WINDOW(0);
 
        ram_size  = (config0 & CONFIG_RAMSIZE) >> CONFIG_RAMSIZE_SHIFT;
@@ -591,13 +593,7 @@
        /*
         * Get the default media from the EEPROM.
         */
-       if (epbusyeeprom(sc))
-               return;         /* XXX why is eeprom busy? */
-       bus_space_write_2(iot, ioh, ELINK_W0_EEPROM_COMMAND,
-           READ_EEPROM | EEPROM_ADDR_CFG);
-       if (epbusyeeprom(sc))
-               return;         /* XXX why is  eeprom busy? */
-       port = bus_space_read_2(iot, ioh, ELINK_W0_EEPROM_DATA) >> 14;
+       port = ep_read_eeprom(sc, EEPROM_ADDR_CFG) >> 14;
 
 #define        PRINT(s)        printf("%s%s", sep, s); sep = ", "
 
@@ -649,7 +645,8 @@
        const char *sep = "", *defmedianame = NULL;
 
        GO_WINDOW(3);
-       config1 = (u_int)bus_space_read_2(iot, ioh, ELINK_W3_INTERNAL_CONFIG + 2);
+       config1 = (u_int)bus_space_read_2(iot, ioh,
+           ELINK_W3_INTERNAL_CONFIG + 2);
        reset_options = (int)bus_space_read_1(iot, ioh, ELINK_W3_RESET_OPTIONS);
        GO_WINDOW(0);
 
@@ -742,11 +739,16 @@
        /* Make sure any pending reset has completed before touching board. */
        ep_finish_reset(iot, ioh);
 
+       /*
+        * Cance any pending I/O.
+        */
+       epstop(sc);
 
        if (sc->bustype != ELINK_BUS_PCI) {
                GO_WINDOW(0);
                bus_space_write_2(iot, ioh, ELINK_W0_CONFIG_CTRL, 0);
-               bus_space_write_2(iot, ioh, ELINK_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ);
+               bus_space_write_2(iot, ioh, ELINK_W0_CONFIG_CTRL,
+                   ENABLE_DRQ_IRQ);
        }
 
        if (sc->bustype == ELINK_BUS_PCMCIA) {
@@ -796,13 +798,20 @@
 
                bus_space_write_2(iot, ioh, ELINK_W1_RUNNER_WRCTL, 0);
                bus_space_write_2(iot, ioh, ELINK_W1_RUNNER_RDCTL, 0);
+
+               if (sc->ep_flags & ELINK_FLAGS_MII) {
+                       ep_roadrunner_mii_enable(sc);
+                       GO_WINDOW(1);
+               }
        }
 
        /* Enable interrupts. */
-       bus_space_write_2(iot, ioh, ELINK_COMMAND, SET_RD_0_MASK | S_CARD_FAILURE |
-                               S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
-       bus_space_write_2(iot, ioh, ELINK_COMMAND, SET_INTR_MASK | S_CARD_FAILURE |
-                               S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
+       bus_space_write_2(iot, ioh, ELINK_COMMAND,
+           SET_RD_0_MASK | S_CARD_FAILURE | S_RX_COMPLETE | S_TX_COMPLETE |
+           S_TX_AVAIL);
+       bus_space_write_2(iot, ioh, ELINK_COMMAND,
+           SET_INTR_MASK | S_CARD_FAILURE | S_RX_COMPLETE | S_TX_COMPLETE |
+           S_TX_AVAIL);
 
        /*
         * Attempt to get rid of any stray interrupts that occured during
@@ -846,10 +855,10 @@
        register struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 
        GO_WINDOW(1);           /* Window 1 is operating window */
-       bus_space_write_2(sc->sc_iot, sc->sc_ioh, ELINK_COMMAND, SET_RX_FILTER |
-           FIL_INDIVIDUAL | FIL_BRDCST |
-           ((ifp->if_flags & IFF_MULTICAST) ? FIL_MULTICAST : 0 ) |
-           ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 ));
+       bus_space_write_2(sc->sc_iot, sc->sc_ioh, ELINK_COMMAND,
+           SET_RX_FILTER | FIL_INDIVIDUAL | FIL_BRDCST |
+           ((ifp->if_flags & IFF_MULTICAST) ? FIL_MULTICAST : 0) |
+           ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0));
 }
 
 int
@@ -865,6 +874,30 @@
 }
 
 /*
+ * Reset and enable the MII on the RoadRunner.
+ */
+void
+ep_roadrunner_mii_enable(sc)
+       struct ep_softc *sc;
+{
+       bus_space_tag_t iot = sc->sc_iot;
+       bus_space_handle_t ioh = sc->sc_ioh;
+
+       GO_WINDOW(3);
+       bus_space_write_2(iot, ioh, ELINK_W3_RESET_OPTIONS,
+           ELINK_PCI_100BASE_MII|ELINK_RUNNER_ENABLE_MII);
+       delay(1000);
+       bus_space_write_2(iot, ioh, ELINK_W3_RESET_OPTIONS,
+           ELINK_PCI_100BASE_MII|ELINK_RUNNER_MII_RESET|
+           ELINK_RUNNER_ENABLE_MII);
+       ep_reset_cmd(sc, ELINK_COMMAND, TX_RESET);
+       ep_reset_cmd(sc, ELINK_COMMAND, RX_RESET);
+       delay(1000);
+       bus_space_write_2(iot, ioh, ELINK_W3_RESET_OPTIONS,
+           ELINK_PCI_100BASE_MII|ELINK_RUNNER_ENABLE_MII);
+}
+
+/*
  * Set the card to use the specified media.
  */
 void
@@ -891,14 +924,16 @@
 
                GO_WINDOW(3);
 
+#if 0
                if (sc->ep_chipset == ELINK_CHIPSET_ROADRUNNER) {
                        int resopt;
 
                        resopt = bus_space_read_2(iot, ioh,
                            ELINK_W3_RESET_OPTIONS);
-                       bus_space_write_2(iot, ioh,
-                           ELINK_W3_RESET_OPTIONS, resopt|ELINK_RUNNER_ENABLE_MII);
+                       bus_space_write_2(iot, ioh, ELINK_W3_RESET_OPTIONS,
+                           resopt | ELINK_RUNNER_ENABLE_MII);
                }
+#endif
 
                config0 = (u_int)bus_space_read_2(iot, ioh,
                    ELINK_W3_INTERNAL_CONFIG);
@@ -909,7 +944,8 @@
                config1 |= (ELINKMEDIA_MII << CONFIG_MEDIAMASK_SHIFT);
 
                bus_space_write_2(iot, ioh, ELINK_W3_INTERNAL_CONFIG, config0);
-               bus_space_write_2(iot, ioh, ELINK_W3_INTERNAL_CONFIG + 2, config1);
+               bus_space_write_2(iot, ioh, ELINK_W3_INTERNAL_CONFIG + 2,
+                   config1);
                GO_WINDOW(1);   /* back to operating window */
 
                mii_mediachg(&sc->sc_mii);
@@ -1115,7 +1151,7 @@
                return;
        } else {
                bus_space_write_2(iot, ioh, ELINK_COMMAND,
-                   SET_TX_AVAIL_THRESH | ELINK_THRESH_DISABLE );
+                   SET_TX_AVAIL_THRESH | ELINK_THRESH_DISABLE);
        }
 
        IF_DEQUEUE(&ifp->if_snd, m0);
@@ -1123,7 +1159,7 @@
                return;
 
        bus_space_write_2(iot, ioh, ELINK_COMMAND, SET_TX_START_THRESH |
-           ((len / 4 + sc->tx_start_thresh) /* >> sc->ep_pktlenshift*/) );
+           ((len / 4 + sc->tx_start_thresh) /* >> sc->ep_pktlenshift*/));
 
 #if NBPFILTER > 0
        if (ifp->if_bpf)
@@ -1153,7 +1189,7 @@
        bus_space_write_2(iot, ioh, txreg, len);



Home | Main Index | Thread Index | Old Index