[BACK]Return to ess_isa.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / dev / isa

Annotation of src/sys/dev/isa/ess_isa.c, Revision 1.18.22.1

1.18.22.1! joerg       1: /*     $NetBSD: ess_isa.c,v 1.18 2006/11/16 01:33:00 christos Exp $    */
1.1       nathanw     2:
                      3: /*-
                      4:  * Copyright (c) 1999 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:  * 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:
1.6       lukem      39: #include <sys/cdefs.h>
1.18.22.1! joerg      40: __KERNEL_RCSID(0, "$NetBSD: ess_isa.c,v 1.18 2006/11/16 01:33:00 christos Exp $");
1.1       nathanw    41:
                     42: #include <sys/param.h>
                     43: #include <sys/systm.h>
                     44: #include <sys/device.h>
                     45:
1.18.22.1! joerg      46: #include <sys/cpu.h>
        !            47: #include <sys/bus.h>
1.1       nathanw    48:
                     49: #include <dev/isa/isavar.h>
                     50:
                     51: #include <dev/isa/essreg.h>
                     52: #include <dev/isa/essvar.h>
                     53:
1.11      drochner   54: #include "joy_ess.h"
                     55:
1.1       nathanw    56: #ifdef ESS_ISA_DEBUG
                     57: #define DPRINTF(x)     printf x
                     58: #else
1.17      reinoud    59: #define DPRINTF(x)     {}
1.1       nathanw    60: #endif
                     61:
1.13      kent       62: int ess_isa_probe(struct device *, struct cfdata *, void *);
                     63: void ess_isa_attach(struct device *, struct device *, void *);
1.1       nathanw    64:
1.10      thorpej    65: CFATTACH_DECL(ess_isa, sizeof(struct ess_softc),
                     66:     ess_isa_probe, ess_isa_attach, NULL, NULL);
1.1       nathanw    67:
                     68: int
1.18      christos   69: ess_isa_probe(struct device *parent, struct cfdata *match,
1.16      christos   70:     void *aux)
1.1       nathanw    71: {
1.13      kent       72:        int ret;
                     73:        struct isa_attach_args *ia;
                     74:        struct ess_softc probesc, *sc;
1.7       thorpej    75:
1.13      kent       76:        ia = aux;
                     77:        sc= &probesc;
1.7       thorpej    78:        if (ia->ia_nio < 1)
1.13      kent       79:                return 0;
1.7       thorpej    80:        if (ia->ia_nirq < 1)
1.13      kent       81:                return 0;
1.7       thorpej    82:        if (ia->ia_ndrq < 1)
1.13      kent       83:                return 0;
1.7       thorpej    84:
                     85:        if (ISA_DIRECT_CONFIG(ia))
1.13      kent       86:                return 0;
1.7       thorpej    87:
1.1       nathanw    88:        memset(sc, 0, sizeof *sc);
                     89:
                     90:        sc->sc_ic = ia->ia_ic;
                     91:        sc->sc_iot = ia->ia_iot;
1.7       thorpej    92:        sc->sc_iobase = ia->ia_io[0].ir_addr;
                     93:        if (bus_space_map(sc->sc_iot, sc->sc_iobase, ESS_NPORT, 0,
                     94:            &sc->sc_ioh)) {
                     95:                DPRINTF(("ess_isa_probe: Couldn't map I/O region at %x, "
                     96:                    "size %x\n", sc->sc_iobase, ESS_NPORT));
                     97:                return 0;
1.1       nathanw    98:        }
                     99:
1.7       thorpej   100:        sc->sc_audio1.irq = ia->ia_irq[0].ir_irq;
1.2       mycroft   101:        sc->sc_audio1.ist = IST_EDGE;
1.7       thorpej   102:        sc->sc_audio1.drq = ia->ia_drq[0].ir_drq;
1.3       mycroft   103:        sc->sc_audio2.irq = -1;
1.7       thorpej   104:        sc->sc_audio2.drq = (ia->ia_ndrq > 1) ? ia->ia_drq[1].ir_drq : -1;
1.1       nathanw   105:
                    106:        ret = essmatch(sc);
1.13      kent      107:
1.1       nathanw   108:        bus_space_unmap(sc->sc_iot, sc->sc_ioh, ESS_NPORT);
                    109:
1.4       mycroft   110:        if (ret) {
1.1       nathanw   111:                DPRINTF(("ess_isa_probe succeeded (score %d)\n", ret));
1.7       thorpej   112:                ia->ia_nio = 1;
                    113:                ia->ia_io[0].ir_size = ESS_NPORT;
                    114:
                    115:                ia->ia_nirq = 1;
                    116:
                    117:                if (ia->ia_ndrq > 1 &&
1.12      drochner  118:                    ia->ia_drq[1].ir_drq != ISA_UNKNOWN_DRQ)
1.7       thorpej   119:                        ia->ia_ndrq = 2;
                    120:                else
                    121:                        ia->ia_ndrq = 1;
                    122:
                    123:                ia->ia_niomem = 0;
1.4       mycroft   124:        } else
1.5       augustss  125:                DPRINTF(("ess_isa_probe failed\n"));
1.13      kent      126:
1.1       nathanw   127:        return ret;
                    128: }
                    129:
1.13      kent      130: void
1.18      christos  131: ess_isa_attach(struct device *parent, struct device *self, void *aux)
1.1       nathanw   132: {
1.13      kent      133:        struct ess_softc *sc;
                    134:        struct isa_attach_args *ia;
                    135:        int enablejoy;
                    136:
                    137:        sc = (void *)self;
                    138:        ia = aux;
                    139:        enablejoy = 0;
1.1       nathanw   140:        printf("\n");
                    141:
                    142:        sc->sc_ic = ia->ia_ic;
                    143:        sc->sc_iot = ia->ia_iot;
1.7       thorpej   144:        sc->sc_iobase = ia->ia_io[0].ir_addr;
                    145:        if (bus_space_map(sc->sc_iot, sc->sc_iobase, ESS_NPORT, 0,
                    146:            &sc->sc_ioh)) {
                    147:                DPRINTF(("ess_isa_attach: Couldn't map I/O region at %x, "
                    148:                    "size %x\n", sc->sc_iobase, ESS_NPORT));
                    149:                return;
1.1       nathanw   150:        }
                    151:
1.7       thorpej   152:        sc->sc_audio1.irq = ia->ia_irq[0].ir_irq;
1.2       mycroft   153:        sc->sc_audio1.ist = IST_EDGE;
1.7       thorpej   154:        sc->sc_audio1.drq = ia->ia_drq[0].ir_drq;
1.3       mycroft   155:        sc->sc_audio2.irq = -1;
1.7       thorpej   156:        sc->sc_audio2.drq = ia->ia_ndrq > 1 ? ia->ia_drq[1].ir_drq : -1;
1.1       nathanw   157:
1.11      drochner  158: #if NJOY_ESS > 0
1.15      thorpej   159:        if (device_cfdata(&sc->sc_dev)->cf_flags & 1) {
1.11      drochner  160:                sc->sc_joy_iot = ia->ia_iot;
                    161:                if (!bus_space_map(sc->sc_joy_iot, 0x201, 1, 0,
                    162:                                   &sc->sc_joy_ioh))
                    163:                        enablejoy = 1;
                    164:        }
                    165: #endif
                    166:
1.3       mycroft   167:        printf("%s", sc->sc_dev.dv_xname);
1.1       nathanw   168:
1.11      drochner  169:        essattach(sc, enablejoy);
1.1       nathanw   170: }

CVSweb <webmaster@jp.NetBSD.org>