melody.c revision 1.7
11.7Saymeric/*	$NetBSD: melody.c,v 1.7 2000/01/23 21:06:13 aymeric Exp $	*/
21.1Sis
31.1Sis/*-
41.5Sis * Copyright (c) 1997 The NetBSD Foundation, Inc.
51.4Sis * All rights reserved.
61.4Sis *
71.4Sis * This code is derived from software contributed to The NetBSD Foundation
81.4Sis * by Ignatios Souvatzis.
91.1Sis *
101.1Sis * Redistribution and use in source and binary forms, with or without
111.1Sis * modification, are permitted provided that the following conditions
121.1Sis * are met:
131.1Sis * 1. Redistributions of source code must retain the above copyright
141.1Sis *    notice, this list of conditions and the following disclaimer.
151.1Sis * 2. Redistributions in binary form must reproduce the above copyright
161.1Sis *    notice, this list of conditions and the following disclaimer in the
171.1Sis *    documentation and/or other materials provided with the distribution.
181.4Sis * 3. All advertising materials mentioning features or use of this software
191.4Sis *    must display the following acknowledgement:
201.4Sis *        This product includes software developed by the NetBSD
211.4Sis *        Foundation, Inc. and its contributors.
221.4Sis * 4. Neither the name of The NetBSD Foundation nor the names of its
231.4Sis *    contributors may be used to endorse or promote products derived
241.4Sis *    from this software without specific prior written permission.
251.1Sis *
261.4Sis * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.4Sis * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.4Sis * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.4Sis * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.4Sis * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.4Sis * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.4Sis * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.4Sis * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.4Sis * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.4Sis * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.4Sis * POSSIBILITY OF SUCH DAMAGE.
371.1Sis */
381.1Sis
391.1Sis/*
401.1Sis * Melody audio driver.
411.1Sis *
421.1Sis * Currently, only minimum support for audio output. For audio/video
431.1Sis * synchronization, more is needed.
441.1Sis */
451.1Sis
461.1Sis#include <sys/types.h>
471.1Sis#include <sys/param.h>
481.1Sis#include <sys/systm.h>
491.1Sis#include <sys/kernel.h>
501.1Sis#include <sys/device.h>
511.1Sis
521.1Sis#include <dev/ic/tms320av110reg.h>
531.1Sis#include <dev/ic/tms320av110var.h>
541.1Sis
551.1Sis#include <machine/bus.h>
561.1Sis
571.1Sis#include <amiga/dev/zbusvar.h>
581.1Sis#include <amiga/amiga/isr.h>
591.1Sis
601.1Sisstruct melody_softc {
611.1Sis	struct tav_softc	sc_tav;
621.1Sis	struct bus_space_tag	sc_bst_leftbyte;
631.1Sis	struct isr		sc_isr;
641.1Sis	caddr_t			sc_intack;
651.1Sis};
661.1Sis
671.1Sisint melody_match __P((struct device *, struct cfdata *, void *));
681.1Sisvoid melody_attach __P((struct device *, struct device *, void *));
691.1Sisvoid melody_intack __P((struct tav_softc *));
701.1Sis
711.1Sisstruct cfattach melody_ca = {
721.1Sis        sizeof(struct melody_softc), melody_match, melody_attach
731.1Sis};
741.1Sis
751.1Sisint
761.1Sismelody_match(parent, cfp, aux)
771.1Sis	struct device *parent;
781.1Sis	struct cfdata *cfp;
791.1Sis	void *aux;
801.1Sis{
811.1Sis	struct zbus_args *zap;
821.1Sis
831.1Sis	zap = aux;
841.1Sis	if (zap->manid != 2145)
851.1Sis		return (0);
861.1Sis
871.1Sis	if (zap->prodid != 128)
881.1Sis		return (0);
891.1Sis
901.1Sis	return (1);
911.1Sis}
921.1Sis
931.1Sisvoid
941.1Sismelody_attach(parent, self, aux)
951.1Sis	struct device *parent, *self;
961.1Sis	void *aux;
971.1Sis{
981.1Sis	struct melody_softc *sc;
991.1Sis	struct zbus_args *zap;
1001.1Sis	bus_space_tag_t iot;
1011.1Sis	bus_space_handle_t ioh;
1021.1Sis
1031.1Sis	sc = (struct melody_softc *)self;
1041.1Sis	zap = aux;
1051.1Sis
1061.1Sis	sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
1071.7Saymeric	sc->sc_bst_leftbyte.absm = &amiga_bus_stride_2;
1081.3Stron	sc->sc_intack = (caddr_t)zap->va + 0xc000;
1091.1Sis
1101.1Sis	/* set up board specific part in sc_tav */
1111.1Sis
1121.1Sis	iot = &sc->sc_bst_leftbyte;
1131.1Sis
1141.1Sis	if (bus_space_map(iot, 0, 128, 0, &ioh)) {
1151.1Sis		panic("melody: cant bus_space_map");
1161.1Sis		/* NOTREACHED */
1171.1Sis	}
1181.1Sis	sc->sc_tav.sc_iot = iot;
1191.1Sis	sc->sc_tav.sc_ioh = ioh;
1201.1Sis	sc->sc_tav.sc_pcm_ord = 0;
1211.1Sis	sc->sc_tav.sc_pcm_18 = 0;
1221.1Sis	sc->sc_tav.sc_dif = 0;
1231.1Sis	sc->sc_tav.sc_pcm_div = 12;
1241.1Sis
1251.1Sis	/*
1261.1Sis	 * Attach option boards now. They might provide additional
1271.1Sis	 * functionality to our audio part.
1281.1Sis	 */
1291.1Sis
1301.1Sis	/* attach our audio driver */
1311.1Sis
1321.1Sis	printf(" #%d", zap->serno);
1331.1Sis	tms320av110_attach_mi(&sc->sc_tav);
1341.1Sis	sc->sc_isr.isr_ipl = 6;
1351.1Sis	sc->sc_isr.isr_arg = &sc->sc_tav;
1361.1Sis	sc->sc_isr.isr_intr = tms320av110_intr;
1371.1Sis	add_isr(&sc->sc_isr);
1381.1Sis}
1391.1Sis
1401.1Sisvoid
1411.1Sismelody_intack(p)
1421.1Sis	struct tav_softc *p;
1431.1Sis{
1441.1Sis	struct melody_softc *sc;
1451.1Sis
1461.1Sis	sc = (struct melody_softc *)p;
1471.1Sis	*sc->sc_intack = 0;
1481.1Sis}
149