xref: /netbsd/sys/arch/luna68k/luna68k/mainbus.c (revision 6550d01e)
1 /* $NetBSD: mainbus.c,v 1.8 2009/03/14 21:04:11 dsl Exp $ */
2 
3 /*-
4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Tohru Nishimura.
9  *
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.
18  *
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.
30  */
31 
32 #include <sys/cdefs.h>
33 
34 __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.8 2009/03/14 21:04:11 dsl Exp $");
35 
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
39 
40 #include <machine/cpu.h>
41 #include <machine/autoconf.h>
42 
43 static struct mainbus_attach_args devs[] = {
44 	{ "clock",  0x45000000, -1 },	/* Mostek/Dallas TimeKeeper */
45 	{ "le",	    0xf1000000, 3 },	/* Am7990 */
46 	{ "sio",    0x51000000, 6 },	/* uPD7201A */
47 	{ "fb",	    0xc1100000, -1 },	/* BrookTree RAMDAC */
48 	{ "spc",    0xe1000000, 2 },	/* MB89352 */
49 #if 0
50 	{ "spc",    0xe1000040, 2 },	/* ditto */
51 #endif
52 };
53 
54 static void mainbus_attach(struct device *, struct device *, void *);
55 static int  mainbus_match(struct device *, struct cfdata *, void *);
56 static int  mainbus_print(void *, const char *);
57 
58 CFATTACH_DECL(mainbus, sizeof(struct device),
59     mainbus_match, mainbus_attach, NULL, NULL);
60 
61 static int
62 mainbus_match(struct device *parent, struct cfdata *cf, void *args)
63 {
64 	static int mainbus_matched;
65 
66 	if (mainbus_matched)
67 		return (0);
68 
69 	return ((mainbus_matched = 1));
70 }
71 
72 static void
73 mainbus_attach(struct device *parent, struct device *self, void *args)
74 {
75 	int i;
76 
77 	if (machtype == LUNA_II)
78 		devs[1].ma_addr = 0xf0000000;
79 	printf("\n");
80 	for (i = 0; i < sizeof(devs)/sizeof(devs[0]); i++)
81 		config_found(self, (void *)&devs[i], mainbus_print);
82 }
83 
84 static int
85 mainbus_print(void *aux, const char *pnp)
86 {
87 	struct mainbus_attach_args *ma = aux;
88 
89 	if (pnp)
90 		aprint_normal("%s at %s", ma->ma_name, pnp);
91 
92 	return (UNCONF);
93 }
94