Home | History | Annotate | Line # | Download | only in isapnp
wss_isapnp.c revision 1.1
      1 /*	$NetBSD: wss_isapnp.c,v 1.1 1998/06/30 17:28:00 augustss Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Author: Lennart Augustsson
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *        This product includes software developed by the NetBSD
     20  *        Foundation, Inc. and its contributors.
     21  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22  *    contributors may be used to endorse or promote products derived
     23  *    from this software without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 #include <sys/param.h>
     39 #include <sys/systm.h>
     40 #include <sys/errno.h>
     41 #include <sys/ioctl.h>
     42 #include <sys/syslog.h>
     43 #include <sys/device.h>
     44 #include <sys/proc.h>
     45 
     46 #include <machine/bus.h>
     47 
     48 #include <sys/audioio.h>
     49 #include <dev/audio_if.h>
     50 
     51 #include <dev/isa/isavar.h>
     52 #include <dev/isa/isadmavar.h>
     53 
     54 #include <dev/isapnp/isapnpreg.h>
     55 #include <dev/isapnp/isapnpvar.h>
     56 
     57 #include <dev/isa/ad1848var.h>
     58 #include <dev/isa/madreg.h>
     59 #include <dev/isa/wssreg.h>
     60 #include <dev/isa/wssvar.h>
     61 
     62 int	wss_isapnp_match __P((struct device *, struct cfdata *, void *));
     63 void	wss_isapnp_attach __P((struct device *, struct device *, void *));
     64 
     65 struct cfattach wss_isapnp_ca = {
     66 	sizeof(struct wss_softc), wss_isapnp_match, wss_isapnp_attach
     67 };
     68 
     69 
     70 /*
     71  * Probe / attach routines.
     72  */
     73 
     74 /*
     75  * Probe for the WSS hardware.
     76  */
     77 int
     78 wss_isapnp_match(parent, match, aux)
     79 	struct device *parent;
     80 	struct cfdata *match;
     81 	void *aux;
     82 {
     83 	struct isapnp_attach_args *ipa = aux;
     84 
     85 	if (strcmp(ipa->ipa_devlogic, "CSC0000") == 0)
     86 		return (1);
     87 
     88 	return (0);
     89 }
     90 
     91 
     92 
     93 /*
     94  * Attach hardware to driver, attach hardware driver to audio
     95  * pseudo-device driver.
     96  */
     97 void
     98 wss_isapnp_attach(parent, self, aux)
     99 	struct device *parent, *self;
    100 	void *aux;
    101 {
    102 	struct wss_softc *sc = (struct wss_softc *)self;
    103 	struct isapnp_attach_args *ipa = aux;
    104 
    105 	printf("\n");
    106 
    107 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
    108 		printf("%s: error in region allocation\n",
    109 		       sc->sc_dev.dv_xname);
    110 		return;
    111 	}
    112 
    113 	sc->sc_iot = ipa->ipa_iot;
    114         sc->sc_ioh = ipa->ipa_io[1].h;
    115 
    116         sc->mad_chip_type = MAD_NONE;
    117 
    118 	/* Set up AD1848 I/O handle. */
    119 	sc->sc_ad1848.sc_ic  = ipa->ipa_ic;
    120 	sc->sc_ad1848.sc_iot = ipa->ipa_iot;
    121 	sc->sc_ad1848.sc_ioh = sc->sc_ioh;
    122 	sc->sc_ad1848.sc_iooffs = WSS_CODEC;
    123 	sc->sc_ad1848.mode = 2;
    124 
    125         sc->wss_ic  = ipa->ipa_ic;
    126 	sc->wss_irq = ipa->ipa_irq[0].num;
    127 	sc->wss_drq = ipa->ipa_drq[0].num;
    128 	sc->wss_recdrq =
    129 		ipa->ipa_ndrq > 1 ? ipa->ipa_drq[1].num : ipa->ipa_drq[0].num;
    130 
    131 	if (!ad1848_probe(&sc->sc_ad1848)) {
    132 		printf("%s: ad1848_probe failed\n", sc->sc_dev.dv_xname);
    133 		return;
    134 	}
    135 
    136 	printf("%s: %s %s", sc->sc_dev.dv_xname, ipa->ipa_devident,
    137 	       ipa->ipa_devclass);
    138 
    139 	wssattach(sc);
    140 }
    141