Home | History | Annotate | Line # | Download | only in dev
vme_two_68k.c revision 1.5.6.3
      1 /*	$NetBSD: vme_two_68k.c,v 1.5.6.3 2004/09/21 13:19:05 skrll Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Steve C. Woodford.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * Front-end for the VMEchip2 found on the MVME-1[67][27] boards.
     41  */
     42 
     43 #include <sys/cdefs.h>
     44 __KERNEL_RCSID(0, "$NetBSD: vme_two_68k.c,v 1.5.6.3 2004/09/21 13:19:05 skrll Exp $");
     45 
     46 #include "vmetwo.h"
     47 
     48 #include <sys/param.h>
     49 #include <sys/kernel.h>
     50 #include <sys/systm.h>
     51 #include <sys/device.h>
     52 
     53 #include <machine/cpu.h>
     54 #include <machine/bus.h>
     55 
     56 #include <dev/vme/vmereg.h>
     57 #include <dev/vme/vmevar.h>
     58 
     59 #include <mvme68k/mvme68k/isr.h>
     60 #include <mvme68k/dev/mainbus.h>
     61 
     62 #include <dev/mvme/mvmebus.h>
     63 #include <dev/mvme/vme_tworeg.h>
     64 #include <dev/mvme/vme_twovar.h>
     65 
     66 
     67 static void vmetwoisrlink(void *, int (*)(void *), void *,
     68 	int, int, struct evcnt *);
     69 static void vmetwoisrunlink(void *, int);
     70 static struct evcnt *vmetwoisrevcnt(void *, int);
     71 
     72 #if NVMETWO > 0
     73 
     74 int vmetwo_match __P((struct device *, struct cfdata *, void *));
     75 void vmetwo_attach __P((struct device *, struct device *, void *));
     76 
     77 CFATTACH_DECL(vmetwo, sizeof(struct vmetwo_softc),
     78     vmetwo_match, vmetwo_attach, NULL, NULL);
     79 extern struct cfdriver vmetwo_cd;
     80 
     81 
     82 /* ARGSUSED */
     83 int
     84 vmetwo_match(parent, cf, aux)
     85 	struct device *parent;
     86 	struct cfdata *cf;
     87 	void *aux;
     88 {
     89 	struct mainbus_attach_args *ma;
     90 	static int matched = 0;
     91 
     92 	ma = aux;
     93 
     94 	if (strcmp(ma->ma_name, vmetwo_cd.cd_name))
     95 		return (0);
     96 
     97 	/* Only one VMEchip2, please. */
     98 	if (matched++)
     99 		return (0);
    100 
    101 	/*
    102 	 * Some mvme1[67]2 boards have a `no VMEchip2' build option...
    103 	 */
    104 	return (vmetwo_probe(ma->ma_bust, ma->ma_offset) ? 1 : 0);
    105 }
    106 
    107 /* ARGSUSED */
    108 void
    109 vmetwo_attach(parent, self, aux)
    110 	struct device *parent;
    111 	struct device *self;
    112 	void *aux;
    113 {
    114 	struct mainbus_attach_args *ma;
    115 	struct vmetwo_softc *sc;
    116 
    117 	sc = (struct vmetwo_softc *) self;
    118 	ma = aux;
    119 
    120 	/*
    121 	 * Map the local control registers
    122 	 */
    123 	bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_LCSR_OFFSET,
    124 	    VME2LCSR_SIZE, 0, &sc->sc_lcrh);
    125 
    126 #ifdef notyet
    127 	/*
    128 	 * Map the global control registers
    129 	 */
    130 	bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_GCSR_OFFSET,
    131 	    VME2GCSR_SIZE, 0, &sc->sc_gcrh);
    132 #endif
    133 
    134 	/* Initialise stuff for the common vme_two back-end */
    135 	sc->sc_mvmebus.sc_bust = ma->ma_bust;
    136 	sc->sc_mvmebus.sc_dmat = ma->ma_dmat;
    137 
    138 	vmetwo_init(sc);
    139 }
    140 
    141 #endif	/* NVMETWO > 0 */
    142 
    143 void
    144 vmetwo_md_intr_init(sc)
    145 	struct vmetwo_softc *sc;
    146 {
    147 
    148 	sc->sc_isrlink = vmetwoisrlink;
    149 	sc->sc_isrunlink = vmetwoisrunlink;
    150 	sc->sc_isrevcnt = vmetwoisrevcnt;
    151 }
    152 
    153 /* ARGSUSED */
    154 static void
    155 vmetwoisrlink(cookie, fn, arg, ipl, vec, evcnt)
    156 	void *cookie;
    157 	int (*fn)(void *);
    158 	void *arg;
    159 	int ipl, vec;
    160 	struct evcnt *evcnt;
    161 {
    162 
    163 	isrlink_vectored(fn, arg, ipl, vec, evcnt);
    164 }
    165 
    166 /* ARGSUSED */
    167 static void
    168 vmetwoisrunlink(cookie, vec)
    169 	void *cookie;
    170 	int vec;
    171 {
    172 
    173 	isrunlink_vectored(vec);
    174 }
    175 
    176 /* ARGSUSED */
    177 static struct evcnt *
    178 vmetwoisrevcnt(cookie, ipl)
    179 	void *cookie;
    180 	int ipl;
    181 {
    182 
    183 	return (isrlink_evcnt(ipl));
    184 }
    185