Index: conf/ATARITT =================================================================== RCS file: /cvsroot/src/sys/arch/atari/conf/ATARITT,v retrieving revision 1.86.4.4 diff -u -r1.86.4.4 ATARITT --- conf/ATARITT 12 Mar 2009 23:33:48 -0000 1.86.4.4 +++ conf/ATARITT 20 Mar 2010 12:07:51 -0000 @@ -110,6 +110,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 via SMC_TT VME-ISA bridge et0 at vme0 # Crazy Dots II scsibus* at scsi? # SCSI bus sd* at scsibus? target ? lun ? # SCSI disk drives Index: conf/GENERIC.in =================================================================== RCS file: /cvsroot/src/sys/arch/atari/conf/GENERIC.in,v retrieving revision 1.73.4.5 diff -u -r1.73.4.5 GENERIC.in --- conf/GENERIC.in 12 Mar 2009 23:32:35 -0000 1.73.4.5 +++ conf/GENERIC.in 20 Mar 2010 12:07:51 -0000 @@ -351,6 +351,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 via SMC_TT VME-ISA bridge et0 at vme0 # Crazy Dots II #endif /* TT030_KERNEL */ #endif /* SMALL030_KERNEL */ Index: conf/files.atari =================================================================== RCS file: /cvsroot/src/sys/arch/atari/conf/files.atari,v retrieving revision 1.112.20.1 diff -u -r1.112.20.1 files.atari --- conf/files.atari 8 Jan 2009 22:45:30 -0000 1.112.20.1 +++ conf/files.atari 20 Mar 2010 12:07:51 -0000 @@ -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 Index: vme/if_le_vme.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/vme/if_le_vme.c,v retrieving revision 1.24 diff -u -r1.24 if_le_vme.c --- vme/if_le_vme.c 28 Jun 2008 05:26:33 -0000 1.24 +++ vme/if_le_vme.c 20 Mar 2010 12:07:51 -0000 @@ -125,7 +125,7 @@ } lestd[] = { { 0xfe00fff0, 0xfe010000, IRQUNK, 16, 64*1024, LE_OLD_RIEBL|LE_NEW_RIEBL }, /* Riebl */ - { 0xffcffff0, 0xffcf0000, 5, 16, 64*1024, + { 0xfecffff0, 0xfecf0000, 5, 16, 64*1024, LE_PAM }, /* PAM */ { 0xfecffff0, 0xfecf0000, 5, 16, 64*1024, LE_ROTHRON }, /* Rhotron */ Index: vme/if_levar.h =================================================================== RCS file: /cvsroot/src/sys/arch/atari/vme/if_levar.h,v retrieving revision 1.6 diff -u -r1.6 if_levar.h --- vme/if_levar.h 28 Apr 2008 20:23:15 -0000 1.6 +++ vme/if_levar.h 20 Mar 2010 12:07:51 -0000 @@ -64,11 +64,11 @@ /* * Board Type: */ -#define LE_PAM 0x00 #define LE_OLD_RIEBL 0x01 #define LE_NEW_RIEBL 0x02 #define LE_BVME410 0x04 #define LE_ROTHRON 0x08 +#define LE_PAM 0x10 /* * Determine type of RIEBL card by magic --- /dev/null 2010-03-20 05:33:47.000000000 +0900 +++ vme/if_we_vme.c 2010-03-17 22:31:32.000000000 +0900 @@ -0,0 +1,453 @@ +/* $NetBSD: if_we_vme.c,v 1.2 2010/03/16 18:50:14 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 +__KERNEL_RCSID(0, "$NetBSD: if_we_vme.c,v 1.2 2010/03/16 18:50:14 tsutsui Exp $"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +/* #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); +static int smctt_bus_space_peek_1(bus_space_tag_t, bus_space_handle_t, + bus_size_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; + asict->abs_p_1 = smctt_bus_space_peek_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); + + /* check if register regions are valid */ + if (bus_space_peek_1(asict, asich, WE_PROM + 0) == 0 || + bus_space_peek_1(asict, asich, WE_PROM + 1) == 0) + goto out; + + /* + * 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 if memory region is valid */ + if (bus_space_peek_2(memt, memh, 0) == 0) + goto out; + + /* + * 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); + + reg = bus_space_read_1(asict, asich, WE790_GCR); + i = ((reg & WE790_GCR_IR2) >> 4) | + ((reg & (WE790_GCR_IR1|WE790_GCR_IR0)) >> 2); + bus_space_write_1(asict, asich, WE790_HWR, hwr & ~WE790_HWR_SWH); + + if (we_790_irq[i] != SMCTT_ISA_IRQ) { + DPRINTF(("%s: wrong IRQ (%d); check jumper settings\n", + __func__, we_790_irq[i])); + goto out; + } + + /* So, we say we've found it! */ + va->va_iobase = SMCTT_IOE_BASE + SMCTT_IO_ADDR; + va->va_iosize = WE_NPORTS; + va->va_maddr = SMCTT_MEM_BASE + SMCTT_MEM_ADDR; + va->va_msize = memsize; + va->va_irq = SMCTT_VME_IRQ; + + rv = 1; + + out: + if (asich_valid) + bus_space_unmap(asict, asich, WE_NPORTS); + if (asich1_valid) + bus_space_unmap(asict, asich1, WE_NPORTS); + if (memh_valid) + bus_space_unmap(memt, memh, memsize); + return rv; +} + +void +we_vme_attach(device_t parent, device_t self, void *aux) +{ + struct we_vme_softc *wvsc = device_private(self); + struct we_softc *wsc = &wvsc->sc_we; + struct dp8390_softc *sc = &wsc->sc_dp8390; + struct vme_attach_args *va = aux; + bus_space_tag_t nict, asict, memt; + bus_space_handle_t nich, asich, asich1, memh; + const char *typestr; + + aprint_normal("\n"); + + sc->sc_dev = self; + + /* See comments in the above probe function */ + asict = beb_alloc_bus_space_tag(&wvsc->sc_bs); + asict->abs_r_1 = smctt_bus_space_read_1; + asict->abs_w_1 = smctt_bus_space_write_1; + nict = asict; + + memt = va->va_memt; + + /* Map the device. */ + if (bus_space_map(asict, va->va_iobase, WE_NPORTS, 0, &asich) != 0) { + aprint_error_dev(self, "can't map even I/O space\n"); + return; + } + if (bus_space_map(asict, va->va_iobase + SMCTT_IO_OFFSET, WE_NPORTS, + 0, &asich1) != 0) { + aprint_error_dev(self, "can't map odd I/O space\n"); + goto out; + } + asict->stride = + (vaddr_t)bus_space_vaddr(asict, asich1) - + (vaddr_t)bus_space_vaddr(asict, asich); + + if (bus_space_subregion(asict, asich, WE_NIC_OFFSET, WE_NIC_NPORTS, + &nich) != 0) { + aprint_error_dev(self, "can't subregion I/O space\n"); + goto out1; + } + + /* Map memory space. */ + if (bus_space_map(memt, va->va_maddr, va->va_msize, 0, &memh) != 0) { + aprint_error_dev(self, "can't map shared memory\n"); + goto out1; + } + + wsc->sc_asict = asict; + wsc->sc_asich = asich; + + sc->sc_regt = nict; + sc->sc_regh = nich; + + sc->sc_buft = memt; + sc->sc_bufh = memh; + + wsc->sc_maddr = va->va_maddr & 0xfffff; + sc->mem_size = va->va_msize; + + /* Interface is always enabled. */ + sc->sc_enabled = 1; + + /* SMC_TT assumes SMC8216 */ + sc->is790 = 1; + + /* SMC_TT supports only 16 bit access for shared memory */ + wsc->sc_flags |= WE_16BIT_ENABLE; + + /* Appeal the Atari spirit :-) */ + typestr = "SMC8216 with SMC_TT VME-ISA bridge"; + + if (we_config(self, wsc, typestr) != 0) + goto out2; + + /* + * Enable the configured interrupt. + */ + bus_space_write_1(asict, asich, WE790_ICR, + bus_space_read_1(asict, asich, WE790_ICR) | WE790_ICR_EIL); + + /* Establish interrupt handler. */ + wsc->sc_ih = intr_establish(SMCTT_VECTOR - 64, USER_VEC, 0, + (hw_ifun_t)dp8390_intr, sc); + if (wsc->sc_ih == NULL) { + aprint_error_dev(self, "can't establish interrupt\n"); + goto out2; + } + /* + * Unmask the VME interrupt we're on. + */ + if ((machineid & ATARI_TT) != 0) + SCU->vme_mask |= 1 << va->va_irq; + + return; + + out2: + bus_space_unmap(memt, memh, va->va_msize); + out1: + bus_space_unmap(asict, asich1, WE_NPORTS); + out: + bus_space_unmap(asict, asich, WE_NPORTS); +} + +static uint8_t +smctt_bus_space_read_1(bus_space_tag_t bt, bus_space_handle_t bh, + bus_size_t reg) +{ + uint8_t rv; + + if ((reg & 0x01) != 0) { + /* odd address space */ + rv = *(volatile uint8_t *)(bh + bt->stride + (reg & ~0x01)); + } else { + /* even address space */ + rv = *(volatile uint8_t *)(bh + reg); + } + + return rv; +} + +static void +smctt_bus_space_write_1(bus_space_tag_t bt, bus_space_handle_t bh, + bus_size_t reg, uint8_t val) +{ + + if ((reg & 0x01) != 0) { + /* odd address space */ + *(volatile uint8_t *)(bh + bt->stride + (reg & ~0x01)) = val; + } else { + /* even address space */ + *(volatile uint8_t *)(bh + reg) = val; + } +} + +static int +smctt_bus_space_peek_1(bus_space_tag_t bt, bus_space_handle_t bh, + bus_size_t reg) +{ + uint8_t *va; + + if ((reg & 0x01) != 0) { + /* odd address space */ + va = (uint8_t *)(bh + bt->stride + (reg & ~0x01)); + } else { + /* even address space */ + va = (uint8_t *)(bh + reg); + } + + return !badbaddr(va, sizeof(uint8_t)); +} --- /dev/null 2010-03-20 05:33:47.000000000 +0900 +++ conf/SMALL_SMCTT 2010-03-15 23:28:42.000000000 +0900 @@ -0,0 +1,61 @@ +# +# $NetBSD: SMALL030,v 1.1.2.3 2009/03/12 23:33:48 snj Exp $ +# +# This file was automatically created. Changes will be +# lost when running makeconf in this directory. +# +# Created from: +# NetBSD: GENERIC.in,v 1.73.4.5 2009/03/12 23:32:35 snj Exp $ +include "arch/atari/conf/std.atari" +makeoptions COPTS="-Os" +maxusers 16 +options HZ=64 # Set the clock-rate (48/64/96) +options INSECURE # disable kernel security levels +options M68030 # support for 030 +options FPU_EMULATE # Support for MC68881/MC68882 emulator +options INET # IP + ICMP + TCP + UDP +file-system FFS # Berkeley fast file system +file-system MFS # Memory based filesystem +file-system MSDOSFS # MSDOS filesystem +file-system CD9660 # ISO 9660 filesystem with Rock Ridge +options WAPBL # File system journaling support - Experimental +options PANICWAIT # Require keystroke to dump/reboot +options COMPAT_16 # Compatibility with NetBSD 1.6 +options COMPAT_20 # Compatibility with NetBSD 2.0 +options COMPAT_30 # NetBSD 3.0 compatibility. +options COMPAT_40 # NetBSD 4.0 compatibility. +options COMPAT_BSDPTY # /dev/[pt]ty?? ptys. +options PIPE_SOCKETPAIR # smaller, but slower pipe(2) +options ST_POOL_SIZE=24 # smallest that allows TT-HIGH +options TT_SCSI # SCSI-support for TT +options TT_VIDEO # Graphics support for TT +options FALCON_SCSI # SCSI-support for Falcon +options FALCON_VIDEO # Graphics support for FALCON +options MEMORY_DISK_HOOKS # Boot RAM-disk +options DISKLABEL_NBDA # NetBSD disklabels (required) +options DISKLABEL_AHDI # NetBSD/AHDI disklabels +config netbsd root on ? type ? +pseudo-device sl # Slip +pseudo-device pty # pseudo-terminals +pseudo-device loop # Loopback network +pseudo-device md 3 # Boot memory disk +pseudo-device view 4 # View (graphics mapping) +ncrscsi0 at mainbus0 # NCR5380 SCSI driver +zs0 at mainbus0 # Serial support through 8530 +grfbus0 at mainbus0 # bitmapped display's +grfcc0 at grfbus0 # graphics driver +ite0 at grfcc0 # console +nvr0 at mainbus0 # nvram driver +avmebus0 at mainbus0 # VME bus +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 +wdc0 at mainbus0 # IDE-bus +atabus* at wdc? channel ? +wd* at atabus? drive ? +atapibus* at atabus? +cd* at atapibus? drive ? # ATAPI CD-ROM drives +scsibus* at scsi? # SCSI bus +sd* at scsibus? target ? lun ? # SCSI disk drives +cd* at scsibus? target ? lun ? # SCSI CD-ROM drives