melody.c revision 1.9
11.9Saymeric/*	$NetBSD: melody.c,v 1.9 2002/01/28 09:57:01 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.9Saymeric
391.9Saymeric#include <sys/cdefs.h>
401.9Saymeric__KERNEL_RCSID(0, "$NetBSD: melody.c,v 1.9 2002/01/28 09:57:01 aymeric Exp $");
411.1Sis
421.1Sis/*
431.1Sis * Melody audio driver.
441.1Sis *
451.1Sis * Currently, only minimum support for audio output. For audio/video
461.1Sis * synchronization, more is needed.
471.1Sis */
481.1Sis
491.1Sis#include <sys/types.h>
501.1Sis#include <sys/param.h>
511.1Sis#include <sys/systm.h>
521.1Sis#include <sys/kernel.h>
531.8Saymeric#include <sys/device.h>
541.1Sis
551.1Sis#include <dev/ic/tms320av110reg.h>
561.1Sis#include <dev/ic/tms320av110var.h>
571.1Sis
581.1Sis#include <machine/bus.h>
591.1Sis
601.1Sis#include <amiga/dev/zbusvar.h>
611.1Sis#include <amiga/amiga/isr.h>
621.1Sis
631.1Sisstruct melody_softc {
641.1Sis	struct tav_softc	sc_tav;
651.1Sis	struct bus_space_tag	sc_bst_leftbyte;
661.1Sis	struct isr		sc_isr;
671.1Sis	caddr_t			sc_intack;
681.1Sis};
691.1Sis
701.8Saymericint melody_match(struct device *, struct cfdata *, void *);
711.8Saymericvoid melody_attach(struct device *, struct device *, void *);
721.8Saymericvoid melody_intack(struct tav_softc *);
731.1Sis
741.1Sisstruct cfattach melody_ca = {
751.1Sis        sizeof(struct melody_softc), melody_match, melody_attach
761.1Sis};
771.1Sis
781.1Sisint
791.8Saymericmelody_match(struct device *parent, struct cfdata *cfp, void *aux)
801.1Sis{
811.1Sis	struct zbus_args *zap;
821.8Saymeric
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.8Saymericmelody_attach(struct device *parent, struct device *self, void *aux)
951.1Sis{
961.1Sis	struct melody_softc *sc;
971.1Sis	struct zbus_args *zap;
981.1Sis	bus_space_tag_t iot;
991.1Sis	bus_space_handle_t ioh;
1001.1Sis
1011.1Sis	sc = (struct melody_softc *)self;
1021.1Sis	zap = aux;
1031.1Sis
1041.1Sis	sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
1051.7Saymeric	sc->sc_bst_leftbyte.absm = &amiga_bus_stride_2;
1061.3Stron	sc->sc_intack = (caddr_t)zap->va + 0xc000;
1071.1Sis
1081.1Sis	/* set up board specific part in sc_tav */
1091.1Sis
1101.1Sis	iot = &sc->sc_bst_leftbyte;
1111.1Sis
1121.1Sis	if (bus_space_map(iot, 0, 128, 0, &ioh)) {
1131.1Sis		panic("melody: cant bus_space_map");
1141.1Sis		/* NOTREACHED */
1151.1Sis	}
1161.1Sis	sc->sc_tav.sc_iot = iot;
1171.1Sis	sc->sc_tav.sc_ioh = ioh;
1181.1Sis	sc->sc_tav.sc_pcm_ord = 0;
1191.1Sis	sc->sc_tav.sc_pcm_18 = 0;
1201.1Sis	sc->sc_tav.sc_dif = 0;
1211.1Sis	sc->sc_tav.sc_pcm_div = 12;
1221.1Sis
1231.1Sis	/*
1241.1Sis	 * Attach option boards now. They might provide additional
1251.1Sis	 * functionality to our audio part.
1261.1Sis	 */
1271.1Sis
1281.1Sis	/* attach our audio driver */
1291.8Saymeric
1301.1Sis	printf(" #%d", zap->serno);
1311.1Sis	tms320av110_attach_mi(&sc->sc_tav);
1321.1Sis	sc->sc_isr.isr_ipl = 6;
1331.1Sis	sc->sc_isr.isr_arg = &sc->sc_tav;
1341.1Sis	sc->sc_isr.isr_intr = tms320av110_intr;
1351.1Sis	add_isr(&sc->sc_isr);
1361.1Sis}
1371.1Sis
1381.1Sisvoid
1391.8Saymericmelody_intack(struct tav_softc *p)
1401.1Sis{
1411.1Sis	struct melody_softc *sc;
1421.1Sis
1431.1Sis	sc = (struct melody_softc *)p;
1441.8Saymeric	*sc->sc_intack = 0;
1451.1Sis}
146