melody.c revision 1.13
11.13Slukem/*	$NetBSD: melody.c,v 1.13 2007/09/07 10:34:58 lukem 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.13Slukem__KERNEL_RCSID(0, "$NetBSD: melody.c,v 1.13 2007/09/07 10:34:58 lukem 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.13Slukem	uint8_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.11SthorpejCFATTACH_DECL(melody, sizeof(struct melody_softc),
751.11Sthorpej    melody_match, melody_attach, NULL, NULL);
761.1Sis
771.1Sisint
781.8Saymericmelody_match(struct device *parent, struct cfdata *cfp, void *aux)
791.1Sis{
801.1Sis	struct zbus_args *zap;
811.8Saymeric
821.1Sis	zap = aux;
831.1Sis	if (zap->manid != 2145)
841.1Sis		return (0);
851.1Sis
861.1Sis	if (zap->prodid != 128)
871.1Sis		return (0);
881.1Sis
891.1Sis	return (1);
901.1Sis}
911.1Sis
921.1Sisvoid
931.8Saymericmelody_attach(struct device *parent, struct device *self, void *aux)
941.1Sis{
951.1Sis	struct melody_softc *sc;
961.1Sis	struct zbus_args *zap;
971.1Sis	bus_space_tag_t iot;
981.1Sis	bus_space_handle_t ioh;
991.1Sis
1001.1Sis	sc = (struct melody_softc *)self;
1011.1Sis	zap = aux;
1021.1Sis
1031.1Sis	sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
1041.7Saymeric	sc->sc_bst_leftbyte.absm = &amiga_bus_stride_2;
1051.13Slukem	sc->sc_intack = (uint8_t *)zap->va + 0xc000;
1061.1Sis
1071.1Sis	/* set up board specific part in sc_tav */
1081.1Sis
1091.1Sis	iot = &sc->sc_bst_leftbyte;
1101.1Sis
1111.1Sis	if (bus_space_map(iot, 0, 128, 0, &ioh)) {
1121.1Sis		panic("melody: cant bus_space_map");
1131.1Sis		/* NOTREACHED */
1141.1Sis	}
1151.1Sis	sc->sc_tav.sc_iot = iot;
1161.1Sis	sc->sc_tav.sc_ioh = ioh;
1171.1Sis	sc->sc_tav.sc_pcm_ord = 0;
1181.1Sis	sc->sc_tav.sc_pcm_18 = 0;
1191.1Sis	sc->sc_tav.sc_dif = 0;
1201.1Sis	sc->sc_tav.sc_pcm_div = 12;
1211.1Sis
1221.1Sis	/*
1231.1Sis	 * Attach option boards now. They might provide additional
1241.1Sis	 * functionality to our audio part.
1251.1Sis	 */
1261.1Sis
1271.1Sis	/* attach our audio driver */
1281.8Saymeric
1291.1Sis	printf(" #%d", zap->serno);
1301.1Sis	tms320av110_attach_mi(&sc->sc_tav);
1311.1Sis	sc->sc_isr.isr_ipl = 6;
1321.1Sis	sc->sc_isr.isr_arg = &sc->sc_tav;
1331.1Sis	sc->sc_isr.isr_intr = tms320av110_intr;
1341.1Sis	add_isr(&sc->sc_isr);
1351.1Sis}
1361.1Sis
1371.1Sisvoid
1381.8Saymericmelody_intack(struct tav_softc *p)
1391.1Sis{
1401.1Sis	struct melody_softc *sc;
1411.1Sis
1421.1Sis	sc = (struct melody_softc *)p;
1431.8Saymeric	*sc->sc_intack = 0;
1441.1Sis}
145