mpu_yds.c revision 1.8 1 1.8 xtraeme /* $NetBSD: mpu_yds.c,v 1.8 2004/12/02 09:50:42 xtraeme Exp $ */
2 1.1 minoura
3 1.1 minoura /*
4 1.1 minoura * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.1 minoura * All rights reserved.
6 1.1 minoura *
7 1.1 minoura * This code is derived from software contributed to The NetBSD Foundation
8 1.6 keihan * by Lennart Augustsson (augustss (at) NetBSD.org).
9 1.1 minoura *
10 1.1 minoura * Redistribution and use in source and binary forms, with or without
11 1.1 minoura * modification, are permitted provided that the following conditions
12 1.1 minoura * are met:
13 1.1 minoura * 1. Redistributions of source code must retain the above copyright
14 1.1 minoura * notice, this list of conditions and the following disclaimer.
15 1.1 minoura * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 minoura * notice, this list of conditions and the following disclaimer in the
17 1.1 minoura * documentation and/or other materials provided with the distribution.
18 1.1 minoura * 3. All advertising materials mentioning features or use of this software
19 1.1 minoura * must display the following acknowledgement:
20 1.1 minoura * This product includes software developed by the NetBSD
21 1.1 minoura * Foundation, Inc. and its contributors.
22 1.1 minoura * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 minoura * contributors may be used to endorse or promote products derived
24 1.1 minoura * from this software without specific prior written permission.
25 1.1 minoura *
26 1.1 minoura * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 minoura * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 minoura * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 minoura * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 minoura * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 minoura * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 minoura * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 minoura * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 minoura * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 minoura * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 minoura * POSSIBILITY OF SUCH DAMAGE.
37 1.1 minoura */
38 1.2 lukem
39 1.2 lukem #include <sys/cdefs.h>
40 1.8 xtraeme __KERNEL_RCSID(0, "$NetBSD: mpu_yds.c,v 1.8 2004/12/02 09:50:42 xtraeme Exp $");
41 1.1 minoura
42 1.1 minoura #include <sys/param.h>
43 1.1 minoura #include <sys/systm.h>
44 1.1 minoura #include <sys/kernel.h>
45 1.1 minoura #include <sys/errno.h>
46 1.1 minoura #include <sys/device.h>
47 1.1 minoura #include <sys/proc.h>
48 1.1 minoura #include <sys/conf.h>
49 1.1 minoura #include <sys/audioio.h>
50 1.1 minoura #include <sys/midiio.h>
51 1.1 minoura
52 1.1 minoura #include <machine/bus.h>
53 1.1 minoura
54 1.1 minoura #include <dev/audio_if.h>
55 1.1 minoura #include <dev/midi_if.h>
56 1.1 minoura
57 1.1 minoura #include <dev/pci/pcireg.h>
58 1.1 minoura #include <dev/pci/pcivar.h>
59 1.1 minoura
60 1.1 minoura #include <dev/ic/mpuvar.h>
61 1.1 minoura #include <dev/ic/ac97var.h>
62 1.1 minoura #include <dev/pci/ydsreg.h>
63 1.1 minoura #include <dev/pci/ydsvar.h>
64 1.1 minoura
65 1.7 kent static int mpu_yds_match(struct device *, struct cfdata *, void *);
66 1.7 kent static void mpu_yds_attach(struct device *, struct device *, void *);
67 1.1 minoura
68 1.4 thorpej CFATTACH_DECL(mpu_yds, sizeof (struct mpu_softc),
69 1.5 thorpej mpu_yds_match, mpu_yds_attach, NULL, NULL);
70 1.1 minoura
71 1.1 minoura static int
72 1.7 kent mpu_yds_match(struct device *parent, struct cfdata *match, void *aux)
73 1.1 minoura {
74 1.1 minoura struct audio_attach_args *aa = (struct audio_attach_args *)aux;
75 1.1 minoura struct yds_softc *ysc = (struct yds_softc *)parent;
76 1.1 minoura struct mpu_softc sc;
77 1.1 minoura
78 1.1 minoura if (aa->type != AUDIODEV_TYPE_MPU)
79 1.1 minoura return (0);
80 1.1 minoura memset(&sc, 0, sizeof sc);
81 1.1 minoura sc.ioh = ysc->sc_mpu_ioh;
82 1.1 minoura sc.iot = ysc->sc_mpu_iot;
83 1.1 minoura return (mpu_find(&sc));
84 1.1 minoura }
85 1.1 minoura
86 1.1 minoura static void
87 1.7 kent mpu_yds_attach(struct device *parent, struct device *self, void *aux)
88 1.1 minoura {
89 1.1 minoura struct yds_softc *ysc = (struct yds_softc *)parent;
90 1.1 minoura struct mpu_softc *sc = (struct mpu_softc *)self;
91 1.1 minoura
92 1.8 xtraeme printf("\n");
93 1.8 xtraeme
94 1.1 minoura sc->ioh = ysc->sc_mpu_ioh;
95 1.1 minoura sc->iot = ysc->sc_mpu_iot;
96 1.1 minoura sc->model = "Yamaha DS-1 MIDI UART";
97 1.1 minoura #ifndef AUDIO_NO_POWER_CTL
98 1.1 minoura sc->powerctl = 0;
99 1.1 minoura #endif
100 1.1 minoura
101 1.1 minoura mpu_attach(sc);
102 1.1 minoura }
103