1 /* $NetBSD: mainbus.c,v 1.19 2008/01/12 09:54:21 tsutsui Exp $ */
4 * Copyright (c) 2000 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 * Derived from the mainbus code in mvme68k/autoconf.c by Chuck Cranor.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2008/01/12 09:54:21 tsutsui Exp $");
41 #include <sys/param.h>
42 #include <sys/kernel.h>
43 #include <sys/systm.h>
44 #include <sys/device.h>
46 #define _MVME68K_BUS_DMA_PRIVATE
47 #define _MVME68K_BUS_SPACE_PRIVATE
48 #include <machine/bus.h>
49 #undef _MVME68K_BUS_DMA_PRIVATE
50 #undef _MVME68K_BUS_SPACE_PRIVATE
51 #include <machine/cpu.h>
53 #include <mvme68k/dev/mainbus.h>
55 #if defined(MVME162) || defined(MVME172) || defined(MVME167) || defined(MVME177)
57 #include <dev/vme/vmevar.h>
58 #include <dev/mvme/mvmebus.h>
59 #include <dev/mvme/vme_twovar.h>
63 void mainbus_attach(struct device
*, struct device
*, void *);
64 int mainbus_match(struct device
*, struct cfdata
*, void *);
65 int mainbus_print(void *, const char *);
67 CFATTACH_DECL(mainbus
, sizeof(struct device
),
68 mainbus_match
, mainbus_attach
, NULL
, NULL
);
71 struct mainbus_devices
{
77 static struct mainbus_devices mainbusdevs_147
[] = {
78 {"pcc", MAINBUS_PCC_OFFSET
},
79 {"timekeeper", MAINBUS_TK147_OFFSET
},
84 #if defined(MVME162) || defined(MVME167) || defined(MVME172) || defined(MVME177)
85 static struct mainbus_devices mainbusdevs_1x7
[] = {
86 {"pcctwo", MAINBUS_PCCTWO_OFFSET
},
87 {"vmetwo", MAINBUS_VMETWO_OFFSET
},
88 {"timekeeper", MAINBUS_TIMEKEEPER_OFFSET
},
93 struct mvme68k_bus_dma_tag _mainbus_dma_tag
= {
97 _bus_dmamap_load_direct
,
98 _bus_dmamap_load_mbuf_direct
,
99 _bus_dmamap_load_uio_direct
,
100 _bus_dmamap_load_raw_direct
,
102 NULL
, /* Set up at run-time */
110 struct mvme68k_bus_space_tag _mainbus_space_tag
= {
125 mainbus_match(struct device
*parent
, struct cfdata
*cf
, void *args
)
127 static int mainbus_matched
;
132 return (mainbus_matched
= 1);
137 mainbus_attach(struct device
*parent
, struct device
*self
, void *args
)
139 struct mainbus_attach_args ma
;
140 struct mainbus_devices
*devices
;
146 * Attach children appropriate for this CPU.
151 devices
= mainbusdevs_147
;
152 _mainbus_dma_tag
._dmamap_sync
= _bus_dmamap_sync_030
;
156 #if defined(MVME162) || defined(MVME167) || defined(MVME172) || defined(MVME177)
161 devices
= mainbusdevs_1x7
;
162 _mainbus_dma_tag
._dmamap_sync
= _bus_dmamap_sync_0460
;
167 panic("mainbus_attach: impossible CPU type");
170 for (i
= 0; devices
[i
].md_name
!= NULL
; ++i
) {
172 * On mvme162 and up, if the kernel config file had no vmetwo0
173 * device, we have to do some manual initialisation on the
174 * VMEChip2 to get local interrupts working (ABORT switch,
175 * hardware assisted soft interrupts).
177 #if defined(MVME162) || defined(MVME172) || defined(MVME167) || defined(MVME177)
179 if (devices
[i
].md_offset
== MAINBUS_VMETWO_OFFSET
181 && machineid
!= MVME_147
184 (void)vmetwo_probe(&_mainbus_space_tag
,
185 intiobase_phys
+ MAINBUS_VMETWO_OFFSET
);
190 ma
.ma_name
= devices
[i
].md_name
;
191 ma
.ma_dmat
= &_mainbus_dma_tag
;
192 ma
.ma_bust
= &_mainbus_space_tag
;
193 ma
.ma_offset
= devices
[i
].md_offset
+ intiobase_phys
;
195 (void)config_found(self
, &ma
, mainbus_print
);
200 * Attach the memory controllers on mvme162->mvme177.
201 * Note: These *must* be attached after the PCCChip2/MCChip.
202 * They must also be attached *after* the VMEchip2 has been
203 * initialised (either by the driver, or the vmetwo_probe()
206 #if defined(MVME162) || defined(MVME172) || defined(MVME167) || defined(MVME177)
208 if (machineid
!= MVME_147
)
212 ma
.ma_dmat
= &_mainbus_dma_tag
;
213 ma
.ma_bust
= &_mainbus_space_tag
;
214 ma
.ma_offset
= MAINBUS_MEMC1_OFFSET
+ intiobase_phys
;
215 (void)config_found(self
, &ma
, mainbus_print
);
216 ma
.ma_offset
= MAINBUS_MEMC2_OFFSET
+ intiobase_phys
;
217 (void)config_found(self
, &ma
, mainbus_print
);
222 * Attach Industry Pack modules on mvme162 and mvme172
224 #if defined(MVME162) || defined(MVME172)
225 #if defined(MVME147) || defined(MVME167) || defined(MVME177)
226 if (machineid
== MVME_162
|| machineid
== MVME_172
)
229 ma
.ma_name
= "ipack";
230 ma
.ma_dmat
= &_mainbus_dma_tag
;
231 ma
.ma_bust
= &_mainbus_space_tag
;
232 ma
.ma_offset
= MAINBUS_IPACK_OFFSET
+ intiobase_phys
;
233 (void)config_found(self
, &ma
, mainbus_print
);
239 mainbus_print(void *aux
, const char *cp
)
241 struct mainbus_attach_args
*ma
;
246 aprint_normal("%s at %s", ma
->ma_name
, cp
);
248 aprint_normal(" address 0x%lx", ma
->ma_offset
);