Home | History | Annotate | Line # | Download | only in isa
mpu_isa.c revision 1.3.2.2
      1  1.3.2.2  thorpej /*	$NetBSD: mpu_isa.c,v 1.3.2.2 1999/08/02 21:59:29 thorpej Exp $	*/
      2  1.3.2.2  thorpej 
      3  1.3.2.2  thorpej /*-
      4  1.3.2.2  thorpej  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  1.3.2.2  thorpej  * All rights reserved.
      6  1.3.2.2  thorpej  *
      7  1.3.2.2  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.3.2.2  thorpej  * by Lennart Augustsson.
      9  1.3.2.2  thorpej  *
     10  1.3.2.2  thorpej  * Redistribution and use in source and binary forms, with or without
     11  1.3.2.2  thorpej  * modification, are permitted provided that the following conditions
     12  1.3.2.2  thorpej  * are met:
     13  1.3.2.2  thorpej  * 1. Redistributions of source code must retain the above copyright
     14  1.3.2.2  thorpej  *    notice, this list of conditions and the following disclaimer.
     15  1.3.2.2  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.3.2.2  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17  1.3.2.2  thorpej  *    documentation and/or other materials provided with the distribution.
     18  1.3.2.2  thorpej  * 3. All advertising materials mentioning features or use of this software
     19  1.3.2.2  thorpej  *    must display the following acknowledgement:
     20  1.3.2.2  thorpej  *        This product includes software developed by the NetBSD
     21  1.3.2.2  thorpej  *        Foundation, Inc. and its contributors.
     22  1.3.2.2  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.3.2.2  thorpej  *    contributors may be used to endorse or promote products derived
     24  1.3.2.2  thorpej  *    from this software without specific prior written permission.
     25  1.3.2.2  thorpej  *
     26  1.3.2.2  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.3.2.2  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.3.2.2  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.3.2.2  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.3.2.2  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.3.2.2  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.3.2.2  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.3.2.2  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.3.2.2  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.3.2.2  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.3.2.2  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37  1.3.2.2  thorpej  */
     38  1.3.2.2  thorpej 
     39  1.3.2.2  thorpej #include <sys/param.h>
     40  1.3.2.2  thorpej #include <sys/systm.h>
     41  1.3.2.2  thorpej #include <sys/kernel.h>
     42  1.3.2.2  thorpej #include <sys/errno.h>
     43  1.3.2.2  thorpej #include <sys/device.h>
     44  1.3.2.2  thorpej #include <sys/proc.h>
     45  1.3.2.2  thorpej #include <sys/conf.h>
     46  1.3.2.2  thorpej #include <sys/midiio.h>
     47  1.3.2.2  thorpej 
     48  1.3.2.2  thorpej #include <machine/bus.h>
     49  1.3.2.2  thorpej 
     50  1.3.2.2  thorpej #include <dev/midi_if.h>
     51  1.3.2.2  thorpej 
     52  1.3.2.2  thorpej #include <dev/isa/isavar.h>
     53  1.3.2.2  thorpej #include <dev/ic/mpuvar.h>
     54  1.3.2.2  thorpej 
     55  1.3.2.2  thorpej struct mpu_isa_softc {
     56  1.3.2.2  thorpej 	struct mpu_softc sc_mpu;	/* generic part */
     57  1.3.2.2  thorpej 	void	*sc_ih;			/* ISA interrupt handler */
     58  1.3.2.2  thorpej };
     59  1.3.2.2  thorpej 
     60  1.3.2.2  thorpej int	mpu_isa_match __P((struct device *, struct cfdata *, void *));
     61  1.3.2.2  thorpej void	mpu_isa_attach __P((struct device *, struct device *, void *));
     62  1.3.2.2  thorpej 
     63  1.3.2.2  thorpej struct cfattach mpu_isa_ca = {
     64  1.3.2.2  thorpej 	sizeof (struct mpu_isa_softc), mpu_isa_match, mpu_isa_attach
     65  1.3.2.2  thorpej };
     66  1.3.2.2  thorpej 
     67  1.3.2.2  thorpej int
     68  1.3.2.2  thorpej mpu_isa_match(parent, match, aux)
     69  1.3.2.2  thorpej 	struct device *parent;
     70  1.3.2.2  thorpej 	struct cfdata *match;
     71  1.3.2.2  thorpej 	void *aux;
     72  1.3.2.2  thorpej {
     73  1.3.2.2  thorpej 	struct isa_attach_args *ia = aux;
     74  1.3.2.2  thorpej 	struct mpu_isa_softc sc;
     75  1.3.2.2  thorpej 	int r;
     76  1.3.2.2  thorpej 
     77  1.3.2.2  thorpej 	memset(&sc, 0, sizeof sc);
     78  1.3.2.2  thorpej 	sc.sc_mpu.iot = ia->ia_iot;
     79  1.3.2.2  thorpej 	if (bus_space_map(sc.sc_mpu.iot, ia->ia_iobase, MPU401_NPORT, 0,
     80  1.3.2.2  thorpej 			  &sc.sc_mpu.ioh))
     81  1.3.2.2  thorpej 		return (0);
     82  1.3.2.2  thorpej 	r = mpu_find(&sc.sc_mpu);
     83  1.3.2.2  thorpej         bus_space_unmap(sc.sc_mpu.iot, sc.sc_mpu.ioh, MPU401_NPORT);
     84  1.3.2.2  thorpej 	if (r) {
     85  1.3.2.2  thorpej 		ia->ia_iosize = MPU401_NPORT;
     86  1.3.2.2  thorpej 		ia->ia_msize = 0;
     87  1.3.2.2  thorpej 	}
     88  1.3.2.2  thorpej 	return (r);
     89  1.3.2.2  thorpej }
     90  1.3.2.2  thorpej 
     91  1.3.2.2  thorpej void
     92  1.3.2.2  thorpej mpu_isa_attach(parent, self, aux)
     93  1.3.2.2  thorpej 	struct device *parent;
     94  1.3.2.2  thorpej 	struct device *self;
     95  1.3.2.2  thorpej 	void *aux;
     96  1.3.2.2  thorpej {
     97  1.3.2.2  thorpej 	struct mpu_isa_softc *sc = (struct mpu_isa_softc *)self;
     98  1.3.2.2  thorpej 	struct isa_attach_args *ia = aux;
     99  1.3.2.2  thorpej 
    100  1.3.2.2  thorpej 	printf("\n");
    101  1.3.2.2  thorpej 
    102  1.3.2.2  thorpej 	if (bus_space_map(sc->sc_mpu.iot, ia->ia_iobase, MPU401_NPORT, 0,
    103  1.3.2.2  thorpej 			  &sc->sc_mpu.ioh)) {
    104  1.3.2.2  thorpej 		printf("mpu_isa_attach: bus_space_map failed\n");
    105  1.3.2.2  thorpej 		return;
    106  1.3.2.2  thorpej 	}
    107  1.3.2.2  thorpej 
    108  1.3.2.2  thorpej 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, IPL_AUDIO,
    109  1.3.2.2  thorpej 				       mpu_intr, sc);
    110  1.3.2.2  thorpej 
    111  1.3.2.2  thorpej 	sc->model = "Roland MPU-401 MIDI UART";
    112  1.3.2.2  thorpej 	mpu_attach(&sc->sc_mpu);
    113  1.3.2.2  thorpej }
    114  1.3.2.2  thorpej 
    115