Home | History | Annotate | Line # | Download | only in isapnp
mpu_isapnp.c revision 1.15.8.1
      1  1.15.8.1        ad /*	$NetBSD: mpu_isapnp.c,v 1.15.8.1 2007/10/23 20:08:28 ad Exp $	*/
      2       1.5     lukem 
      3       1.5     lukem #include <sys/cdefs.h>
      4  1.15.8.1        ad __KERNEL_RCSID(0, "$NetBSD: mpu_isapnp.c,v 1.15.8.1 2007/10/23 20:08:28 ad Exp $");
      5       1.5     lukem 
      6       1.1   mycroft #include "midi.h"
      7       1.1   mycroft 
      8       1.1   mycroft #include <sys/param.h>
      9       1.1   mycroft #include <sys/systm.h>
     10       1.1   mycroft #include <sys/errno.h>
     11       1.1   mycroft #include <sys/ioctl.h>
     12       1.1   mycroft #include <sys/syslog.h>
     13       1.1   mycroft #include <sys/device.h>
     14       1.1   mycroft #include <sys/proc.h>
     15       1.1   mycroft 
     16  1.15.8.1        ad #include <sys/bus.h>
     17       1.1   mycroft 
     18       1.1   mycroft #include <sys/audioio.h>
     19       1.1   mycroft #include <dev/audio_if.h>
     20       1.1   mycroft #include <dev/midi_if.h>
     21       1.1   mycroft #include <dev/mulaw.h>
     22       1.1   mycroft 
     23       1.1   mycroft #include <dev/isa/isavar.h>
     24       1.1   mycroft #include <dev/isa/isadmavar.h>
     25       1.1   mycroft 
     26       1.1   mycroft #include <dev/isapnp/isapnpreg.h>
     27       1.1   mycroft #include <dev/isapnp/isapnpvar.h>
     28       1.1   mycroft #include <dev/isapnp/isapnpdevs.h>
     29       1.1   mycroft 
     30       1.4  augustss #include <dev/ic/mpuvar.h>
     31       1.1   mycroft 
     32       1.9     perry int	mpu_isapnp_match(struct device *, struct cfdata *, void *);
     33       1.9     perry void	mpu_isapnp_attach(struct device *, struct device *, void *);
     34       1.1   mycroft 
     35       1.1   mycroft struct mpu_isapnp_softc {
     36       1.1   mycroft 	struct device sc_dev;
     37       1.1   mycroft 	void *sc_ih;
     38       1.1   mycroft 
     39       1.1   mycroft 	struct mpu_softc sc_mpu;
     40       1.1   mycroft };
     41       1.1   mycroft 
     42       1.7   thorpej CFATTACH_DECL(mpu_isapnp, sizeof(struct mpu_isapnp_softc),
     43       1.8   thorpej     mpu_isapnp_match, mpu_isapnp_attach, NULL, NULL);
     44       1.1   mycroft 
     45       1.1   mycroft int
     46      1.15  christos mpu_isapnp_match(struct device *parent, struct cfdata *match,
     47      1.14  christos     void *aux)
     48       1.1   mycroft {
     49       1.3   mycroft 	int pri, variant;
     50       1.2   mycroft 
     51       1.3   mycroft 	pri = isapnp_devmatch(aux, &isapnp_mpu_devinfo, &variant);
     52       1.3   mycroft 	if (pri && variant > 0)
     53       1.3   mycroft 		pri = 0;
     54       1.3   mycroft 	return (pri);
     55       1.1   mycroft }
     56       1.1   mycroft 
     57       1.1   mycroft void
     58      1.15  christos mpu_isapnp_attach(struct device *parent, struct device *self,
     59      1.14  christos     void *aux)
     60       1.1   mycroft {
     61      1.12   thorpej 	struct mpu_isapnp_softc *sc = device_private(self);
     62       1.1   mycroft 	struct isapnp_attach_args *ipa = aux;
     63       1.1   mycroft 
     64       1.1   mycroft 	printf("\n");
     65       1.1   mycroft 
     66       1.1   mycroft 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
     67      1.10     perry 		printf("%s: error in region allocation\n",
     68       1.1   mycroft 		       sc->sc_dev.dv_xname);
     69       1.1   mycroft 		return;
     70       1.1   mycroft 	}
     71       1.1   mycroft 
     72       1.1   mycroft 	sc->sc_mpu.iot = ipa->ipa_iot;
     73       1.1   mycroft 	sc->sc_mpu.ioh = ipa->ipa_io[0].h;
     74       1.1   mycroft 
     75       1.1   mycroft 	if (!mpu_find(&sc->sc_mpu)) {
     76       1.1   mycroft 		printf("%s: find failed\n", sc->sc_dev.dv_xname);
     77       1.1   mycroft 		return;
     78       1.1   mycroft 	}
     79       1.1   mycroft 
     80       1.1   mycroft 	printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
     81       1.1   mycroft 	       ipa->ipa_devclass);
     82       1.1   mycroft 
     83      1.13  christos 	sc->sc_mpu.model = "Roland MPU-401 MIDI UART";
     84      1.13  christos 
     85       1.1   mycroft 	midi_attach_mi(&mpu_midi_hw_if, &sc->sc_mpu, &sc->sc_dev);
     86       1.1   mycroft 
     87       1.1   mycroft 	sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
     88       1.1   mycroft 	    ipa->ipa_irq[0].type, IPL_AUDIO, mpu_intr, &sc->sc_mpu);
     89       1.1   mycroft }
     90