Source-Changes-HG archive

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

[src/trunk]: src/sys Overhaul of fmv(4) driver:



details:   https://anonhg.NetBSD.org/src/rev/47134a2ded5f
branches:  trunk
changeset: 537749:47134a2ded5f
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Oct 05 15:16:10 2002 +0000

description:
Overhaul of fmv(4) driver:
- Split if_fmv.c into MI/MD part and add ISA-PnP attachment for FMV-183.
  (XXX FMV-184 is not tested. It would require extra media-select functions..)
- Fix probe functions of fmv_isa so that FMV-181A/182A will also match.
  Fixes port-i386/9476.

diffstat:

 sys/conf/files                 |    7 +-
 sys/dev/ic/fmv.c               |  173 ++++++++++++++++++
 sys/dev/ic/fmvreg.h            |   87 +++++++++
 sys/dev/ic/fmvvar.h            |   35 +++
 sys/dev/ic/mb86960var.h        |    6 +-
 sys/dev/isa/files.isa          |    8 +-
 sys/dev/isa/if_fmv.c           |  391 -----------------------------------------
 sys/dev/isa/if_fmv_isa.c       |  306 ++++++++++++++++++++++++++++++++
 sys/dev/isa/if_fmvreg.h        |   83 --------
 sys/dev/isapnp/files.isapnp    |    6 +-
 sys/dev/isapnp/if_fmv_isapnp.c |  114 +++++++++++
 11 files changed, 735 insertions(+), 481 deletions(-)

diffs (truncated from 1301 to 300 lines):

diff -r fd70106f4bcc -r 47134a2ded5f sys/conf/files
--- a/sys/conf/files    Sat Oct 05 15:04:49 2002 +0000
+++ b/sys/conf/files    Sat Oct 05 15:16:10 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.556 2002/10/04 23:04:53 elric Exp $
+#      $NetBSD: files,v 1.557 2002/10/05 15:16:10 tsutsui Exp $
 
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
@@ -749,6 +749,11 @@
 #
 device ate: arp, ether, ifnet, mb86960
 
+# Fujitsu FMV-18x Ethernet driver based on Fujitsu MB8696xA controllers
+#
+device fmv: arp, ether, ifnet, mb86960
+file   dev/ic/fmv.c                    fmv
+
 # Crystal Semiconductor CS8900, CS8920, and CS8920M Ethernet
 #
 device cs: arp, ether, ifnet
diff -r fd70106f4bcc -r 47134a2ded5f sys/dev/ic/fmv.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/fmv.c  Sat Oct 05 15:16:10 2002 +0000
@@ -0,0 +1,173 @@
+/*     $NetBSD: fmv.c,v 1.1 2002/10/05 15:16:11 tsutsui Exp $  */
+
+/*
+ * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
+ *
+ * This software may be used, modified, copied, distributed, and sold, in
+ * both source and binary form provided that the above copyright, these
+ * terms and the following disclaimer are retained.  The name of the author
+ * and/or the contributor may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``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 AUTHOR OR THE CONTRIBUTOR 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.
+ */
+
+/*
+ * Portions copyright (C) 1993, David Greenman.  This software may be used,
+ * modified, copied, distributed, and sold, in both source and binary form
+ * provided that the above copyright and these terms are retained.  Under no
+ * circumstances is the author responsible for the proper functioning of this
+ * software, nor does the author assume any responsibility for damages
+ * incurred with its use.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: fmv.c,v 1.1 2002/10/05 15:16:11 tsutsui Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#include <machine/bus.h>
+
+#include <dev/ic/mb86960reg.h>
+#include <dev/ic/mb86960var.h>
+#include <dev/ic/fmvreg.h>
+#include <dev/ic/fmvvar.h>
+
+/*
+ * Determine type and ethernet address.
+ */
+int
+fmv_detect(iot, ioh, enaddr)
+       bus_space_tag_t iot;
+       bus_space_handle_t ioh;
+       u_int8_t *enaddr;
+{
+       int model, id, type;
+
+       /* Get our station address from EEPROM. */
+       bus_space_read_region_1(iot, ioh, FE_FMV4, enaddr, ETHER_ADDR_LEN);
+
+       /* Make sure we got a valid station address. */
+       if ((enaddr[0] & 0x03) != 0x00 ||
+           (enaddr[0] == 0x00 && enaddr[1] == 0x00 && enaddr[2] == 0x00)) {
+#ifdef FMV_DEBUG
+               printf("fmv_detect: invalid ethernet address\n");
+#endif
+               return (0);
+       }
+
+       /* Determine the card type. */
+       model = bus_space_read_1(iot, ioh, FE_FMV0) & FE_FMV0_MODEL;
+       id    = bus_space_read_1(iot, ioh, FE_FMV1) & FE_FMV1_CARDID_REV;
+       
+       switch (model) {
+       case FE_FMV0_MODEL_FMV181:
+               type = FE_TYPE_FMV181;
+               if (id == FE_FMV1_CARDID_REV_A)
+                       type = FE_TYPE_FMV181A;
+               break;
+       case FE_FMV0_MODEL_FMV182:
+               type = FE_TYPE_FMV182;
+               if (id == FE_FMV1_CARDID_REV_A)
+                       type = FE_TYPE_FMV182A;
+               else if (id == FE_FMV1_CARDID_PNP)
+                       type = FE_TYPE_FMV184;
+               break;
+       case FE_FMV0_MODEL_FMV183:
+               type = FE_TYPE_FMV183;
+               break;
+       default:
+               type = 0;
+#ifdef FMV_DEBUG
+               printf("fmv_detect: unknown card\n");
+#endif
+               break;
+       }
+
+       return (type);
+}
+
+void
+fmv_attach(sc)
+       struct mb86960_softc *sc;
+{
+       bus_space_tag_t iot;
+       bus_space_handle_t ioh;
+       const char *typestr;
+       int type;
+       u_int8_t myea[ETHER_ADDR_LEN];
+
+       iot = sc->sc_bst;
+       ioh = sc->sc_bsh;
+
+       /* Determine the card type. */
+       type = fmv_detect(iot, ioh, myea);
+       switch (type) {
+       case FE_TYPE_FMV181:
+               typestr = "FMV-181";
+               break;
+       case FE_TYPE_FMV181A:
+               typestr = "FMV-181A";
+               break;
+       case FE_TYPE_FMV182:
+               typestr = "FMV-182";
+               break;
+       case FE_TYPE_FMV182A:
+               typestr = "FMV-182A";
+               break;
+       case FE_TYPE_FMV183:
+               typestr = "FMV-183";
+               break;
+       case FE_TYPE_FMV184:
+               typestr = "FMV-184";
+               break;
+       default:
+               /* Unknown card type: maybe a new model, but... */
+               panic("%s: unknown FMV-18x card", sc->sc_dev.dv_xname);
+       }
+
+       printf("%s: %s Ethernet\n", sc->sc_dev.dv_xname, typestr);
+
+       /* This interface is always enabled. */
+       sc->sc_flags |= FE_FLAGS_ENABLED;
+
+       /*
+        * Minimum initialization of the hardware.
+        * We write into registers; hope I/O ports have no
+        * overlap with other boards.
+        */
+
+       /* Initialize ASIC. */
+       bus_space_write_1(iot, ioh, FE_FMV3, 0);
+       bus_space_write_1(iot, ioh, FE_FMV10, 0);
+
+       /* Wait for a while.  I'm not sure this is necessary.  FIXME */
+       delay(200);
+
+       /*
+        * Do generic MB86960 attach.
+        */
+       mb86960_attach(sc, MB86960_TYPE_86965, myea);
+
+       /* Is this really needs to be done here? XXX */
+       /* Turn the "master interrupt control" flag of ASIC on. */
+       bus_space_write_1(iot, ioh, FE_FMV3, FE_FMV3_ENABLE_FLAG);
+
+       mb86960_config(sc, NULL, 0, 0);
+}
diff -r fd70106f4bcc -r 47134a2ded5f sys/dev/ic/fmvreg.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/fmvreg.h       Sat Oct 05 15:16:10 2002 +0000
@@ -0,0 +1,87 @@
+/*     $NetBSD: fmvreg.h,v 1.1 2002/10/05 15:16:11 tsutsui Exp $       */
+
+/*
+ * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
+ *
+ * This software may be used, modified, copied, distributed, and sold,
+ * in both source and binary form provided that the above copyright,
+ * these terms and the following disclaimer are retained.  The name of
+ * the author and/or the contributor may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``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 AUTHOR OR THE CONTRIBUTOR 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.
+ */
+
+/*
+ * Hardware specification of various 86960/86965 based Ethernet cards.
+ * Contributed by M.S. <seki%sysrap.cs.fujitsu.co.jp@localhost>
+ */
+
+/*
+ * Registers on FMV-180 series' ISA bus interface ASIC.
+ * I'm not sure the following register names are appropriate.
+ * Doesn't it look silly, eh?  FIXME.
+ */
+
+#define FE_FMV0                16      /* Hardware status.             */
+#define FE_FMV1                17      /* Hardrare type?  Always 0     */
+#define FE_FMV2                18      /* Hardware configuration.      */
+#define FE_FMV3                19      /* Hardware enable.             */
+#define FE_FMV4                20      /* Station address #1           */
+#define FE_FMV5                21      /* Station address #2           */
+#define FE_FMV6                22      /* Station address #3           */
+#define FE_FMV7                23      /* Station address #4           */
+#define FE_FMV8                24      /* Station address #5           */
+#define FE_FMV9                25      /* Station address #6           */
+#define FE_FMV10       26      /* Unknown; to be set to 0.     */
+
+/*
+ * FMV-180 series' ASIC register values.
+ */
+
+/* Magic value in FMV0 register.  */
+#define FE_FMV0_MAGIC_MASK     0x78
+#define FE_FMV0_MAGIC_VALUE    0x50
+
+/* Model identification.  */
+#define FE_FMV0_MODEL          0x07
+#define FE_FMV0_MODEL_FMV181   0x05    /* FMV-181/181A         */
+#define FE_FMV0_MODEL_FMV182   0x03    /* FMV-182/182A/184     */
+#define FE_FMV0_MODEL_FMV183   0x04    /* FMV-183              */
+
+/* Card type ID */
+#define FE_FMV1_MAGIC_MASK     0xB0
+#define FE_FMV1_MAGIC_VALUE    0x00
+#define FE_FMV1_CARDID_REV     0x0F
+#define FE_FMV1_CARDID_REV_A   0x01    /* FMV-181A/182A        */
+#define FE_FMV1_CARDID_PNP     0x08    /* FMV-183/184          */
+
+/* I/O port address assignment.  */
+#define FE_FMV2_ADDR           0x07
+#define FE_FMV2_ADDR_SHIFT     0
+
+/* Boot ROM address assignment.  */
+#define FE_FMV2_ROM            0x38
+#define FE_FMV2_ROM_SHIFT      3
+
+/* IRQ assignment.  */
+#define FE_FMV2_IRQ            0xC0
+#define FE_FMV2_IRQ_SHIFT      6
+
+/* Hardware(?) enable flag.  */
+#define FE_FMV3_ENABLE_FLAG    0x80
+
+/* Extra bits in FMV3 register.  Always 0?  */
+#define FE_FMV3_EXTRA_MASK     0x7F
+#define FE_FMV3_EXTRA_VALUE    0x00
diff -r fd70106f4bcc -r 47134a2ded5f sys/dev/ic/fmvvar.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/fmvvar.h       Sat Oct 05 15:16:10 2002 +0000
@@ -0,0 +1,35 @@
+/*     $NetBSD: fmvvar.h,v 1.1 2002/10/05 15:16:12 tsutsui Exp $       */
+
+/*
+ * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
+ *
+ * This software may be used, modified, copied, distributed, and sold, in
+ * both source and binary form provided that the above copyright, these



Home | Main Index | Thread Index | Old Index