melody.c revision 1.8
11.8Saymeric/*	$NetBSD: melody.c,v 1.8 2002/01/26 13:40:58 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.8Saymeric#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.8Saymericint melody_match(struct device *, struct cfdata *, void *);
681.8Saymericvoid melody_attach(struct device *, struct device *, void *);
691.8Saymericvoid melody_intack(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.8Saymericmelody_match(struct device *parent, struct cfdata *cfp, void *aux)
771.1Sis{
781.1Sis	struct zbus_args *zap;
791.8Saymeric
801.1Sis	zap = aux;
811.1Sis	if (zap->manid != 2145)
821.1Sis		return (0);
831.1Sis
841.1Sis	if (zap->prodid != 128)
851.1Sis		return (0);
861.1Sis
871.1Sis	return (1);
881.1Sis}
891.1Sis
901.1Sisvoid
911.8Saymericmelody_attach(struct device *parent, struct device *self, void *aux)
921.1Sis{
931.1Sis	struct melody_softc *sc;
941.1Sis	struct zbus_args *zap;
951.1Sis	bus_space_tag_t iot;
961.1Sis	bus_space_handle_t ioh;
971.1Sis
981.1Sis	sc = (struct melody_softc *)self;
991.1Sis	zap = aux;
1001.1Sis
1011.1Sis	sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
1021.7Saymeric	sc->sc_bst_leftbyte.absm = &amiga_bus_stride_2;
1031.3Stron	sc->sc_intack = (caddr_t)zap->va + 0xc000;
1041.1Sis
1051.1Sis	/* set up board specific part in sc_tav */
1061.1Sis
1071.1Sis	iot = &sc->sc_bst_leftbyte;
1081.1Sis
1091.1Sis	if (bus_space_map(iot, 0, 128, 0, &ioh)) {
1101.1Sis		panic("melody: cant bus_space_map");
1111.1Sis		/* NOTREACHED */
1121.1Sis	}
1131.1Sis	sc->sc_tav.sc_iot = iot;
1141.1Sis	sc->sc_tav.sc_ioh = ioh;
1151.1Sis	sc->sc_tav.sc_pcm_ord = 0;
1161.1Sis	sc->sc_tav.sc_pcm_18 = 0;
1171.1Sis	sc->sc_tav.sc_dif = 0;
1181.1Sis	sc->sc_tav.sc_pcm_div = 12;
1191.1Sis
1201.1Sis	/*
1211.1Sis	 * Attach option boards now. They might provide additional
1221.1Sis	 * functionality to our audio part.
1231.1Sis	 */
1241.1Sis
1251.1Sis	/* attach our audio driver */
1261.8Saymeric
1271.1Sis	printf(" #%d", zap->serno);
1281.1Sis	tms320av110_attach_mi(&sc->sc_tav);
1291.1Sis	sc->sc_isr.isr_ipl = 6;
1301.1Sis	sc->sc_isr.isr_arg = &sc->sc_tav;
1311.1Sis	sc->sc_isr.isr_intr = tms320av110_intr;
1321.1Sis	add_isr(&sc->sc_isr);
1331.1Sis}
1341.1Sis
1351.1Sisvoid
1361.8Saymericmelody_intack(struct tav_softc *p)
1371.1Sis{
1381.1Sis	struct melody_softc *sc;
1391.1Sis
1401.1Sis	sc = (struct melody_softc *)p;
1411.8Saymeric	*sc->sc_intack = 0;
1421.1Sis}
143