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