1 /* $NetBSD: tsdio.c,v 1.9 2009/05/12 08:44:20 cegger Exp $ */
4 * Copyright (c) 2005 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
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: tsdio.c,v 1.9 2009/05/12 08:44:20 cegger Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
42 #include <dev/isa/isareg.h>
43 #include <dev/isa/isavar.h>
44 #include <dev/isa/isadmavar.h>
45 #include <dev/isa/tsdiovar.h>
47 int tsdio_probe(device_t
, cfdata_t
, void *);
48 void tsdio_attach(device_t
, device_t
, void *);
49 int tsdio_search(device_t
, cfdata_t
, const int *, void *);
50 int tsdio_print(void *, const char *);
52 CFATTACH_DECL(tsdio
, sizeof(struct tsdio_softc
),
53 tsdio_probe
, tsdio_attach
, NULL
, NULL
);
56 tsdio_probe(device_t parent
, cfdata_t cf
, void *aux
)
58 struct isa_attach_args
*ia
= aux
;
59 bus_space_tag_t iot
= ia
->ia_iot
;
60 bus_space_handle_t dioh
;
61 int rv
= 0, have_io
= 0;
68 if (ISA_DIRECT_CONFIG(ia
))
72 * Disallow wildcarded I/O base.
74 if (ia
->ia_io
[0].ir_addr
== ISA_UNKNOWN_PORT
)
80 if (bus_space_map(ia
->ia_iot
, ia
->ia_io
[0].ir_addr
, 8,
85 if (bus_space_read_1(ia
->ia_iot
, dioh
, 0) != 0x54) {
91 ia
->ia_io
[0].ir_size
= 8;
98 bus_space_unmap(iot
, dioh
, 8);
104 tsdio_attach(device_t parent
, device_t self
, void *aux
)
106 struct tsdio_softc
*sc
= (struct tsdio_softc
*) self
;
107 struct isa_attach_args
*ia
= aux
;
109 sc
->sc_iot
= ia
->ia_iot
;
111 aprint_normal(": Technologic Systems TS-DIO24\n");
116 if (bus_space_map(sc
->sc_iot
, ia
->ia_io
[0].ir_addr
, 8,
118 aprint_error_dev(&sc
->sc_dev
, "unable to map i/o space\n");
125 config_search_ia(tsdio_search
, self
, "tsdio", NULL
);
129 tsdio_search(device_t parent
, cfdata_t cf
, const int *l
, void *aux
)
131 struct tsdio_softc
*sc
= (struct tsdio_softc
*)parent
;
132 struct tsdio_attach_args sa
;
134 sa
.ta_iot
= sc
->sc_iot
;
135 sa
.ta_ioh
= sc
->sc_ioh
;
137 if (config_match(parent
, cf
, &sa
) > 0)
138 config_attach(parent
, cf
, &sa
, tsdio_print
);
144 tsdio_print(void *aux
, const char *name
)