Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/atari Add support for the SMC Elite Ultra Ethernet ...



details:   https://anonhg.NetBSD.org/src/rev/b7cdbd5fa95f
branches:  trunk
changeset: 752980:b7cdbd5fa95f
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Mar 13 16:30:02 2010 +0000

description:
Add support for the SMC Elite Ultra Ethernet with the SMC_TT VME-ISA bridge.

The SMC_TT is the user designed "handmade" VME-ISA bridge circuit
for 16 bit VME slot on TT030 and the SMC Elite Ultra ISA Ethernet card.
More information about SMC_TT can be found in the following archive:
ftp://ftp.funet.fi/pub/atari/net/smc_tt1.zip

Demonstrated on the NetBSD booth in Open Source Conference 2010 Kansai@Kobe.

diffstat:

 sys/arch/atari/conf/GENERIC.in  |    3 +-
 sys/arch/atari/conf/files.atari |    6 +-
 sys/arch/atari/vme/if_we_vme.c  |  423 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 430 insertions(+), 2 deletions(-)

diffs (truncated from 466 to 300 lines):

diff -r 355d62094a7f -r b7cdbd5fa95f sys/arch/atari/conf/GENERIC.in
--- a/sys/arch/atari/conf/GENERIC.in    Sat Mar 13 16:28:13 2010 +0000
+++ b/sys/arch/atari/conf/GENERIC.in    Sat Mar 13 16:30:02 2010 +0000
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: GENERIC.in,v 1.83 2010/02/21 17:57:03 tsutsui Exp $
+#      $NetBSD: GENERIC.in,v 1.84 2010/03/13 16:30:02 tsutsui Exp $
 #
 # Generic atari
 #
@@ -355,6 +355,7 @@
 vme0           at avmebus0
 le0            at vme0 irq 5   # Lance ethernet (Riebl/PAM).
 le0            at vme0 irq 4   # Lance ethernet (BVME410).
+we0            at vme0 irq 4   # SMC Elite Ultra with SMC_TT VME-ISA bridge
 et0            at vme0         # Crazy Dots II
 #endif /* TT030_KERNEL */
 #endif /* SMALL030_KERNEL */
diff -r 355d62094a7f -r b7cdbd5fa95f sys/arch/atari/conf/files.atari
--- a/sys/arch/atari/conf/files.atari   Sat Mar 13 16:28:13 2010 +0000
+++ b/sys/arch/atari/conf/files.atari   Sat Mar 13 16:30:02 2010 +0000
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: files.atari,v 1.115 2009/12/06 06:46:26 tsutsui Exp $
+#      $NetBSD: files.atari,v 1.116 2010/03/13 16:30:03 tsutsui Exp $
 
 maxpartitions 16
 
@@ -91,6 +91,10 @@
 attach le at vme with le_vme: le24
 file   arch/atari/vme/if_le_vme.c      le_vme
 
+# SMC Elite Ultra (8216) with SMC_TT VME-ISA bridge
+attach we at vme with we_vme
+file   arch/atari/vme/if_we_vme.c      we_vme
+
 # Circad Leonardo 24-bit true color video
 device leo
 attach leo at vme
diff -r 355d62094a7f -r b7cdbd5fa95f sys/arch/atari/vme/if_we_vme.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/atari/vme/if_we_vme.c    Sat Mar 13 16:30:02 2010 +0000
@@ -0,0 +1,423 @@
+/*     $NetBSD: if_we_vme.c,v 1.1 2010/03/13 16:30:03 tsutsui Exp $    */
+
+/*-
+ * Copyright (c) 1997, 1998, 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
+ * adapters.
+ *
+ * Copyright (c) 1994, 1995 Charles M. Hannum.  All rights reserved.
+ *
+ * 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.
+ */
+
+/*
+ * Device driver for the SMC Elite Ultra (8216) with SMC_TT VME-ISA bridge.
+ * Based on:
+ *     NetBSD: if_we_isa.c,v 1.20 2008/04/28 20:23:52 martin Exp
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_we_vme.c,v 1.1 2010/03/13 16:30:03 tsutsui Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/socket.h>
+#include <sys/mbuf.h>
+#include <sys/syslog.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#include <net/if_media.h>
+
+#include <net/if_ether.h>
+
+#include <sys/bus.h>
+#include <sys/intr.h>
+
+#include <machine/cpu.h>
+#include <machine/iomap.h>
+#include <machine/scu.h>
+
+#include <atari/vme/vmevar.h>
+
+#include <dev/ic/dp8390reg.h>
+#include <dev/ic/dp8390var.h>
+#include <dev/ic/wereg.h>
+#include <dev/ic/wevar.h>
+
+/* #define WE_DEBUG */
+#ifdef WE_DEBUG
+#define DPRINTF(x)     printf x
+#else
+#define DPRINTF(x)     /**/
+#endif
+
+/* VME space mapped by SMC_TT VME-ISA bridge */
+#define SMCTT_MEM_BASE 0xFE000000      /* base for shared memory space */
+#define SMCTT_IOE_BASE 0xFE200000      /* base for I/O ports at even address */
+#define SMCTT_IOO_BASE 0xFE300000      /* base for I/O ports at odd address */
+
+#define SMCTT_IO_OFFSET        (SMCTT_IOO_BASE - SMCTT_IOE_BASE)
+
+/* default SMC8216 settings for SMC_TT specified by a jumper switch at No.2 */
+#define SMCTT_MEM_ADDR 0xD0000
+#define SMCTT_IO_ADDR  0x280
+
+/* SMC_TT uses IRQ4 on VME, IRQ3 on ISA, and interrupt vector 0xAA */
+#define SMCTT_VME_IRQ  4
+#define SMCTT_ISA_IRQ  3
+#define SMCTT_VECTOR   0xAA
+
+static int we_vme_probe(device_t, cfdata_t , void *);
+static void we_vme_attach(device_t, device_t, void *);
+
+static uint8_t smctt_bus_space_read_1(bus_space_tag_t, bus_space_handle_t,
+    bus_size_t);
+static void    smctt_bus_space_write_1(bus_space_tag_t, bus_space_handle_t,
+    bus_size_t, uint8_t);
+
+struct we_vme_softc {
+       struct we_softc sc_we;
+       struct atari_bus_space sc_bs;
+};
+
+CFATTACH_DECL_NEW(we_vme, sizeof(struct we_vme_softc),
+    we_vme_probe, we_vme_attach, NULL, NULL);
+
+static const int we_790_irq[] = {
+       -1, 9, 3, 5, 7, 10, 11, 15,
+};
+
+static int
+we_vme_probe(device_t parent, cfdata_t cf, void *aux)
+{
+       struct vme_attach_args *va = aux;
+       struct atari_bus_space t;
+       bus_space_tag_t asict, memt;
+       bus_space_handle_t asich, asich1, memh;
+       bus_size_t memsize;
+       bool asich_valid, asich1_valid, memh_valid;
+       int i, rv;
+       uint8_t sum, reg, type, hwr;
+
+       rv = 0;
+       asich_valid = false;
+       asich1_valid = false;
+       memh_valid = false;
+
+       if (va->va_iobase != IOBASEUNK &&
+           va->va_iobase != SMCTT_IOE_BASE + SMCTT_IO_ADDR)
+               return 0;
+       if (va->va_maddr != IOBASEUNK &&
+           va->va_maddr != SMCTT_MEM_BASE + SMCTT_MEM_ADDR)
+               return 0;
+       if (va->va_irq != IRQUNK &&
+           va->va_irq != SMCTT_VME_IRQ)
+               return 0;
+
+       /* SMC_TT has a bit weird I/O address mappings */
+       asict = beb_alloc_bus_space_tag(&t);
+       /* XXX setup only simple byte functions used in MI we(4) driver */
+       asict->abs_r_1 = smctt_bus_space_read_1;
+       asict->abs_w_1 = smctt_bus_space_write_1;
+
+       /*
+        * Only 16 bit accesses are allowed for memory space on SMC_TT,
+        * but MI we(4) uses them on 16 bit mode.
+        */
+       memt = va->va_memt;
+
+       /* Attempt to map the device. */
+       if (bus_space_map(asict, SMCTT_IOE_BASE + SMCTT_IO_ADDR, WE_NPORTS,
+           0, &asich) != 0) {
+               DPRINTF(("%s: failed to map even I/O space", __func__));
+               goto out;
+       }
+       asich_valid = true;
+
+       if (bus_space_map(asict, SMCTT_IOO_BASE + SMCTT_IO_ADDR, WE_NPORTS,
+           0, &asich1) != 0) {
+               DPRINTF(("%s: failed to map odd I/O space", __func__));
+               goto out;
+       }
+       asich1_valid = true;
+
+       /* XXX abuse stride for offset of odd ports from even ones */
+       asict->stride =
+           (vaddr_t)bus_space_vaddr(asict, asich1) -
+           (vaddr_t)bus_space_vaddr(asict, asich);
+
+       /*
+        * Attempt to do a checksum over the station address PROM.
+        * If it fails, it's probably not an SMC_TT board.
+        */
+       DPRINTF(("%s: WE_PROM: ", __func__));
+       sum = 0;
+       for (i = 0; i < 8; i++) {
+               reg = bus_space_read_1(asict, asich, WE_PROM + i);
+               DPRINTF(("%02x ", reg));
+               sum += reg;
+       }
+       DPRINTF(("\n"));
+       DPRINTF(("%s: WE_ROM_SUM: 0x%02x\n", __func__, sum));
+
+       if (sum != WE_ROM_CHECKSUM_TOTAL)
+               goto out;
+
+       /*
+        * Reset the card to force it into a known state.
+        */
+       bus_space_write_1(asict, asich, WE_MSR, WE_MSR_RST);
+       delay(100);
+
+       bus_space_write_1(asict, asich, WE_MSR,
+           bus_space_read_1(asict, asich, WE_MSR) & ~WE_MSR_RST);
+
+       /* Wait in case the card is reading it's EEPROM. */
+       delay(5000);
+
+       /*
+        * Check card type.
+        */
+       type = bus_space_read_1(asict, asich, WE_CARD_ID);
+       /* Assume SMT_TT has only 8216 */
+       if (type != WE_TYPE_SMC8216C && type != WE_TYPE_SMC8216T)
+               goto out;
+
+       hwr = bus_space_read_1(asict, asich, WE790_HWR);
+       bus_space_write_1(asict, asich, WE790_HWR, hwr | WE790_HWR_SWH);
+       switch (bus_space_read_1(asict, asich, WE790_RAR) & WE790_RAR_SZ64) {
+       case WE790_RAR_SZ64:
+               memsize = 65536;
+               break;
+       case WE790_RAR_SZ32:
+               memsize = 32768;
+               break;
+       case WE790_RAR_SZ16:
+               memsize = 16384;
+               break;
+       case WE790_RAR_SZ8:
+               memsize = 8192;
+               break;
+       default:
+               memsize = 16384;
+               break;
+       }
+       bus_space_write_1(asict, asich, WE790_HWR, hwr);
+
+       /* Attempt to map the memory space. */
+       if (bus_space_map(memt, SMCTT_MEM_BASE + SMCTT_MEM_ADDR, memsize,
+           0, &memh) != 0) {
+               DPRINTF(("%s: failed to map shared memory", __func__));
+               goto out;
+       }
+       memh_valid = true;
+
+       /*
+        * Check the assigned interrupt number from the card.
+        */
+
+       /* Assemble together the encoded interrupt number. */
+       hwr = bus_space_read_1(asict, asich, WE790_HWR);
+       bus_space_write_1(asict, asich, WE790_HWR, hwr | WE790_HWR_SWH);



Home | Main Index | Thread Index | Old Index