1 /* $NetBSD: melody.c,v 1.11 2002/10/02 04:55:52 thorpej 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.11 2002/10/02 04:55:52 thorpej 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 CFATTACH_DECL(melody, sizeof(struct melody_softc), 75 melody_match, melody_attach, NULL, NULL); 76 77 int 78 melody_match(struct device *parent, struct cfdata *cfp, void *aux) 79 { 80 struct zbus_args *zap; 81 82 zap = aux; 83 if (zap->manid != 2145) 84 return (0); 85 86 if (zap->prodid != 128) 87 return (0); 88 89 return (1); 90 } 91 92 void 93 melody_attach(struct device *parent, struct device *self, void *aux) 94 { 95 struct melody_softc *sc; 96 struct zbus_args *zap; 97 bus_space_tag_t iot; 98 bus_space_handle_t ioh; 99 100 sc = (struct melody_softc *)self; 101 zap = aux; 102 103 sc->sc_bst_leftbyte.base = (u_long)zap->va + 0; 104 sc->sc_bst_leftbyte.absm = &amiga_bus_stride_2; 105 sc->sc_intack = (caddr_t)zap->va + 0xc000; 106 107 /* set up board specific part in sc_tav */ 108 109 iot = &sc->sc_bst_leftbyte; 110 111 if (bus_space_map(iot, 0, 128, 0, &ioh)) { 112 panic("melody: cant bus_space_map"); 113 /* NOTREACHED */ 114 } 115 sc->sc_tav.sc_iot = iot; 116 sc->sc_tav.sc_ioh = ioh; 117 sc->sc_tav.sc_pcm_ord = 0; 118 sc->sc_tav.sc_pcm_18 = 0; 119 sc->sc_tav.sc_dif = 0; 120 sc->sc_tav.sc_pcm_div = 12; 121 122 /* 123 * Attach option boards now. They might provide additional 124 * functionality to our audio part. 125 */ 126 127 /* attach our audio driver */ 128 129 printf(" #%d", zap->serno); 130 tms320av110_attach_mi(&sc->sc_tav); 131 sc->sc_isr.isr_ipl = 6; 132 sc->sc_isr.isr_arg = &sc->sc_tav; 133 sc->sc_isr.isr_intr = tms320av110_intr; 134 add_isr(&sc->sc_isr); 135 } 136 137 void 138 melody_intack(struct tav_softc *p) 139 { 140 struct melody_softc *sc; 141 142 sc = (struct melody_softc *)p; 143 *sc->sc_intack = 0; 144 } 145