Home | History | Annotate | Line # | Download | only in dev
if_bah_zbus.c revision 1.6.8.2
      1  1.6.8.2  jdolecek /*	$NetBSD: if_bah_zbus.c,v 1.6.8.2 2002/10/10 18:31:27 jdolecek Exp $ */
      2      1.1        is 
      3      1.3        is /*-
      4      1.4        is  * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
      5      1.1        is  * All rights reserved.
      6      1.1        is  *
      7      1.3        is  * This code is derived from software contributed to The NetBSD Foundation
      8      1.3        is  * by Ignatios Souvatzis.
      9      1.3        is  *
     10      1.1        is  * Redistribution and use in source and binary forms, with or without
     11      1.1        is  * modification, are permitted provided that the following conditions
     12      1.1        is  * are met:
     13      1.1        is  * 1. Redistributions of source code must retain the above copyright
     14      1.1        is  *    notice, this list of conditions and the following disclaimer.
     15      1.1        is  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.1        is  *    notice, this list of conditions and the following disclaimer in the
     17      1.1        is  *    documentation and/or other materials provided with the distribution.
     18      1.1        is  * 3. All advertising materials mentioning features or use of this software
     19      1.1        is  *    must display the following acknowledgement:
     20      1.3        is  *        This product includes software developed by the NetBSD
     21      1.3        is  *        Foundation, Inc. and its contributors.
     22      1.3        is  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.3        is  *    contributors may be used to endorse or promote products derived
     24      1.3        is  *    from this software without specific prior written permission.
     25      1.1        is  *
     26      1.3        is  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.3        is  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.3        is  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.3        is  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.3        is  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.3        is  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.3        is  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.3        is  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.3        is  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.3        is  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.3        is  * POSSIBILITY OF SUCH DAMAGE.
     37      1.1        is  */
     38      1.1        is 
     39  1.6.8.1  jdolecek #include <sys/cdefs.h>
     40  1.6.8.2  jdolecek __KERNEL_RCSID(0, "$NetBSD: if_bah_zbus.c,v 1.6.8.2 2002/10/10 18:31:27 jdolecek Exp $");
     41  1.6.8.1  jdolecek 
     42      1.1        is /*
     43      1.1        is  * Driver frontend for the Commodore Busines Machines and the
     44      1.1        is  * Ameristar ARCnet card.
     45      1.1        is  */
     46      1.1        is 
     47      1.1        is #include <sys/types.h>
     48      1.1        is #include <sys/param.h>
     49      1.1        is 
     50      1.1        is #include <sys/conf.h>
     51      1.1        is #include <sys/device.h>
     52      1.1        is #include <sys/mbuf.h>
     53      1.1        is #include <sys/socket.h>
     54      1.1        is #include <sys/systm.h>
     55      1.1        is #include <sys/kernel.h>
     56      1.1        is 
     57      1.1        is #include <machine/bus.h>
     58      1.1        is #include <machine/cpu.h>
     59      1.1        is #include <machine/intr.h>
     60      1.1        is 
     61      1.1        is #include <net/if.h>
     62      1.1        is #include <net/route.h>
     63      1.1        is 
     64      1.1        is #include <net/if_arc.h>
     65      1.1        is 
     66      1.1        is #include <amiga/amiga/device.h>
     67      1.1        is #include <amiga/dev/zbusvar.h>
     68      1.1        is 
     69      1.1        is #include <dev/ic/smc90cx6var.h>
     70      1.1        is 
     71      1.1        is /*
     72      1.1        is  * A2060 software status per interface
     73      1.1        is  */
     74      1.1        is struct bah_zbus_softc {
     75      1.1        is 	struct	bah_softc	sc_bah;
     76      1.1        is 	struct	bus_space_tag	sc_bst;
     77      1.1        is 	struct	isr		sc_isr;
     78      1.1        is };
     79      1.1        is 
     80  1.6.8.1  jdolecek int	bah_zbus_match(struct device *, struct cfdata *, void *);
     81  1.6.8.1  jdolecek void	bah_zbus_attach(struct device *, struct device *, void *);
     82  1.6.8.1  jdolecek void	bah_zbus_reset(struct bah_softc *, int);
     83      1.1        is 
     84  1.6.8.2  jdolecek CFATTACH_DECL(bah_zbus, sizeof(struct bah_zbus_softc),
     85  1.6.8.2  jdolecek     bah_zbus_match, bah_zbus_attach, NULL, NULL);
     86      1.1        is 
     87      1.1        is int
     88  1.6.8.1  jdolecek bah_zbus_match(struct device *parent, struct cfdata *cfp, void *aux)
     89      1.1        is {
     90      1.1        is 	struct zbus_args *zap = aux;
     91      1.1        is 
     92      1.1        is 	if ((zap->manid == 514 || zap->manid == 1053) && zap->prodid == 9)
     93      1.1        is 		return (1);
     94      1.1        is 
     95      1.1        is 	return (0);
     96      1.1        is }
     97      1.1        is 
     98      1.1        is void
     99  1.6.8.1  jdolecek bah_zbus_attach(struct device *parent, struct device *self, void *aux)
    100      1.1        is {
    101      1.1        is 	struct bah_zbus_softc *bsc = (void *)self;
    102      1.1        is 	struct bah_softc *sc = &bsc->sc_bah;
    103      1.1        is 	struct zbus_args *zap = aux;
    104      1.1        is 
    105      1.1        is #if (defined(BAH_DEBUG) && (BAH_DEBUG > 2))
    106      1.1        is 	printf("\n%s: attach(0x%x, 0x%x, 0x%x)\n",
    107      1.1        is 	    sc->sc_dev.dv_xname, parent, self, aux);
    108      1.1        is #endif
    109      1.1        is 	bsc->sc_bst.base = (bus_addr_t)zap->va;
    110      1.6   aymeric 	bsc->sc_bst.absm = &amiga_bus_stride_2;
    111      1.1        is 
    112      1.1        is 	sc->sc_bst_r = &bsc->sc_bst;
    113      1.1        is 	sc->sc_regs = bsc->sc_bst.base + 0x4000;
    114      1.1        is 
    115      1.1        is 	sc->sc_bst_m = &bsc->sc_bst;
    116      1.1        is 	sc->sc_mem = bsc->sc_bst.base + 0x8000;
    117      1.1        is 
    118      1.1        is 	sc->sc_reset = bah_zbus_reset;
    119      1.1        is 
    120      1.1        is 	bah_attach_subr(sc);
    121      1.1        is 
    122      1.1        is 	bsc->sc_isr.isr_intr = bahintr;
    123      1.1        is 	bsc->sc_isr.isr_arg = sc;
    124      1.1        is 	bsc->sc_isr.isr_ipl = 2;
    125      1.1        is 	add_isr(&bsc->sc_isr);
    126      1.1        is }
    127      1.1        is 
    128      1.1        is void
    129  1.6.8.1  jdolecek bah_zbus_reset(struct bah_softc *sc, int onoff)
    130      1.1        is {
    131      1.1        is 	struct bah_zbus_softc *bsc;
    132      1.1        is 	volatile u_int8_t *p;
    133      1.1        is 
    134      1.1        is 	bsc = (struct bah_zbus_softc *)sc;
    135      1.1        is 
    136      1.1        is 	p = (volatile u_int8_t *)bsc->sc_bst.base;
    137      1.1        is 
    138      1.1        is 	p[0x0000] = 0;	/* A2060 reset flipflop */
    139      1.1        is 	p[0xc000] = 0;	/* A560 reset flipflop */
    140      1.1        is 
    141      1.1        is 	if (!onoff)
    142      1.1        is 		return;
    143      1.1        is 
    144      1.2        is #ifdef M68060
    145      1.2        is 	/* make sure we flush the store buffer before the delay */
    146      1.2        is 	(void)p[0x8000];
    147      1.2        is #endif
    148      1.1        is 	DELAY(200);
    149      1.1        is 
    150      1.1        is 	p[0x0000] = 0xff;
    151      1.1        is 	p[0xc000] = 0xff;
    152      1.1        is 
    153      1.1        is 	return;
    154      1.1        is }
    155