Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src netdock* - ethernet driver for Asante NetDock/Newer Ether Mi...
details: https://anonhg.NetBSD.org/src/rev/8dfe92604868
branches: trunk
changeset: 533012:8dfe92604868
user: itojun <itojun%NetBSD.org@localhost>
date: Wed Jun 19 01:54:26 2002 +0000
description:
netdock* - ethernet driver for Asante NetDock/Newer Ether MicroDock.
by Daishi Kato <daishi%axlight.com@localhost>
test/stabilization by Takeo Kuwata <tkuwata%virus.kyoto-u.ac.jp@localhost>
diffstat:
distrib/notes/mac68k/legal | 4 +-
sys/arch/mac68k/conf/GENERIC | 5 +-
sys/arch/mac68k/conf/files.mac68k | 6 +-
sys/arch/mac68k/nubus/if_netdock_nubus.c | 875 +++++++++++++++++++++++++++++++
4 files changed, 886 insertions(+), 4 deletions(-)
diffs (truncated from 940 to 300 lines):
diff -r 168287802bed -r 8dfe92604868 distrib/notes/mac68k/legal
--- a/distrib/notes/mac68k/legal Wed Jun 19 00:17:11 2002 +0000
+++ b/distrib/notes/mac68k/legal Wed Jun 19 01:54:26 2002 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: legal,v 1.11 2002/05/20 23:48:46 itojun Exp $
+.\" $NetBSD: legal,v 1.12 2002/06/19 01:54:26 itojun Exp $
.
.It
This product includes software developed by the Alice Group.
@@ -14,3 +14,5 @@
This product includes software developed by John P. Wittkoski.
.It
This product includes software developed by Colin Wood.
+.It
+This product includes software developed by Daishi Kato.
diff -r 168287802bed -r 8dfe92604868 sys/arch/mac68k/conf/GENERIC
--- a/sys/arch/mac68k/conf/GENERIC Wed Jun 19 00:17:11 2002 +0000
+++ b/sys/arch/mac68k/conf/GENERIC Wed Jun 19 01:54:26 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.127 2002/06/17 05:14:15 lukem Exp $
+# $NetBSD: GENERIC,v 1.128 2002/06/19 01:54:27 itojun Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.127 $"
+#ident "GENERIC-$Revision: 1.128 $"
maxusers 16 # estimated number of users
@@ -254,6 +254,7 @@
ae* at nubus? # DP8390-based
sn* at nubus? # SONIC-based (DP83932, DP83916)
sm* at nubus? # SMC 91cxx-based
+netdock* at nubus? # Asante NetDock, Newer Ether MicroDock
nsphy* at mii? phy ?
ukphy* at mii? phy ?
diff -r 168287802bed -r 8dfe92604868 sys/arch/mac68k/conf/files.mac68k
--- a/sys/arch/mac68k/conf/files.mac68k Wed Jun 19 00:17:11 2002 +0000
+++ b/sys/arch/mac68k/conf/files.mac68k Wed Jun 19 01:54:26 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.mac68k,v 1.105 2002/04/27 19:29:08 shiba Exp $
+# $NetBSD: files.mac68k,v 1.106 2002/06/19 01:54:28 itojun Exp $
# mac68k-specific configuration info
@@ -93,6 +93,10 @@
attach sm at nubus with sm_nubus
file arch/mac68k/nubus/if_sm_nubus.c sm_nubus
+device netdock: ifnet, ether, arp
+attach netdock at nubus with netdock_nubus
+file arch/mac68k/nubus/if_netdock_nubus.c netdock_nubus
+
# Sony floppy disk controller
device iwm { drive = -1 }
attach iwm at obio_norm
diff -r 168287802bed -r 8dfe92604868 sys/arch/mac68k/nubus/if_netdock_nubus.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mac68k/nubus/if_netdock_nubus.c Wed Jun 19 01:54:26 2002 +0000
@@ -0,0 +1,875 @@
+/* $NetBSD: if_netdock_nubus.c,v 1.1 2002/06/19 01:54:28 itojun Exp $ */
+
+/*
+ * Copyright (C) 2000,2002 Daishi Kato <daishi%axlight.com@localhost>
+ * All rights reserved.
+ *
+ * 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 Daishi Kato
+ * 4. The name of the author 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 ``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 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.
+ */
+
+/*
+ * Asante NetDock (for Duo series) driver
+ * the chip inside is not known
+ */
+
+/*
+ * The author would like to thank Takeo Kuwata <tkuwata%mac.com@localhost> for
+ * his help in stabilizing this driver.
+ */
+
+/***********************/
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <sys/ioctl.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_ether.h>
+
+#include "opt_inet.h"
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/if_inarp.h>
+#endif
+
+#include "bpfilter.h"
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#endif
+
+#include <machine/bus.h>
+#include <machine/viareg.h>
+#include <mac68k/nubus/nubus.h>
+
+/***********************/
+
+#define NETDOCK_DEBUG
+
+#define NETDOCK_NUBUS_CATEGORY 0x0020
+#define NETDOCK_NUBUS_TYPE 0x0003
+#define NETDOCK_NUBUS_DRSW 0x0103
+#define NETDOCK_NUBUS_DRHW 0x0100
+
+#define ETHERMICRODOCK_NUBUS_CATEGORY 0x0020
+#define ETHERMICRODOCK_NUBUS_TYPE 0x0003
+#define ETHERMICRODOCK_NUBUS_DRSW 0x0102
+#define ETHERMICRODOCK_NUBUS_DRHW 0x0100
+
+#define REG_ISR 0x000c
+#define REG_000E 0x000e
+#define REG_0000 0x0000
+#define REG_0002 0x0002
+#define REG_0004 0x0004
+#define REG_0006 0x0006
+#define REG_DATA 0x0008
+#define REG_EFD00 0xefd00
+
+#define ISR_ALL 0x3300
+#define ISR_TX 0x0200
+#define ISR_RX 0x0100
+#define ISR_READY 0x0800
+#define ISR_BIT_0C 0x1000
+#define ISR_BIT_0D 0x2000
+#define ISR_MASK 0x0033
+#define ISR_BIT_03 0x0008
+
+#define REG_0002_BIT_04 0x0010
+#define REG_0000_BIT_08 0x0100
+#define REG_0004_BIT_0F 0x8000
+#define REG_0004_BIT_07 0x0080
+#define REG_DATA_BIT_02 0x0004
+#define REG_DATA_BIT_03 0x0008
+#define REG_DATA_BIT_04 0x0010
+#define REG_DATA_BIT_05 0x0020
+#define REG_DATA_BIT_08 0x0100
+#define REG_DATA_BIT_07 0x0080
+#define REG_DATA_BIT_0F 0x8000
+
+/***********************/
+
+typedef struct netdock_softc {
+ struct device sc_dev;
+ struct ethercom sc_ethercom;
+#define sc_if sc_ethercom.ec_if
+
+ bus_space_tag_t sc_regt;
+ bus_space_handle_t sc_regh;
+
+ u_int8_t sc_enaddr[ETHER_ADDR_LEN];
+
+} netdock_softc_t;
+
+/***********************/
+
+static int netdock_nubus_match __P((struct device *, struct cfdata *,
+ void*));
+static void netdock_nubus_attach __P((struct device *, struct device *,
+ void *));
+static int netdock_nb_get_enaddr __P((bus_space_tag_t, bus_space_handle_t,
+ struct nubus_attach_args *, u_int8_t *));
+#ifdef NETDOCK_DEBUG_DRIVER
+static void netdock_print_driver __P((bus_space_tag_t, bus_space_handle_t,
+ struct nubus_attach_args *));
+#endif
+
+int netdock_setup __P((struct netdock_softc *, u_int8_t *));
+void netdock_intr __P((void *));
+
+static void netdock_watchdog __P((struct ifnet *));
+static int netdock_init __P((struct netdock_softc *));
+static int netdock_stop __P((struct netdock_softc *));
+static int netdock_ioctl __P((struct ifnet *, u_long, caddr_t));
+static void netdock_start __P((struct ifnet *));
+static void netdock_reset __P((struct netdock_softc *));
+static void netdock_txint __P((struct netdock_softc *));
+static void netdock_rxint __P((struct netdock_softc *));
+
+static u_int netdock_put __P((struct netdock_softc *, struct mbuf *));
+static int netdock_read __P((struct netdock_softc *, int));
+static struct mbuf *netdock_get __P((struct netdock_softc *, int));
+
+/***********************/
+
+#define NIC_GET_1(sc, o) (bus_space_read_1((sc)->sc_regt, \
+ (sc)->sc_regh, (o)))
+#define NIC_PUT_1(sc, o, val) (bus_space_write_1((sc)->sc_regt, \
+ (sc)->sc_regh, (o), (val)))
+#define NIC_GET_2(sc, o) (bus_space_read_2((sc)->sc_regt, \
+ (sc)->sc_regh, (o)))
+#define NIC_PUT_2(sc, o, val) (bus_space_write_2((sc)->sc_regt, \
+ (sc)->sc_regh, (o), (val)))
+#define NIC_GET_4(sc, o) (bus_space_read_4((sc)->sc_regt, \
+ (sc)->sc_regh, (o)))
+#define NIC_PUT_4(sc, o, val) (bus_space_write_4((sc)->sc_regt, \
+ (sc)->sc_regh, (o), (val)))
+
+#define NIC_BSET(sc, o, b) \
+ __asm__ __volatile("bset %0,%1" : : "di" ((u_short)(b)), \
+ "g" (*(u_int8_t *)((sc)->sc_regh.base + (o))))
+#define NIC_BCLR(sc, o, b) \
+ __asm__ __volatile("bclr %0,%1" : : "di" ((u_short)(b)), \
+ "g" (*(u_int8_t *)((sc)->sc_regh.base + (o))))
+#define NIC_ANDW(sc, o, b) \
+ __asm__ __volatile("andw %0,%1" : : "di" ((u_short)(b)), \
+ "g" (*(u_int8_t *)((sc)->sc_regh.base + (o))))
+#define NIC_ORW(sc, o, b) \
+ __asm__ __volatile("orw %0,%1" : : "di" ((u_short)(b)), \
+ "g" (*(u_int8_t *)((sc)->sc_regh.base + (o))))
+
+
+/***********************/
+
+struct cfattach netdock_nubus_ca = {
+ sizeof(struct netdock_softc), netdock_nubus_match, netdock_nubus_attach
+};
+
+/***********************/
+
+static int
+netdock_nubus_match(parent, cf, aux)
+ struct device *parent;
+ struct cfdata *cf;
+ void *aux;
+{
+ struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
+ bus_space_handle_t bsh;
+ int rv;
+
+ if (bus_space_map(na->na_tag, NUBUS_SLOT2PA(na->slot),
+ NBMEMSIZE, 0, &bsh))
+ return (0);
+
+ rv = 0;
+
+ if (na->category == NETDOCK_NUBUS_CATEGORY &&
+ na->type == NETDOCK_NUBUS_TYPE &&
+ na->drsw == NETDOCK_NUBUS_DRSW) {
+ /* assuming this IS Asante NetDock */
+ rv = 1;
+ }
+
+ if (na->category == ETHERMICRODOCK_NUBUS_CATEGORY &&
+ na->type == ETHERMICRODOCK_NUBUS_TYPE &&
+ na->drsw == ETHERMICRODOCK_NUBUS_DRSW) {
+ /* assuming this IS Newer EtherMicroDock */
+ rv = 1;
+ }
+
+ bus_space_unmap(na->na_tag, bsh, NBMEMSIZE);
+
+ return rv;
+}
+
+static void
+netdock_nubus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct netdock_softc *sc = (struct netdock_softc *)self;
Home |
Main Index |
Thread Index |
Old Index