1 /* $NetBSD: ess_pnpbios.c,v 1.23 2019/05/08 13:40:15 isaki Exp $ */ 2 3 /*- 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Nathan J. Williams. 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 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 __KERNEL_RCSID(0, "$NetBSD: ess_pnpbios.c,v 1.23 2019/05/08 13:40:15 isaki Exp $"); 34 35 #include <sys/param.h> 36 #include <sys/systm.h> 37 #include <sys/errno.h> 38 #include <sys/ioctl.h> 39 #include <sys/syslog.h> 40 #include <sys/device.h> 41 #include <sys/proc.h> 42 43 #include <sys/bus.h> 44 45 #include <sys/audioio.h> 46 #include <dev/audio/audio_if.h> 47 #include <dev/midi_if.h> 48 49 #include <dev/isa/isavar.h> 50 #include <dev/isa/isadmavar.h> 51 52 #include <i386/pnpbios/pnpbiosvar.h> 53 54 #include <dev/isa/essreg.h> 55 #include <dev/isa/essvar.h> 56 57 int ess_pnpbios_match(device_t, cfdata_t, void *); 58 void ess_pnpbios_attach(device_t, device_t, void *); 59 60 CFATTACH_DECL_NEW(ess_pnpbios, sizeof(struct ess_softc), 61 ess_pnpbios_match, ess_pnpbios_attach, NULL, NULL); 62 63 int 64 ess_pnpbios_match(device_t parent, cfdata_t match, void *aux) 65 { 66 struct pnpbiosdev_attach_args *aa = aux; 67 68 if (strcmp(aa->idstr, "ESS0104") && /* 1788 */ 69 strcmp(aa->idstr, "ESS0114") && /* 1788 */ 70 strcmp(aa->idstr, "CPQAE27") && /* 1788 */ 71 strcmp(aa->idstr, "ESS1869") && /* 1869 */ 72 strcmp(aa->idstr, "CPQB0AB") && /* 1869 */ 73 strcmp(aa->idstr, "CPQB0AC") && /* 1869 */ 74 strcmp(aa->idstr, "CPQB0AD") && /* 1869 */ 75 strcmp(aa->idstr, "CPQB0F1") && /* 1869 */ 76 strcmp(aa->idstr, "ESS1878") && /* 1878 */ 77 strcmp(aa->idstr, "ESS1879")) /* 1879 */ 78 return (0); 79 80 return (1); 81 } 82 83 void 84 ess_pnpbios_attach(device_t parent, device_t self, void *aux) 85 { 86 struct ess_softc *sc = device_private(self); 87 struct pnpbiosdev_attach_args *aa = aux; 88 89 sc->sc_dev = self; 90 91 if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) { 92 aprint_error(": can't map i/o space\n"); 93 return; 94 } 95 96 sc->sc_ic = aa->ic; 97 98 /* XXX These are only for setting chip configuration registers. */ 99 pnpbios_getiobase(aa->pbt, aa->resc, 0, 0, &sc->sc_iobase); 100 101 sc->sc_audio1.ist = IST_EDGE; 102 sc->sc_audio2.ist = IST_EDGE; 103 104 if (pnpbios_getirqnum(aa->pbt, aa->resc, 0, &sc->sc_audio1.irq, 105 NULL)) { 106 aprint_error(": can't get IRQ\n"); 107 return; 108 } 109 110 if (pnpbios_getirqnum(aa->pbt, aa->resc, 1, &sc->sc_audio2.irq, 111 NULL)) 112 sc->sc_audio2.irq = -1; 113 114 if (pnpbios_getdmachan(aa->pbt, aa->resc, 0, &sc->sc_audio1.drq)) { 115 aprint_error(": can't get DMA channel\n"); 116 return; 117 } 118 119 if (pnpbios_getdmachan(aa->pbt, aa->resc, 1, &sc->sc_audio2.drq)) 120 sc->sc_audio2.drq = -1; 121 122 aprint_naive("\n"); 123 aprint_normal("\n"); 124 pnpbios_print_devres(self, aa); 125 126 aprint_normal_dev(self, ""); 127 128 if (!essmatch(sc)) { 129 aprint_error_dev(self, "essmatch failed\n"); 130 pnpbios_io_unmap(aa->pbt, aa->resc, 0, sc->sc_iot, sc->sc_ioh); 131 return; 132 } 133 134 essattach(sc, 0); 135 } 136