No empty .Rs/.Re
[netbsd-mini2440.git] / sys / dev / isa / tsdio.c
blob71204d05bf78b5122150dd710fd7b9a3cdff40cf
1 /* $NetBSD: tsdio.c,v 1.9 2009/05/12 08:44:20 cegger Exp $ */
3 /*-
4 * Copyright (c) 2005 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jesse Off
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.
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>
39 #include <sys/bus.h>
40 #include <sys/intr.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);
55 int
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;
63 if (ia->ia_nio < 1)
64 return (0);
65 if (ia->ia_nirq < 1)
66 return (0);
68 if (ISA_DIRECT_CONFIG(ia))
69 return (0);
72 * Disallow wildcarded I/O base.
74 if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
75 return (0);
78 * Map the I/O space.
80 if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 8,
81 0, &dioh))
82 goto out;
83 have_io = 1;
85 if (bus_space_read_1(ia->ia_iot, dioh, 0) != 0x54) {
86 goto out;
89 rv = 1;
90 ia->ia_nio = 1;
91 ia->ia_io[0].ir_size = 8;
92 ia->ia_niomem = 0;
93 ia->ia_nirq = 0;
94 ia->ia_ndrq = 0;
96 out:
97 if (have_io)
98 bus_space_unmap(iot, dioh, 8);
100 return (rv);
103 void
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");
114 * Map the device.
116 if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, 8,
117 0, &sc->sc_ioh)) {
118 aprint_error_dev(&sc->sc_dev, "unable to map i/o space\n");
119 return;
123 * Attach sub-devices
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);
140 return (0);
144 tsdio_print(void *aux, const char *name)
147 return (UNCONF);