intio.c revision 1.15 1 1.15 gmcgarry /* $NetBSD: intio.c,v 1.15 2003/05/24 06:21:22 gmcgarry Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*-
4 1.7 gmcgarry * Copyright (c) 1996, 1998, 2001 The NetBSD Foundation, Inc.
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.1 thorpej * by Jason R. Thorpe.
9 1.1 thorpej *
10 1.1 thorpej * Redistribution and use in source and binary forms, with or without
11 1.1 thorpej * modification, are permitted provided that the following conditions
12 1.1 thorpej * are met:
13 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.1 thorpej * notice, this list of conditions and the following disclaimer.
15 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.1 thorpej * documentation and/or other materials provided with the distribution.
18 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.1 thorpej * must display the following acknowledgement:
20 1.1 thorpej * This product includes software developed by the NetBSD
21 1.1 thorpej * Foundation, Inc. and its contributors.
22 1.1 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 thorpej * contributors may be used to endorse or promote products derived
24 1.1 thorpej * from this software without specific prior written permission.
25 1.1 thorpej *
26 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.3 jtc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.3 jtc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.1 thorpej */
38 1.1 thorpej
39 1.1 thorpej /*
40 1.1 thorpej * Autoconfiguration support for hp300 internal i/o space.
41 1.1 thorpej */
42 1.1 thorpej
43 1.8 gmcgarry #include <sys/cdefs.h>
44 1.15 gmcgarry __KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.15 2003/05/24 06:21:22 gmcgarry Exp $");
45 1.8 gmcgarry
46 1.1 thorpej #include <sys/param.h>
47 1.1 thorpej #include <sys/systm.h>
48 1.1 thorpej #include <sys/device.h>
49 1.7 gmcgarry
50 1.7 gmcgarry #include <machine/hp300spu.h>
51 1.7 gmcgarry
52 1.7 gmcgarry #include <hp300/dev/intioreg.h>
53 1.1 thorpej #include <hp300/dev/intiovar.h>
54 1.1 thorpej
55 1.7 gmcgarry int intiomatch(struct device *, struct cfdata *, void *);
56 1.7 gmcgarry void intioattach(struct device *, struct device *, void *);
57 1.7 gmcgarry int intioprint(void *, const char *);
58 1.1 thorpej
59 1.12 thorpej CFATTACH_DECL(intio, sizeof(struct device),
60 1.12 thorpej intiomatch, intioattach, NULL, NULL);
61 1.1 thorpej
62 1.7 gmcgarry #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \
63 1.7 gmcgarry defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \
64 1.7 gmcgarry defined(HP380) || defined(HP385)
65 1.7 gmcgarry const struct intio_builtins intio_3xx_builtins[] = {
66 1.9 gmcgarry { "rtc", 0x020000, -1},
67 1.9 gmcgarry { "hil", 0x028000, 1},
68 1.15 gmcgarry { "hpib", 0x078000, 3},
69 1.13 gmcgarry { "dma", 0x100000, 1},
70 1.9 gmcgarry { "fb", 0x160000, -1},
71 1.7 gmcgarry };
72 1.7 gmcgarry #define nintio_3xx_builtins \
73 1.7 gmcgarry (sizeof(intio_3xx_builtins) / sizeof(intio_3xx_builtins[0]))
74 1.7 gmcgarry #endif
75 1.7 gmcgarry
76 1.7 gmcgarry #if defined(HP400) || defined(HP425) || defined(HP433)
77 1.7 gmcgarry const struct intio_builtins intio_4xx_builtins[] = {
78 1.9 gmcgarry { "rtc", 0x020000, -1},
79 1.9 gmcgarry { "frodo", 0x01c000, 5},
80 1.9 gmcgarry { "hil", 0x028000, 1},
81 1.15 gmcgarry { "hpib", 0x078000, 3},
82 1.13 gmcgarry { "dma", 0x100000, 1},
83 1.7 gmcgarry };
84 1.7 gmcgarry #define nintio_4xx_builtins \
85 1.7 gmcgarry (sizeof(intio_4xx_builtins) / sizeof(intio_4xx_builtins[0]))
86 1.7 gmcgarry #endif
87 1.7 gmcgarry
88 1.7 gmcgarry static int intio_matched = 0;
89 1.15 gmcgarry extern caddr_t internalhpib;
90 1.7 gmcgarry
91 1.1 thorpej int
92 1.1 thorpej intiomatch(parent, match, aux)
93 1.1 thorpej struct device *parent;
94 1.1 thorpej struct cfdata *match;
95 1.1 thorpej void *aux;
96 1.1 thorpej {
97 1.1 thorpej /* Allow only one instance. */
98 1.1 thorpej if (intio_matched)
99 1.1 thorpej return (0);
100 1.1 thorpej
101 1.1 thorpej intio_matched = 1;
102 1.1 thorpej return (1);
103 1.1 thorpej }
104 1.1 thorpej
105 1.1 thorpej void
106 1.1 thorpej intioattach(parent, self, aux)
107 1.1 thorpej struct device *parent, *self;
108 1.1 thorpej void *aux;
109 1.1 thorpej {
110 1.7 gmcgarry struct intio_attach_args ia;
111 1.7 gmcgarry const struct intio_builtins *ib;
112 1.7 gmcgarry int ndevs;
113 1.7 gmcgarry int i;
114 1.1 thorpej
115 1.1 thorpej printf("\n");
116 1.1 thorpej
117 1.7 gmcgarry switch (machineid) {
118 1.7 gmcgarry #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \
119 1.7 gmcgarry defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \
120 1.7 gmcgarry defined(HP380) || defined(HP385)
121 1.7 gmcgarry case HP_320:
122 1.7 gmcgarry case HP_330:
123 1.7 gmcgarry case HP_340:
124 1.7 gmcgarry case HP_345:
125 1.7 gmcgarry case HP_350:
126 1.7 gmcgarry case HP_360:
127 1.7 gmcgarry case HP_370:
128 1.7 gmcgarry case HP_375:
129 1.7 gmcgarry case HP_380:
130 1.7 gmcgarry case HP_385:
131 1.7 gmcgarry ib = intio_3xx_builtins;
132 1.7 gmcgarry ndevs = nintio_3xx_builtins;
133 1.7 gmcgarry break;
134 1.7 gmcgarry #endif
135 1.7 gmcgarry #if defined(HP400) || defined(HP425) || defined(HP433)
136 1.7 gmcgarry case HP_400:
137 1.7 gmcgarry case HP_425:
138 1.7 gmcgarry case HP_433:
139 1.7 gmcgarry ib = intio_4xx_builtins;
140 1.7 gmcgarry ndevs = nintio_4xx_builtins;
141 1.7 gmcgarry break;
142 1.7 gmcgarry #endif
143 1.7 gmcgarry default:
144 1.7 gmcgarry return;
145 1.7 gmcgarry }
146 1.7 gmcgarry
147 1.7 gmcgarry memset(&ia, 0, sizeof(ia));
148 1.7 gmcgarry
149 1.7 gmcgarry for (i=0; i<ndevs; i++) {
150 1.15 gmcgarry
151 1.15 gmcgarry /*
152 1.15 gmcgarry * Internal HP-IB doesn't always return a device ID,
153 1.15 gmcgarry * so we rely on the sysflags.
154 1.15 gmcgarry */
155 1.15 gmcgarry if (ib[i].ib_offset == 0x078000 && !internalhpib)
156 1.15 gmcgarry continue;
157 1.15 gmcgarry
158 1.7 gmcgarry strncpy(ia.ia_modname, ib[i].ib_modname, INTIO_MOD_LEN);
159 1.7 gmcgarry ia.ia_modname[INTIO_MOD_LEN] = '\0';
160 1.7 gmcgarry ia.ia_bst = HP300_BUS_SPACE_INTIO;
161 1.7 gmcgarry ia.ia_iobase = ib[i].ib_offset;
162 1.7 gmcgarry ia.ia_addr = (bus_addr_t)(intiobase + ib[i].ib_offset);
163 1.7 gmcgarry ia.ia_ipl = ib[i].ib_ipl;
164 1.7 gmcgarry config_found(self, &ia, intioprint);
165 1.7 gmcgarry }
166 1.1 thorpej }
167 1.1 thorpej
168 1.1 thorpej int
169 1.1 thorpej intioprint(aux, pnp)
170 1.1 thorpej void *aux;
171 1.1 thorpej const char *pnp;
172 1.1 thorpej {
173 1.1 thorpej struct intio_attach_args *ia = aux;
174 1.1 thorpej
175 1.9 gmcgarry if (pnp != NULL)
176 1.14 thorpej aprint_normal("%s at %s", ia->ia_modname, pnp);
177 1.15 gmcgarry if (ia->ia_iobase != 0 && pnp == NULL) {
178 1.15 gmcgarry aprint_normal(" addr 0x%lx", INTIOBASE + ia->ia_iobase);
179 1.15 gmcgarry if (ia->ia_ipl != -1)
180 1.14 thorpej aprint_normal(" ipl %d", ia->ia_ipl);
181 1.7 gmcgarry }
182 1.1 thorpej return (UNCONF);
183 1.1 thorpej }
184