1 /* $NetBSD: intio.c,v 1.27 2008/03/29 06:47:07 tsutsui Exp $ */
4 * Copyright (c) 1996, 1998, 2001 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.
33 * Autoconfiguration support for hp300 internal i/o space.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.27 2008/03/29 06:47:07 tsutsui Exp $");
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
43 #include <machine/hp300spu.h>
45 #include <hp300/dev/intioreg.h>
46 #include <hp300/dev/intiovar.h>
50 struct bus_space_tag sc_tag
;
53 static int intiomatch(device_t
, cfdata_t
, void *);
54 static void intioattach(device_t
, device_t
, void *);
55 static int intioprint(void *, const char *);
57 CFATTACH_DECL_NEW(intio
, sizeof(struct intio_softc
),
58 intiomatch
, intioattach
, NULL
, NULL
);
60 #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \
61 defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \
62 defined(HP380) || defined(HP385)
63 static const struct intio_builtins intio_3xx_builtins
[] = {
64 { "rtc", RTC_BASE
, -1},
65 { "hil", HIL_BASE
, 1},
66 { "hpib", HPIB_BASE
, 3},
67 { "dma", DMA_BASE
, 1},
70 #define nintio_3xx_builtins __arraycount(intio_3xx_builtins)
73 #if defined(HP362) || defined(HP382)
74 static const struct intio_builtins intio_3x2_builtins
[] = {
75 { "rtc", RTC_BASE
, -1},
76 { "frodo", FRODO_BASE
, 5},
77 { "hil", HIL_BASE
, 1},
78 { "hpib", HPIB_BASE
, 3},
79 { "dma", DMA_BASE
, 1},
81 #define nintio_3x2_builtins __arraycount(intio_3x2_builtins)
84 #if defined(HP400) || defined(HP425) || defined(HP433)
85 static const struct intio_builtins intio_4xx_builtins
[] = {
86 { "rtc", RTC_BASE
, -1},
87 { "frodo", FRODO_BASE
, 5},
88 { "hil", HIL_BASE
, 1},
89 { "hpib", HPIB_BASE
, 3},
90 { "dma", DMA_BASE
, 1},
92 #define nintio_4xx_builtins __arraycount(intio_4xx_builtins)
95 static int intio_matched
= 0;
96 extern void *internalhpib
;
99 intiomatch(device_t parent
, cfdata_t cf
, void *aux
)
102 /* Allow only one instance. */
111 intioattach(device_t parent
, device_t self
, void *aux
)
113 struct intio_softc
*sc
= device_private(self
);
114 struct intio_attach_args ia
;
115 const struct intio_builtins
*ib
;
116 bus_space_tag_t bst
= &sc
->sc_tag
;
123 memset(bst
, 0, sizeof(struct bus_space_tag
));
124 bst
->bustype
= HP300_BUS_SPACE_INTIO
;
127 #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \
128 defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \
129 defined(HP380) || defined(HP385)
140 ib
= intio_3xx_builtins
;
141 ndevs
= nintio_3xx_builtins
;
144 #if defined(HP362) || defined(HP382)
147 ib
= intio_3x2_builtins
;
148 ndevs
= nintio_3x2_builtins
;
151 #if defined(HP400) || defined(HP425) || defined(HP433)
155 ib
= intio_4xx_builtins
;
156 ndevs
= nintio_4xx_builtins
;
163 memset(&ia
, 0, sizeof(ia
));
165 for (i
= 0; i
< ndevs
; i
++) {
168 * Internal HP-IB doesn't always return a device ID,
169 * so we rely on the sysflags.
171 if (ib
[i
].ib_offset
== HPIB_BASE
&& !internalhpib
)
174 strlcpy(ia
.ia_modname
, ib
[i
].ib_modname
,
175 sizeof(ia
.ia_modname
));
177 ia
.ia_iobase
= ib
[i
].ib_offset
;
178 ia
.ia_addr
= (bus_addr_t
)(intiobase
+ ib
[i
].ib_offset
);
179 ia
.ia_ipl
= ib
[i
].ib_ipl
;
180 config_found(self
, &ia
, intioprint
);
185 intioprint(void *aux
, const char *pnp
)
187 struct intio_attach_args
*ia
= aux
;
190 aprint_normal("%s at %s", ia
->ia_modname
, pnp
);
191 if (ia
->ia_iobase
!= 0 && pnp
== NULL
) {
192 aprint_normal(" addr 0x%lx", INTIOBASE
+ ia
->ia_iobase
);
193 if (ia
->ia_ipl
!= -1)
194 aprint_normal(" ipl %d", ia
->ia_ipl
);