Home | History | Annotate | Line # | Download | only in isapnp
mpu_isapnp.c revision 1.12
      1  1.12   thorpej /*	$NetBSD: mpu_isapnp.c,v 1.12 2006/03/29 06:51:47 thorpej Exp $	*/
      2   1.5     lukem 
      3   1.5     lukem #include <sys/cdefs.h>
      4  1.12   thorpej __KERNEL_RCSID(0, "$NetBSD: mpu_isapnp.c,v 1.12 2006/03/29 06:51:47 thorpej 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.1   mycroft #include <machine/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.1   mycroft mpu_isapnp_match(parent, match, aux)
     47   1.1   mycroft 	struct device *parent;
     48   1.1   mycroft 	struct cfdata *match;
     49   1.1   mycroft 	void *aux;
     50   1.1   mycroft {
     51   1.3   mycroft 	int pri, variant;
     52   1.2   mycroft 
     53   1.3   mycroft 	pri = isapnp_devmatch(aux, &isapnp_mpu_devinfo, &variant);
     54   1.3   mycroft 	if (pri && variant > 0)
     55   1.3   mycroft 		pri = 0;
     56   1.3   mycroft 	return (pri);
     57   1.1   mycroft }
     58   1.1   mycroft 
     59   1.1   mycroft void
     60   1.1   mycroft mpu_isapnp_attach(parent, self, aux)
     61   1.1   mycroft 	struct device *parent, *self;
     62   1.1   mycroft 	void *aux;
     63   1.1   mycroft {
     64  1.12   thorpej 	struct mpu_isapnp_softc *sc = device_private(self);
     65   1.1   mycroft 	struct isapnp_attach_args *ipa = aux;
     66   1.1   mycroft 
     67   1.1   mycroft 	printf("\n");
     68   1.1   mycroft 
     69   1.1   mycroft 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
     70  1.10     perry 		printf("%s: error in region allocation\n",
     71   1.1   mycroft 		       sc->sc_dev.dv_xname);
     72   1.1   mycroft 		return;
     73   1.1   mycroft 	}
     74   1.1   mycroft 
     75   1.1   mycroft 	sc->sc_mpu.iot = ipa->ipa_iot;
     76   1.1   mycroft 	sc->sc_mpu.ioh = ipa->ipa_io[0].h;
     77   1.1   mycroft 
     78   1.1   mycroft 	if (!mpu_find(&sc->sc_mpu)) {
     79   1.1   mycroft 		printf("%s: find failed\n", sc->sc_dev.dv_xname);
     80   1.1   mycroft 		return;
     81   1.1   mycroft 	}
     82   1.1   mycroft 
     83   1.1   mycroft 	printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
     84   1.1   mycroft 	       ipa->ipa_devclass);
     85   1.1   mycroft 
     86   1.1   mycroft 	midi_attach_mi(&mpu_midi_hw_if, &sc->sc_mpu, &sc->sc_dev);
     87   1.1   mycroft 
     88   1.1   mycroft 	sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
     89   1.1   mycroft 	    ipa->ipa_irq[0].type, IPL_AUDIO, mpu_intr, &sc->sc_mpu);
     90   1.1   mycroft }
     91