1 /* $NetBSD: ess_isa.c,v 1.22 2009/05/05 12:07:15 cegger Exp $ */
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Nathan J. Williams.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: ess_isa.c,v 1.22 2009/05/05 12:07:15 cegger Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
42 #include <dev/isa/isavar.h>
44 #include <dev/isa/essreg.h>
45 #include <dev/isa/essvar.h>
50 #define DPRINTF(x) printf x
55 int ess_isa_probe(device_t
, cfdata_t
, void *);
56 void ess_isa_attach(device_t
, device_t
, void *);
58 CFATTACH_DECL(ess_isa
, sizeof(struct ess_softc
),
59 ess_isa_probe
, ess_isa_attach
, NULL
, NULL
);
62 ess_isa_probe(device_t parent
, cfdata_t match
, void *aux
)
65 struct isa_attach_args
*ia
;
66 struct ess_softc probesc
, *sc
;
77 if (ISA_DIRECT_CONFIG(ia
))
80 memset(sc
, 0, sizeof *sc
);
82 sc
->sc_ic
= ia
->ia_ic
;
83 sc
->sc_iot
= ia
->ia_iot
;
84 sc
->sc_iobase
= ia
->ia_io
[0].ir_addr
;
85 if (bus_space_map(sc
->sc_iot
, sc
->sc_iobase
, ESS_NPORT
, 0,
87 DPRINTF(("ess_isa_probe: Couldn't map I/O region at %x, "
88 "size %x\n", sc
->sc_iobase
, ESS_NPORT
));
92 sc
->sc_audio1
.irq
= ia
->ia_irq
[0].ir_irq
;
93 sc
->sc_audio1
.ist
= IST_EDGE
;
94 sc
->sc_audio1
.drq
= ia
->ia_drq
[0].ir_drq
;
95 sc
->sc_audio2
.irq
= -1;
96 sc
->sc_audio2
.drq
= (ia
->ia_ndrq
> 1) ? ia
->ia_drq
[1].ir_drq
: -1;
100 bus_space_unmap(sc
->sc_iot
, sc
->sc_ioh
, ESS_NPORT
);
103 DPRINTF(("ess_isa_probe succeeded (score %d)\n", ret
));
105 ia
->ia_io
[0].ir_size
= ESS_NPORT
;
109 if (ia
->ia_ndrq
> 1 &&
110 ia
->ia_drq
[1].ir_drq
!= ISA_UNKNOWN_DRQ
)
117 DPRINTF(("ess_isa_probe failed\n"));
123 ess_isa_attach(device_t parent
, device_t self
, void *aux
)
125 struct ess_softc
*sc
;
126 struct isa_attach_args
*ia
;
129 sc
= device_private(self
);
136 sc
->sc_ic
= ia
->ia_ic
;
137 sc
->sc_iot
= ia
->ia_iot
;
138 sc
->sc_iobase
= ia
->ia_io
[0].ir_addr
;
139 if (bus_space_map(sc
->sc_iot
, sc
->sc_iobase
, ESS_NPORT
, 0,
141 DPRINTF(("ess_isa_attach: Couldn't map I/O region at %x, "
142 "size %x\n", sc
->sc_iobase
, ESS_NPORT
));
146 sc
->sc_audio1
.irq
= ia
->ia_irq
[0].ir_irq
;
147 sc
->sc_audio1
.ist
= IST_EDGE
;
148 sc
->sc_audio1
.drq
= ia
->ia_drq
[0].ir_drq
;
149 sc
->sc_audio2
.irq
= -1;
150 sc
->sc_audio2
.drq
= ia
->ia_ndrq
> 1 ? ia
->ia_drq
[1].ir_drq
: -1;
153 if (device_cfdata(self
)->cf_flags
& 1) {
154 sc
->sc_joy_iot
= ia
->ia_iot
;
155 if (!bus_space_map(sc
->sc_joy_iot
, 0x201, 1, 0,
161 aprint_normal_dev(self
, "");
163 essattach(sc
, enablejoy
);