1 /* $NetBSD: melody.c,v 1.9 2002/01/28 09:57:01 aymeric 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 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include <sys/cdefs.h> 40 __KERNEL_RCSID(0, "$NetBSD: melody.c,v 1.9 2002/01/28 09:57:01 aymeric Exp $"); 41 42 /* 43 * Melody audio driver. 44 * 45 * Currently, only minimum support for audio output. For audio/video 46 * synchronization, more is needed. 47 */ 48 49 #include <sys/types.h> 50 #include <sys/param.h> 51 #include <sys/systm.h> 52 #include <sys/kernel.h> 53 #include <sys/device.h> 54 55 #include <dev/ic/tms320av110reg.h> 56 #include <dev/ic/tms320av110var.h> 57 58 #include <machine/bus.h> 59 60 #include <amiga/dev/zbusvar.h> 61 #include <amiga/amiga/isr.h> 62 63 struct melody_softc { 64 struct tav_softc sc_tav; 65 struct bus_space_tag sc_bst_leftbyte; 66 struct isr sc_isr; 67 caddr_t sc_intack; 68 }; 69 70 int melody_match(struct device *, struct cfdata *, void *); 71 void melody_attach(struct device *, struct device *, void *); 72 void melody_intack(struct tav_softc *); 73 74 struct cfattach melody_ca = { 75 sizeof(struct melody_softc), melody_match, melody_attach 76 }; 77 78 int 79 melody_match(struct device *parent, struct cfdata *cfp, void *aux) 80 { 81 struct zbus_args *zap; 82 83 zap = aux; 84 if (zap->manid != 2145) 85 return (0); 86 87 if (zap->prodid != 128) 88 return (0); 89 90 return (1); 91 } 92 93 void 94 melody_attach(struct device *parent, struct device *self, void *aux) 95 { 96 struct melody_softc *sc; 97 struct zbus_args *zap; 98 bus_space_tag_t iot; 99 bus_space_handle_t ioh; 100 101 sc = (struct melody_softc *)self; 102 zap = aux; 103 104 sc->sc_bst_leftbyte.base = (u_long)zap->va + 0; 105 sc->sc_bst_leftbyte.absm = &amiga_bus_stride_2; 106 sc->sc_intack = (caddr_t)zap->va + 0xc000; 107 108 /* set up board specific part in sc_tav */ 109 110 iot = &sc->sc_bst_leftbyte; 111 112 if (bus_space_map(iot, 0, 128, 0, &ioh)) { 113 panic("melody: cant bus_space_map"); 114 /* NOTREACHED */ 115 } 116 sc->sc_tav.sc_iot = iot; 117 sc->sc_tav.sc_ioh = ioh; 118 sc->sc_tav.sc_pcm_ord = 0; 119 sc->sc_tav.sc_pcm_18 = 0; 120 sc->sc_tav.sc_dif = 0; 121 sc->sc_tav.sc_pcm_div = 12; 122 123 /* 124 * Attach option boards now. They might provide additional 125 * functionality to our audio part. 126 */ 127 128 /* attach our audio driver */ 129 130 printf(" #%d", zap->serno); 131 tms320av110_attach_mi(&sc->sc_tav); 132 sc->sc_isr.isr_ipl = 6; 133 sc->sc_isr.isr_arg = &sc->sc_tav; 134 sc->sc_isr.isr_intr = tms320av110_intr; 135 add_isr(&sc->sc_isr); 136 } 137 138 void 139 melody_intack(struct tav_softc *p) 140 { 141 struct melody_softc *sc; 142 143 sc = (struct melody_softc *)p; 144 *sc->sc_intack = 0; 145 } 146