Home | History | Annotate | Line # | Download | only in dev
vme_two_68k.c revision 1.8.10.1
      1 /*	$NetBSD: vme_two_68k.c,v 1.8.10.1 2008/05/16 02:22:53 yamt 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  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Front-end for the VMEchip2 found on the MVME-1[67][27] boards.
     34  */
     35 
     36 #include <sys/cdefs.h>
     37 __KERNEL_RCSID(0, "$NetBSD: vme_two_68k.c,v 1.8.10.1 2008/05/16 02:22:53 yamt Exp $");
     38 
     39 #include "vmetwo.h"
     40 
     41 #include <sys/param.h>
     42 #include <sys/kernel.h>
     43 #include <sys/systm.h>
     44 #include <sys/device.h>
     45 
     46 #include <machine/cpu.h>
     47 #include <machine/bus.h>
     48 
     49 #include <dev/vme/vmereg.h>
     50 #include <dev/vme/vmevar.h>
     51 
     52 #include <mvme68k/mvme68k/isr.h>
     53 #include <mvme68k/dev/mainbus.h>
     54 
     55 #include <dev/mvme/mvmebus.h>
     56 #include <dev/mvme/vme_tworeg.h>
     57 #include <dev/mvme/vme_twovar.h>
     58 
     59 #include "ioconf.h"
     60 
     61 static void vmetwoisrlink(void *, int (*)(void *), void *,
     62 	int, int, struct evcnt *);
     63 static void vmetwoisrunlink(void *, int);
     64 static struct evcnt *vmetwoisrevcnt(void *, int);
     65 
     66 #if NVMETWO > 0
     67 
     68 int vmetwo_match(struct device *, struct cfdata *, void *);
     69 void vmetwo_attach(struct device *, struct device *, void *);
     70 
     71 CFATTACH_DECL(vmetwo, sizeof(struct vmetwo_softc),
     72     vmetwo_match, vmetwo_attach, NULL, NULL);
     73 
     74 
     75 /* ARGSUSED */
     76 int
     77 vmetwo_match(struct device *parent, struct cfdata *cf, void *aux)
     78 {
     79 	struct mainbus_attach_args *ma;
     80 	static int matched = 0;
     81 
     82 	ma = aux;
     83 
     84 	if (strcmp(ma->ma_name, vmetwo_cd.cd_name))
     85 		return 0;
     86 
     87 	/* Only one VMEchip2, please. */
     88 	if (matched++)
     89 		return 0;
     90 
     91 	/*
     92 	 * Some mvme1[67]2 boards have a `no VMEchip2' build option...
     93 	 */
     94 	return vmetwo_probe(ma->ma_bust, ma->ma_offset) ? 1 : 0;
     95 }
     96 
     97 /* ARGSUSED */
     98 void
     99 vmetwo_attach(struct device *parent, struct device *self, void *aux)
    100 {
    101 	struct mainbus_attach_args *ma;
    102 	struct vmetwo_softc *sc;
    103 
    104 	sc = (struct vmetwo_softc *) self;
    105 	ma = aux;
    106 
    107 	/*
    108 	 * Map the local control registers
    109 	 */
    110 	bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_LCSR_OFFSET,
    111 	    VME2LCSR_SIZE, 0, &sc->sc_lcrh);
    112 
    113 #ifdef notyet
    114 	/*
    115 	 * Map the global control registers
    116 	 */
    117 	bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_GCSR_OFFSET,
    118 	    VME2GCSR_SIZE, 0, &sc->sc_gcrh);
    119 #endif
    120 
    121 	/* Initialise stuff for the common vme_two back-end */
    122 	sc->sc_mvmebus.sc_bust = ma->ma_bust;
    123 	sc->sc_mvmebus.sc_dmat = ma->ma_dmat;
    124 
    125 	vmetwo_init(sc);
    126 }
    127 
    128 #endif	/* NVMETWO > 0 */
    129 
    130 void
    131 vmetwo_md_intr_init(struct vmetwo_softc *sc)
    132 {
    133 
    134 	sc->sc_isrlink = vmetwoisrlink;
    135 	sc->sc_isrunlink = vmetwoisrunlink;
    136 	sc->sc_isrevcnt = vmetwoisrevcnt;
    137 }
    138 
    139 /* ARGSUSED */
    140 static void
    141 vmetwoisrlink(void *cookie, int (*fn)(void *), void *arg, int ipl, int vec,
    142     struct evcnt *evcnt)
    143 {
    144 
    145 	isrlink_vectored(fn, arg, ipl, vec, evcnt);
    146 }
    147 
    148 /* ARGSUSED */
    149 static void
    150 vmetwoisrunlink(void *cookie, int vec)
    151 {
    152 
    153 	isrunlink_vectored(vec);
    154 }
    155 
    156 /* ARGSUSED */
    157 static struct evcnt *
    158 vmetwoisrevcnt(void *cookie, int ipl)
    159 {
    160 
    161 	return isrlink_evcnt(ipl);
    162 }
    163