1 /* $NetBSD: mpu_isapnp.c,v 1.16 2007/10/19 12:00:33 ad Exp $ */
4 __KERNEL_RCSID(0, "$NetBSD: mpu_isapnp.c,v 1.16 2007/10/19 12:00:33 ad Exp $");
10 #include <sys/errno.h>
11 #include <sys/ioctl.h>
12 #include <sys/syslog.h>
13 #include <sys/device.h>
18 #include <sys/audioio.h>
19 #include <dev/audio_if.h>
20 #include <dev/midi_if.h>
21 #include <dev/mulaw.h>
23 #include <dev/isa/isavar.h>
24 #include <dev/isa/isadmavar.h>
26 #include <dev/isapnp/isapnpreg.h>
27 #include <dev/isapnp/isapnpvar.h>
28 #include <dev/isapnp/isapnpdevs.h>
30 #include <dev/ic/mpuvar.h>
32 static int mpu_isapnp_match(device_t
, cfdata_t
, void *);
33 static void mpu_isapnp_attach(device_t
, device_t
, void *);
35 struct mpu_isapnp_softc
{
38 struct mpu_softc sc_mpu
;
41 CFATTACH_DECL_NEW(mpu_isapnp
, sizeof(struct mpu_isapnp_softc
),
42 mpu_isapnp_match
, mpu_isapnp_attach
, NULL
, NULL
);
45 mpu_isapnp_match(device_t parent
, cfdata_t match
, void *aux
)
49 pri
= isapnp_devmatch(aux
, &isapnp_mpu_devinfo
, &variant
);
50 if (pri
&& variant
> 0)
56 mpu_isapnp_attach(device_t parent
, device_t self
, void *aux
)
58 struct mpu_isapnp_softc
*sc
= device_private(self
);
59 struct isapnp_attach_args
*ipa
= aux
;
63 if (isapnp_config(ipa
->ipa_iot
, ipa
->ipa_memt
, ipa
)) {
64 aprint_error_dev(self
, "error in region allocation\n");
68 sc
->sc_mpu
.iot
= ipa
->ipa_iot
;
69 sc
->sc_mpu
.ioh
= ipa
->ipa_io
[0].h
;
71 if (!mpu_find(&sc
->sc_mpu
)) {
72 aprint_error_dev(self
, "find failed\n");
76 aprint_normal_dev(self
, "%s %s\n", ipa
->ipa_devident
,
79 sc
->sc_mpu
.model
= "Roland MPU-401 MIDI UART";
81 midi_attach_mi(&mpu_midi_hw_if
, &sc
->sc_mpu
, self
);
83 sc
->sc_ih
= isa_intr_establish(ipa
->ipa_ic
, ipa
->ipa_irq
[0].num
,
84 ipa
->ipa_irq
[0].type
, IPL_AUDIO
, mpu_intr
, &sc
->sc_mpu
);