Source-Changes-HG archive

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

[src/trunk]: src/sys Add driver for SKNET Personal and MC+ - AMD Lance 7990 b...



details:   https://anonhg.NetBSD.org/src/rev/e58ce35fefd8
branches:  trunk
changeset: 509150:e58ce35fefd8
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Apr 27 18:03:40 2001 +0000

description:
Add driver for SKNET Personal and MC+ - AMD Lance 7990 based ethernet cards.
Both models tested and seem to be quite stable and fast.

Thanks to:
- Hans Hubner <hans%Huebner.org@localhost> for giving me the cards for testing
- Georg Klug of Syskonnect, who provided me with hw docs for these cards,
  very promptly and willingly - I wish all vendors would be like this
- Alfred Arnold, Linux SKNET driver author, for giving me valuable Syskonnect
  contact :)

diffstat:

 sys/arch/i386/conf/PS2  |    3 +-
 sys/dev/mca/files.mca   |    4 +-
 sys/dev/mca/if_le_mca.c |  379 ++++++++++++++++++++++++++++++++++++++++++++++++
 sys/dev/mca/if_lereg.h  |   59 +++++++
 sys/dev/mca/mca_subr.c  |    7 +-
 sys/dev/mca/mcadevs     |    6 +-
 6 files changed, 451 insertions(+), 7 deletions(-)

diffs (truncated from 526 to 300 lines):

diff -r 360079135f4e -r e58ce35fefd8 sys/arch/i386/conf/PS2
--- a/sys/arch/i386/conf/PS2    Fri Apr 27 17:52:51 2001 +0000
+++ b/sys/arch/i386/conf/PS2    Fri Apr 27 18:03:40 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: PS2,v 1.21 2001/04/23 05:45:43 jdolecek Exp $
+#      $NetBSD: PS2,v 1.22 2001/04/27 18:03:40 jdolecek Exp $
 #
 #      Sample kernel config for PS/2 with MCA bus
 #
@@ -110,6 +110,7 @@
 ate*   at mca? slot ?                  # Allied Telesis AT1720
 ne*    at mca? slot ?                  # Novell NE/2 and clones
 tr*    at mca? slot ?                  # IBM Token Ring adapter
+le*    at mca? slot ?                  # SKNET Personal/MC2+
 
 # MCA ESDI controllers & disks
 edc*   at mca? slot ?                  # IBM ESDI Disk Controllers
diff -r 360079135f4e -r e58ce35fefd8 sys/dev/mca/files.mca
--- a/sys/dev/mca/files.mca     Fri Apr 27 17:52:51 2001 +0000
+++ b/sys/dev/mca/files.mca     Fri Apr 27 18:03:40 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.mca,v 1.12 2001/04/23 06:10:08 jdolecek Exp $
+# $NetBSD: files.mca,v 1.13 2001/04/27 18:03:40 jdolecek Exp $
 #
 # Config.new file and device description for machine-independent MCA code.
 # Included by ports that need it.
@@ -54,5 +54,5 @@
 file   dev/mca/if_ne_mca.c             ne_mca
 
 # AMD am7990 (Lance) -based boards
-attach le at mca with le_mca
+attach le at mca with le_mca: le24
 file   dev/mca/if_le_mca.c             le_mca
diff -r 360079135f4e -r e58ce35fefd8 sys/dev/mca/if_le_mca.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/mca/if_le_mca.c   Fri Apr 27 18:03:40 2001 +0000
@@ -0,0 +1,379 @@
+/*     $NetBSD: if_le_mca.c,v 1.1 2001/04/27 18:03:41 jdolecek Exp $   */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jaromir Dolecek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Driver for SKNET Personal and MC2+ cards, which are AMD Lance 7990 based
+ * cards made by Syskonnect, former Schneider & Koch Datensysteme GmbH.
+ *
+ * Syskonnect was very helpful and provided docs for these cards promptly.
+ * I wish all vendors would be like that!
+ * I'd like to thank to Alfred Arnold, author of the Linux driver, for
+ * giving me contact to The Right Syskonnect person, too :-)
+ * 
+ * Sources:
+ * SKNET MC+ Technical Manual, version 1.1, July 21 1993
+ * SKNET personal Technisches Manual, version 1.2, April 14 1988
+ * SKNET junior Technisches Manual, version 1.0, July 14 1987
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <sys/syslog.h>
+#include <sys/socket.h>
+#include <sys/device.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#include <machine/cpu.h>
+#include <machine/intr.h>
+#include <machine/bus.h>
+
+#include <dev/ic/lancereg.h>
+#include <dev/ic/lancevar.h>
+#include <dev/ic/am7990reg.h>
+#include <dev/ic/am7990var.h>
+
+#include <dev/mca/mcareg.h>
+#include <dev/mca/mcavar.h>
+#include <dev/mca/mcadevs.h>
+
+#include <dev/mca/if_lereg.h>
+
+int    le_mca_match __P((struct device *, struct cfdata *, void *));
+void   le_mca_attach __P((struct device *, struct device *, void *));
+
+struct le_mca_softc {
+       struct  am7990_softc sc_am7990; /* glue to MI code */
+
+       void    *sc_ih;
+       bus_space_tag_t sc_memt;
+       bus_space_handle_t sc_memh;
+};
+
+static void le_mca_wrcsr __P((struct lance_softc *, u_int16_t, u_int16_t));
+static u_int16_t le_mca_rdcsr __P((struct lance_softc *, u_int16_t));  
+static void le_mca_hwreset __P((struct lance_softc *));
+static int le_mca_intredge __P((void *));
+
+static void    le_mca_copytobuf(struct lance_softc *, void *, int, int);
+static void    le_mca_copyfrombuf(struct lance_softc *, void *, int, int);
+static void    le_mca_zerobuf(struct lance_softc *, int, int);
+
+static __inline void le_mca_wrreg __P((struct le_mca_softc *, int, int));
+#define le_mca_set_RAP(sc, reg_number) \
+               le_mca_wrreg(sc, reg_number, RAP | REGWRITE)
+
+struct cfattach le_mca_ca = {
+       sizeof(struct le_mca_softc), le_mca_match, le_mca_attach
+};
+
+/* SKNET MC+ POS mapping */
+static const u_int8_t sknet_mcp_irq[] = {
+       3, 5, 10, 11
+};
+static const u_int8_t sknet_mcp_media[] = {
+       IFM_ETHER|IFM_10_2,
+       IFM_ETHER|IFM_10_T,
+       IFM_ETHER|IFM_10_5,
+       0
+};
+
+int
+le_mca_match(struct device *parent, struct cfdata *cf, void *aux)
+{
+       struct mca_attach_args *ma = aux;
+
+       switch(ma->ma_id) {
+       case MCA_PRODUCT_SKNETPER:
+       case MCA_PRODUCT_SKNETG:
+               return (1);
+       }
+
+       return (0);
+}
+
+void
+le_mca_attach(struct device *parent, struct device *self, void *aux)
+{
+       struct le_mca_softc *lesc = (struct le_mca_softc *) self;
+       struct lance_softc *sc = &lesc->sc_am7990.lsc;
+       struct mca_attach_args *ma = aux;
+       int i, pos2, pos3, pos4, irq, membase, supmedia=0;
+       const char *typestr;
+
+       /*
+        * SKNET Personal:
+        *
+        * POS register 2: (adf pos0)
+        * 
+        * 7 6 5 4 3 2 1 0
+        *       | \___/ \__ enable: 0=adapter disabled, 1=adapter enabled
+        *        \    \____ Memory: 0xC0000-0xC3FFF + XX*0x4000
+        *         \________ IRQ: 0=10 1=11
+        *
+        *
+        * SKNET MC+:
+        * POS register 2: (adf pos0)
+        * 
+        * 7 6 5 4 3 2 1 0
+        *       \___/ \ \__ enable: 0=adapter disabled, 1=adapter enabled
+        *           \  \___ BootEPROM disable
+        *            \_____ BootEPROM start address: 0xC0000 + XX*0x4000
+        *
+        * POS register 3: (adf pos1)
+        * 
+        * 7 6 5 4 3 2 1 0
+        * 0 0 1 1 \_____/
+        *               \__ RAM: 0xC0000 + XX*0x4000
+        *
+        * POS register 4: (adf pos2)
+        * 
+        * 7 6 5 4 3 2 1 0
+        * \_/     \_/ \_/
+        *   \       \   \__ Need to be reset to 0 0 after boot
+        *    \       \_____ IRQ: 00=3 01=5 10=10 11=11
+        *     \____________ Medium: 00=BNC 01=UTP 10=AUI 11=not allowed
+        */ 
+
+       switch (ma->ma_id) {
+       case MCA_PRODUCT_SKNETPER:
+               typestr = "Personal MC2";
+
+               pos2 = mca_conf_read(ma->ma_mc, ma->ma_slot, 2);
+               irq = (pos2 & (1<<4)) ? 11 : 10;
+               membase = 0xc0000 + ((pos2 & 0x0e) >> 1) * 0x4000;
+               break;
+       case MCA_PRODUCT_SKNETG:
+               typestr = "MC2+";
+
+               /*
+                * SKNET MC+ needs the driver to clear 0, 1 bits of pos4
+                * and explicitly set the enable bit. Somebody at Syskonnect
+                * was obviously misguided when the card was designed ...
+                */
+               pos3 = mca_conf_read(ma->ma_mc, ma->ma_slot, 3);
+               pos4 = mca_conf_read(ma->ma_mc, ma->ma_slot, 4);
+               if ((pos4 & 0x03) != 0) {
+                       /* clear the bits 0, 1 */
+                       mca_conf_write(ma->ma_mc, ma->ma_slot, 4,
+                               pos4 & ~0x03);
+               }
+
+               pos2 = mca_conf_read(ma->ma_mc, ma->ma_slot, 2);
+               if ((pos2 & 0x01) == 0) {
+                       /* enable the card */
+                       mca_conf_write(ma->ma_mc, ma->ma_slot, 2, pos2 | 0x01);
+               }
+
+               /* get irq and memory base */
+               irq = sknet_mcp_irq[(pos4 & 0x0c) >> 2];
+               membase = 0xc0000 + ((pos3 & 0x0f) * 0x4000);
+
+               /* Get configured media type */
+               supmedia = sknet_mcp_media[(pos4 & 0xc0) >> 6];
+               break;
+       }
+
+       lesc->sc_memt = ma->ma_memt;
+
+       if (bus_space_map(lesc->sc_memt, membase, LE_MCA_MEMSIZE,
+               0, &lesc->sc_memh)) {
+               printf(": can't map memory\n", sc->sc_dev.dv_xname);
+               return;
+       }
+
+       printf(" slot %d irq %d: SKNET %s Ethernet\n",
+               ma->ma_slot + 1, irq, typestr);
+
+       /*
+        * Extract the physical MAC address from the ROM.
+        */
+       for (i = 0; i < ETHER_ADDR_LEN; i++)
+               sc->sc_enaddr[i] = bus_space_read_1(lesc->sc_memt,
+                               lesc->sc_memh, LE_PROMOFF + i*2);
+
+       sc->sc_conf3 = LE_C3_ACON;
+       sc->sc_addr = 0;
+       sc->sc_memsize = LE_MCA_RAMSIZE;
+
+       sc->sc_copytodesc = le_mca_copytobuf;
+       sc->sc_copyfromdesc = le_mca_copyfrombuf;
+       sc->sc_copytobuf = le_mca_copytobuf;
+       sc->sc_copyfrombuf = le_mca_copyfrombuf;
+       sc->sc_zerobuf = le_mca_zerobuf;
+
+       sc->sc_rdcsr = le_mca_rdcsr;
+       sc->sc_wrcsr = le_mca_wrcsr;
+       sc->sc_hwinit = NULL;
+
+       sc->sc_hwreset = le_mca_hwreset;
+
+       /*
+        * This is merely cosmetic since it's not possible to switch
+        * the media anyway, even for MC2+.
+        */
+       if (supmedia != 0) {
+               sc->sc_supmedia = &supmedia;
+               sc->sc_nsupmedia = 1;
+               sc->sc_defaultmedia = supmedia;
+       }
+
+       lesc->sc_ih = mca_intr_establish(ma->ma_mc, irq, IPL_NET,
+                       le_mca_intredge, sc);
+       if (lesc->sc_ih == NULL) {



Home | Main Index | Thread Index | Old Index