xref: /netbsd-src/sys/arch/amiga/dev/melody.c (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1 /*	$NetBSD: melody.c,v 1.1 1997/10/16 23:58:31 is Exp $	*/
2 
3 /*-
4  * Copyright (c) 1997 Ignatios Souvatzis. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the author nor the names of contributors
15  *    may be used to endorse or promote products derived from this software
16  *    without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 /*
32  * Melody audio driver.
33  *
34  * Currently, only minimum support for audio output. For audio/video
35  * synchronization, more is needed.
36  */
37 
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/device.h>
43 
44 #include <dev/ic/tms320av110reg.h>
45 #include <dev/ic/tms320av110var.h>
46 
47 #include <machine/bus.h>
48 
49 #include <amiga/dev/zbusvar.h>
50 #include <amiga/amiga/isr.h>
51 
52 struct melody_softc {
53 	struct tav_softc	sc_tav;
54 	struct bus_space_tag	sc_bst_leftbyte;
55 	struct isr		sc_isr;
56 	caddr_t			sc_intack;
57 };
58 
59 int melody_match __P((struct device *, struct cfdata *, void *));
60 void melody_attach __P((struct device *, struct device *, void *));
61 void melody_intack __P((struct tav_softc *));
62 
63 struct cfattach melody_ca = {
64         sizeof(struct melody_softc), melody_match, melody_attach
65 };
66 
67 struct cfdriver melody_cd = {
68 	NULL, "melody", DV_DULL
69 };
70 
71 int
72 melody_match(parent, cfp, aux)
73 	struct device *parent;
74 	struct cfdata *cfp;
75 	void *aux;
76 {
77 	struct zbus_args *zap;
78 
79 	zap = aux;
80 	if (zap->manid != 2145)
81 		return (0);
82 
83 	if (zap->prodid != 128)
84 		return (0);
85 
86 	return (1);
87 }
88 
89 void
90 melody_attach(parent, self, aux)
91 	struct device *parent, *self;
92 	void *aux;
93 {
94 	struct melody_softc *sc;
95 	struct zbus_args *zap;
96 	bus_space_tag_t iot;
97 	bus_space_handle_t ioh;
98 
99 	sc = (struct melody_softc *)self;
100 	zap = aux;
101 
102 	sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
103 	sc->sc_bst_leftbyte.stride = 1;
104 	sc->sc_intack = zap->va + 0xc000;
105 
106 	/* set up board specific part in sc_tav */
107 
108 	iot = &sc->sc_bst_leftbyte;
109 
110 	if (bus_space_map(iot, 0, 128, 0, &ioh)) {
111 		panic("melody: cant bus_space_map");
112 		/* NOTREACHED */
113 	}
114 	sc->sc_tav.sc_iot = iot;
115 	sc->sc_tav.sc_ioh = ioh;
116 	sc->sc_tav.sc_pcm_ord = 0;
117 	sc->sc_tav.sc_pcm_18 = 0;
118 	sc->sc_tav.sc_dif = 0;
119 	sc->sc_tav.sc_pcm_div = 12;
120 
121 	/*
122 	 * Attach option boards now. They might provide additional
123 	 * functionality to our audio part.
124 	 */
125 
126 	/* attach our audio driver */
127 
128 	printf(" #%d", zap->serno);
129 	tms320av110_attach_mi(&sc->sc_tav);
130 	sc->sc_isr.isr_ipl = 6;
131 	sc->sc_isr.isr_arg = &sc->sc_tav;
132 	sc->sc_isr.isr_intr = tms320av110_intr;
133 	add_isr(&sc->sc_isr);
134 }
135 
136 void
137 melody_intack(p)
138 	struct tav_softc *p;
139 {
140 	struct melody_softc *sc;
141 
142 	sc = (struct melody_softc *)p;
143 	*sc->sc_intack = 0;
144 }
145