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