xref: /openbsd-src/sys/arch/luna88k/luna88k/mainbus.c (revision 0408a2d27c0ed803aa8e342f69800dbe2b30d80d)
1 /* $OpenBSD: mainbus.c,v 1.17 2021/10/24 09:18:51 deraadt Exp $ */
2 /* $NetBSD: mainbus.c,v 1.2 2000/01/07 05:13:08 nisimura Exp $ */
3 
4 /*-
5  * Copyright (c) 2000 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Tohru Nishimura.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/device.h>
36 
37 #include <uvm/uvm_extern.h>
38 
39 #include <machine/autoconf.h>
40 #include <machine/board.h>
41 #include <machine/cmmu.h>
42 #include <machine/cpu.h>
43 
44 #include "cbus.h"
45 #include "lcd.h"
46 #include "xp.h"
47 
48 static const struct mainbus_attach_args devs[] = {
49 	{ "clock", 0x45000000, 6,  LUNA_88K|LUNA_88K2 }, /* Mostek/Dallas TimeKeeper */
50 #if NLCD > 0
51 	{ "lcd",   0x4d000000, -1, LUNA_88K|LUNA_88K2 }, /* Sharp LM16X212 LCD module */
52 #endif
53 	{ "le",	   0xf1000000, 4,  LUNA_88K|LUNA_88K2 }, /* Am7990 */
54 	{ "sio",   0x51000000, 5,  LUNA_88K|LUNA_88K2 }, /* uPD7201A */
55 #if NXP > 0
56 	{ "xp",    0x71000000, 1,  LUNA_88K|LUNA_88K2 }, /* HD647180XP */
57 #endif
58 	{ "fb",	   0xc1100000, -1, LUNA_88K|LUNA_88K2 }, /* BrookTree RAMDAC */
59 	{ "spc",   0xe1000000, 3,  LUNA_88K|LUNA_88K2 }, /* MB89352 */
60 	{ "spc",   0xe1000040, 3,  LUNA_88K2 },	/* ditto, LUNA-88K2 only */
61 #if NCBUS > 0
62 	{ "cbus",  0x91000000, 4,  LUNA_88K2 },	/* PC-9801 extension slot */
63 #endif
64 };
65 
66 void	mainbus_attach(struct device *, struct device *, void *);
67 int	mainbus_match(struct device *, void *, void *);
68 int	mainbus_print(void *, const char *);
69 #ifdef MULTIPROCESSOR
70 extern void	cpu_setup_secondary_processors(void);	/* in machdep.c */
71 #endif
72 
73 const struct cfattach mainbus_ca = {
74 	sizeof(struct device), mainbus_match, mainbus_attach
75 };
76 
77 struct cfdriver mainbus_cd = {
78 	NULL, "mainbus", DV_DULL,
79 };
80 
81 int
mainbus_match(parent,cf,args)82 mainbus_match(parent, cf, args)
83 	struct device *parent;
84 	void *cf, *args;
85 {
86 	static int mainbus_matched;
87 
88 	if (mainbus_matched)
89 		return (0);
90 
91 	return ((mainbus_matched = 1));
92 }
93 
94 void
mainbus_attach(parent,self,args)95 mainbus_attach(parent, self, args)
96 	struct device *parent, *self;
97 	void *args;
98 {
99 	int i;
100 	extern int machtype;
101 	extern char cpu_model[];
102 
103 	printf(": %s\n", cpu_model);
104 
105 	/*
106 	 * Display cpu/mmu details for the main processor.
107 	 */
108 	cpu_configuration_print(1);
109 
110 #ifdef MULTIPROCESSOR
111 	/*
112 	 * Let secondary processors initialize further and print
113 	 * their configuration information now.
114 	 */
115 	cpu_setup_secondary_processors();
116 #endif
117 
118 	for (i = 0; i < sizeof(devs)/sizeof(devs[0]); i++)
119 		if (devs[i].ma_machine & machtype)
120 			config_found(self, (void *)&devs[i], mainbus_print);
121 }
122 
123 int
mainbus_print(aux,pnp)124 mainbus_print(aux, pnp)
125 	void *aux;
126 	const char *pnp;
127 {
128 	struct mainbus_attach_args *ma = aux;
129 
130 	if (pnp)
131 		printf("%s at %s", ma->ma_name, pnp);
132 
133 	return (UNCONF);
134 }
135