NetBSD Problem Report #17493
Received: (qmail 16989 invoked by uid 605); 6 Jul 2002 16:39:29 -0000
Message-Id: <200207061636.g66GaL400697@power.cnet.aladdin.de>
Date: Sat, 6 Jul 2002 18:36:21 +0200 (CEST)
From: cpg@aladdin.de
Sender: gnats-bugs-owner@netbsd.org
Reply-To: cpg@aladdin.de
To: gnats-bugs@gnats.netbsd.org
Subject: driver for Sega LAN Adapter
X-Send-Pr-Version: 3.95
>Number: 17493
>Category: port-dreamcast
>Synopsis: driver for Sega LAN Adapter
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: tsutsui
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat Jul 06 16:40:00 +0000 2002
>Closed-Date: Fri Dec 27 16:56:36 +0000 2002
>Last-Modified: Fri Dec 27 16:56:36 +0000 2002
>Originator: Christian Groessler
>Release: NetBSD 1.6_BETA3
>Organization:
>Environment:
>Description:
This is a driver for the Sega LAN Adapter. In order for it to
work, kern/17193 needs to be applied, too.
The sys/dev/isa/if_fmv.c driver was used as a blueprint.
>How-To-Repeat:
Try to use the Lan Adapter. Notice that it isn't supported by
NetBSD.
>Fix:
diff -ruN orig/sys/arch/dreamcast/conf/DREAMS.LANA new/sys/arch/dreamcast/conf/DREAMS.LANA
--- orig/sys/arch/dreamcast/conf/DREAMS.LANA Thu Jan 1 01:00:00 1970
+++ new/sys/arch/dreamcast/conf/DREAMS.LANA Tue Jul 2 22:01:51 2002
@@ -0,0 +1,155 @@
+# $Id$
+#
+
+include "arch/dreamcast/conf/std.dreamcast"
+
+options DONT_INIT_BSC
+
+# wscons options
+options WSEMUL_VT100 # VT100 / VT220 emulation
+options FONT_BOLD8x16
+
+maxusers 16 # estimated number of users
+
+# CPU support
+options DREAMCAST
+options EVBSH4
+
+#options LED_ADDR=0xa8000000
+options PIPE_SOCKETPAIR
+
+# Standard system options
+#options UCONSOLE # users can use TIOCCONS (for xconsole)
+#options INSECURE # disable kernel security levels
+
+#options RTC_OFFSET=-540
+options HZ=100 # clock interrupt generates every 1/HZ sec
+#options NTP # NTP phase/frequency locked loop
+
+#options KTRACE # system call tracing via ktrace(1)
+
+#options SYSVMSG # System V-like message queues
+#options SYSVSEM # System V-like semaphores
+#options SEMMNI=10 # number of semaphore identifiers
+#options SEMMNS=60 # number of semaphores in system
+#options SEMUME=10 # max number of undo entries per process
+#options SEMMNU=30 # number of undo structures in system
+#options SYSVSHM # System V-like memory sharing
+#options SHMMAXPGS=1024 # 1024 pages is the default
+
+# Diagnostic/debugging support options
+options DIAGNOSTIC # cheap kernel consistency checks
+options DEBUG # expensive debugging checks/support
+options DDB # in-kernel debugger
+#makeoptions DEBUG="-g" # compile full symbol table
+#options SYSCALL_DEBUG
+#options UVMHIST
+#options UVMHIST_PRINT
+
+# Compatibility options
+#options COMPAT_13 # NetBSD 1.3
+#options COMPAT_14 # NetBSD 1.4,
+#options COMPAT_43 # and 4.3BSD
+
+# Executable format options
+options EXEC_COFF # COFF executables
+options EXEC_ELF32 # 32-bit ELF executables
+
+# File systems
+#file-system FFS # UFS
+#file-system MFS # memory file system
+file-system NFS # Network File System client
+file-system PROCFS # /proc
+file-system KERNFS # /kern
+#file-system NULLFS # loopback file system
+#file-system UMAPFS # NULLFS + uid and gid remapping
+file-system CD9660 # CD-ROM file system
+
+#options NFS_RSIZE=1024
+#options NFS_WSIZE=1024
+
+# File system options
+#options QUOTA # UFS quotas
+#options NFSSERVER # Network File System server
+
+# Networking options
+options INET # IP + ICMP + TCP + UDP
+options NFS_BOOT_DHCP # Support DHCP NFS root
+
+#options PCIVERBOSE # verbose PCI device autoconfig messages
+#options PCI_CONFIG_DUMP # verbosely dump PCI config space
+#options PCMCIAVERBOSE # verbose PCMCIA configuration messages
+
+# Kernel root file system and dump configuration.
+config netbsd root on ? type nfs
+#config netbsd root on wd0a type ffs
+#config netbsd root on ? type ?
+#config netbsd root on rtk0 type nfs
+#config netbsd root on lana0 type nfs
+
+#
+# Device configuration
+#
+
+mainbus0 at root
+
+shb* at mainbus?
+
+# Serial Devices
+options SCIFCN_SPEED=57600
+scif0 at shb? #port 0xffe80000 irq 12
+
+pvr0 at shb?
+wsdisplay* at pvr? console ?
+
+maple0 at shb?
+mkbd* at maple? port ? subunit ?
+wskbd* at mkbd? console ?
+
+gdrom0 at shb?
+
+g2bus0 at shb?
+gapspci* at g2bus? # GAPS PCI bridge
+pci* at gapspci?
+rtk* at pci? dev ? function ? # SEGA Broadband Adapter
+ukphy* at mii? phy ?
+
+lana0 at g2bus? # SEGA Lan Adapter
+options FE_DEBUG=2
+options LANA_DEBUG=1
+#options FE_SINGLE_TRANSMISSION
+
+# SH PCMCIA controllers
+#shpcic0 at shb? port 0xb000000a iomem 0xb8000000 iosiz 0x1000000
+#shpcic1 at shb? port 0xb000000c iomem 0xb9000000 iosiz 0x1000000
+
+# PCMCIA bus support
+#pcmcia* at shpcic? controller ? socket ?
+
+#com* at pcmcia? function ? # Modems and serial cards
+#wdc* at pcmcia? function ?
+#wd* at wdc? drive ? # the drives themselves
+
+#ep* at pcmcia? function ? # 3Com 3c589 and 3c562 Ethernet
+#mbe* at pcmcia? function ? # MB8696x based Ethernet
+#ne* at pcmcia? function ? # NE2000-compatible Ethernet
+#sm* at pcmcia? function ? # Megahertz Ethernet
+
+#pseudo-device vnd 4 # disk-like interface to files
+#pseudo-device bpfilter 8 # Berkeley packet filter
+#pseudo-device bridge # simple inter-network bridging
+#pseudo-device ipfilter # IP filter (firewall) and NAT
+pseudo-device loop # network loopback
+pseudo-device pty # pseudo-terminals
+#pseudo-device ppp 2 # Point-to-Point Protocol
+#pseudo-device pppoe # PPP over Ethernet (RFC 2516)
+#pseudo-device tun 2 # network tunneling over tty
+pseudo-device rnd # /dev/random and in-kernel generator
+
+# Enable the hooks used for initializing the root memory-disk.
+#options MEMORY_DISK_HOOKS
+#options MEMORY_DISK_IS_ROOT # force root on memory disk
+#options MEMORY_DISK_SERVER=0 # no userspace memory disk support
+#options MINIROOTSIZE=3074 # size of memory disk, in blocks
+
+#pseudo-device md 1 # memory disk device (ramdisk)
diff -ruN orig/sys/arch/dreamcast/conf/files.dreamcast new/sys/arch/dreamcast/conf/files.dreamcast
--- orig/sys/arch/dreamcast/conf/files.dreamcast Tue Apr 16 22:50:19 2002
+++ new/sys/arch/dreamcast/conf/files.dreamcast Sat Jun 22 00:32:12 2002
@@ -88,3 +88,7 @@
file arch/dreamcast/dev/g2/gapspci.c gapspci
file arch/dreamcast/dev/g2/gapspci_dma.c gapspci
file arch/dreamcast/dev/g2/gapspci_pci.c gapspci
+
+device lana: arp, ether, ifnet, mb86960
+attach lana at g2bus
+file arch/dreamcast/dev/g2/lan_adapter.c lana
diff -ruN orig/sys/arch/dreamcast/dev/g2/lan_adapter.c new/sys/arch/dreamcast/dev/g2/lan_adapter.c
--- orig/sys/arch/dreamcast/dev/g2/lan_adapter.c Thu Jan 1 01:00:00 1970
+++ new/sys/arch/dreamcast/dev/g2/lan_adapter.c Sat Jul 6 18:23:48 2002
@@ -0,0 +1,390 @@
+/* $NetBSD$ */
+
+/*
+ * 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.
+ */
+
+/*
+ * Portions copyright (C) 2002, Christian Groessler. 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$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/socket.h>
+#include <sys/syslog.h>
+
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+#include <machine/sysasicvar.h>
+#include <machine/cpu.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <dev/ic/mb86960reg.h>
+#include <dev/ic/mb86960var.h>
+#include <dev/ic/ate_subr.c> /* needed for FE_xxx defines */
+
+#include <dreamcast/dev/g2/g2busvar.h>
+
+
+int lana_match __P((struct device *, struct cfdata *, void *));
+void lana_attach __P((struct device *, struct device *, void *));
+
+struct lana_softc {
+ struct mb86960_softc sc_mb86960; /* real "mb86960" softc */
+};
+
+struct cfattach lana_ca = {
+ sizeof(struct lana_softc), lana_match, lana_attach
+};
+
+#define LANA_NPORTS (0x20 * 4)
+
+static int lanafound;
+static struct dreamcast_bus_space lana_bs;
+
+static int lana_detect __P((bus_space_tag_t, bus_space_handle_t,
+ u_int8_t enaddr[ETHER_ADDR_LEN]));
+
+
+/*
+ * pointers to some overridden g2bus functions
+ */
+
+static u_int8_t
+(*g2bus_mem_read_1_p)(void *tag,
+ bus_space_handle_t sh,
+ bus_size_t off);
+
+static void
+(*g2bus_mem_write_1_p)(void *tag,
+ bus_space_handle_t sh,
+ bus_size_t off,
+ u_int8_t val);
+
+/*
+ * Prototypes of the lan adapter replacement bus space functions.
+ * There are only those functions replaced which are used by the
+ * mb86960.c driver.
+ */
+
+u_int8_t
+lana_bus_mem_read_1(void *tag,
+ bus_space_handle_t sh,
+ bus_size_t off);
+
+void
+lana_bus_mem_write_1(void *tag,
+ bus_space_handle_t sh,
+ bus_size_t off,
+ u_int8_t val);
+
+void
+lana_bus_space_read_multi_1(bus_space_tag_t tag,
+ bus_space_handle_t bsh,
+ bus_size_t offset,
+ u_int8_t *addr,
+ bus_size_t count);
+
+void
+lana_bus_space_write_multi_1(bus_space_tag_t tag,
+ bus_space_handle_t bsh,
+ bus_size_t offset,
+ u_int8_t *addr,
+ bus_size_t count);
+
+
+void
+lana_bus_mem_write_region_1(void *tag,
+ bus_space_handle_t sh,
+ bus_size_t off,
+ const u_int8_t *addr,
+ bus_size_t len);
+
+
+/*
+ * bus space functions
+ */
+u_int8_t
+lana_bus_mem_read_1(void *tag,
+ bus_space_handle_t sh,
+ bus_size_t off)
+{
+ return g2bus_mem_read_1_p(tag, sh, off * 4);
+}
+
+void
+lana_bus_mem_write_1(void *tag,
+ bus_space_handle_t sh,
+ bus_size_t off,
+ u_int8_t val)
+{
+ g2bus_mem_write_1_p(tag, sh, off * 4, val);
+}
+
+void
+lana_bus_mem_write_region_1(void *tag,
+ bus_space_handle_t sh,
+ bus_size_t off,
+ const u_int8_t *addr,
+ bus_size_t len)
+{
+ off *= 4;
+ while (len--) {
+ lana_bus_mem_write_1(tag, sh, off, *addr);
+ addr++;
+ off += 4;
+ }
+}
+
+void
+lana_bus_space_write_multi_1(bus_space_tag_t tag,
+ bus_space_handle_t bsh,
+ bus_size_t offset,
+ u_int8_t *addr, bus_size_t count)
+{
+ while (count--)
+ lana_bus_mem_write_1(tag, bsh, offset, *addr++);
+}
+
+void
+lana_bus_space_read_multi_1(bus_space_tag_t tag,
+ bus_space_handle_t bsh,
+ bus_size_t offset,
+ u_int8_t *addr,
+ bus_size_t count)
+{
+ while (count--)
+ *addr++ = lana_bus_mem_read_1(tag, bsh, offset);
+}
+
+
+/*
+ * Determine if the device is present.
+ */
+int
+lana_match(struct device *parent, struct cfdata *cf, void *aux)
+
+{
+ struct g2bus_attach_args *ga = aux;
+ bus_space_handle_t memh;
+ struct dreamcast_bus_space b;
+ bus_space_tag_t memt = &b;
+ u_int8_t myea[ETHER_ADDR_LEN];
+
+ if (lanafound)
+ return (0);
+
+ if (strcmp("lana", cf->cf_driver->cd_name))
+ return (0);
+
+ memcpy(memt, ga->ga_memt, sizeof(struct dreamcast_bus_space));
+
+ /* Map i/o ports. */
+ if (bus_space_map(memt, 0x00600400, LANA_NPORTS, 0, &memh)) {
+#ifdef LANA_DEBUG
+ printf("lana_match: couldn't map iospace 0x%x\n",
+ 0x00600400);
+#endif
+ return (0);
+ }
+
+ /* remember original g2bus functions */
+ g2bus_mem_read_1_p = memt->dbs_r_1;
+ g2bus_mem_write_1_p = memt->dbs_w_1;
+
+ /* override some bus functions */
+ memt->dbs_r_1 = lana_bus_mem_read_1;
+ memt->dbs_w_1 = lana_bus_mem_write_1;
+ memt->dbs_wr_1 = lana_bus_mem_write_region_1;
+ memt->dbs_wm_1 = (void *)lana_bus_space_write_multi_1;
+ memt->dbs_rm_1 = (void *)lana_bus_space_read_multi_1;
+
+ if (lana_detect(memt, memh, myea) == 0) {
+ bus_space_unmap(memt, memh, LANA_NPORTS);
+#ifdef LANA_DEBUG
+ printf("lana_match: lana_detect failed\n");
+#endif
+ return(0);
+ }
+
+ bus_space_unmap(memt, memh, LANA_NPORTS);
+ lanafound = 1;
+ return (1);
+}
+
+
+/*
+ * Determine type and ethernet address.
+ */
+static int
+lana_detect(iot, ioh, enaddr)
+ bus_space_tag_t iot;
+ bus_space_handle_t ioh;
+ u_int8_t enaddr[ETHER_ADDR_LEN];
+{
+ u_char eeprom[FE_EEPROM_SIZE];
+
+ memset(eeprom, 0, FE_EEPROM_SIZE);
+
+ /* Get our station address from EEPROM. */
+ ate_read_eeprom(iot, ioh, eeprom);
+ memcpy(enaddr, eeprom, ETHER_ADDR_LEN);
+
+#if LANA_DEBUG > 1
+ {
+ int i;
+ printf("Ethernet address: ");
+ for (i=0; i<ETHER_ADDR_LEN; i++) {
+ if (i) printf(":");
+ printf("%02x", eeprom[i]);
+ }
+ printf("\n");
+ }
+#endif
+
+ /* Make sure we got a valid station address. */
+ if ((enaddr[0] & 0x03) != 0x00 ||
+ (enaddr[0] == 0x00 && enaddr[1] == 0x00 && enaddr[2] == 0x00)) {
+#ifdef LANA_DEBUG
+ printf("lana_detect: invalid ethernet address\n");
+#endif
+ return (0);
+ }
+
+ /* Read the chip type */
+ if (((bus_space_read_1(iot, ioh, 7) >> 6) & 3) != 2) {
+#ifdef LANA_DEBUG
+ printf("lana_detect: unknown chip type\n");
+#endif
+ return(0);
+ }
+
+ return (2);
+}
+
+void
+lana_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct g2bus_attach_args *ga = aux;
+ struct lana_softc *isc = (struct lana_softc *)self;
+ struct mb86960_softc *sc = &isc->sc_mb86960;
+ bus_space_handle_t memh;
+ bus_space_tag_t memt = &lana_bs;
+ const char *typestr;
+ u_int8_t myea[ETHER_ADDR_LEN];
+ int type;
+
+ memcpy(memt, ga->ga_memt, sizeof(struct dreamcast_bus_space));
+
+ /* Map i/o ports. */
+ if (bus_space_map(memt, 0x00600400, LANA_NPORTS, 0, &memh)) {
+ panic("\n%s: can't map i/o space\n", sc->sc_dev.dv_xname);
+ }
+
+ /* remember original g2bus functions */
+ g2bus_mem_read_1_p = memt->dbs_r_1;
+ g2bus_mem_write_1_p = memt->dbs_w_1;
+
+ /* override some bus functions */
+ memt->dbs_r_1 = lana_bus_mem_read_1;
+ memt->dbs_w_1 = lana_bus_mem_write_1;
+ memt->dbs_wr_1 = lana_bus_mem_write_region_1;
+ memt->dbs_wm_1 = (void *)lana_bus_space_write_multi_1;
+ memt->dbs_rm_1 = (void *)lana_bus_space_read_multi_1;
+
+ sc->sc_bst = memt;
+ sc->sc_bsh = memh;
+
+ /* Determine the card type. */
+ type = lana_detect(memt, memh, myea);
+ switch (type) {
+ case 2:
+ typestr = "Sega LAN-Adapter";
+ break;
+ default:
+ /* Unknown card type: maybe a new model, but... */
+ printf("\n%s: where did the card go?!\n", sc->sc_dev.dv_xname);
+ panic("unknown card");
+ }
+
+ printf("\n%s: %s Ethernet\n", sc->sc_dev.dv_xname, typestr);
+
+ /* This interface is always enabled. */
+ sc->sc_flags |= FE_FLAGS_ENABLED;
+
+ /* Override driver default settings for the controller. */
+ sc->sc_dev.dv_cfdata->cf_flags = FE_FLAGS_OVERRIDE_DLCR6 |
+ FE_D6_BUFSIZ_32KB | /*FE_D6_TXBSIZ_2x2KB | */ FE_D6_TXBSIZ_2x4KB |
+ FE_D6_BBW_BYTE | FE_D6_SBW_BYTE | FE_D6_SRAM_150ns;
+
+ /*
+ * 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(memt, memh, FE_FMV3, 0);
+ bus_space_write_1(memt, memh, 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(memt, memh, FE_FMV3, FE_FMV3_ENABLE_FLAG);
+
+ mb86960_config(sc, NULL, 0, 0);
+
+ sysasic_intr_establish(SYSASIC_EVENT_8BIT, mb86960_intr, sc);
+}
diff -ruN orig/sys/arch/dreamcast/dreamcast/sysasic.c new/sys/arch/dreamcast/dreamcast/sysasic.c
--- orig/sys/arch/dreamcast/dreamcast/sysasic.c Sun Mar 24 19:21:10 2002
+++ new/sys/arch/dreamcast/dreamcast/sysasic.c Sat Jun 8 01:21:27 2002
@@ -73,6 +73,7 @@
*/
switch (event) {
case SYSASIC_EVENT_EXT:
+ case SYSASIC_EVENT_8BIT:
idx = SYSASIC_IRQ_LEVEL_11;
ipl = IPL_NET;
evtcode = SH_INTEVT_IRL11;
diff -ruN orig/sys/arch/dreamcast/include/sysasicvar.h new/sys/arch/dreamcast/include/sysasicvar.h
--- orig/sys/arch/dreamcast/include/sysasicvar.h Sun Mar 24 19:21:09 2002
+++ new/sys/arch/dreamcast/include/sysasicvar.h Fri Jun 7 23:33:48 2002
@@ -41,6 +41,7 @@
#define SYSASIC_EVENT_GDROM 32
#define SYSASIC_EVENT_AICA 33
+#define SYSASIC_EVENT_8BIT 34
#define SYSASIC_EVENT_EXT 35
#define SYSASIC_EVENT_MAX 63
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: tsutsui
State-Changed-When: Fri Dec 27 08:54:55 PST 2002
State-Changed-Why:
The driver has been integrated.
Responsible-Changed-From-To: port-dreamcast-maintainer->tsutsui
Responsible-Changed-By: tsutsui
Responsible-Changed-When: Fri Dec 27 08:54:55 PST 2002
Responsible-Changed-Why:
I've committed the driver.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.