xref: /netbsd-src/sys/arch/luna68k/luna68k/mainbus.c (revision 9f72ec66fd77ee8716962724360ffd3f8be40603)
1 /* $NetBSD: mainbus.c,v 1.21 2023/04/23 06:57:59 tsutsui 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.21 2023/04/23 06:57:59 tsutsui 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 #include <machine/board.h>
43 
44 static const struct mainbus_attach_args luna_devs[] = {
45 	{ "clock",  NVRAM_ADDR, -1 },	/* Mostek/Dallas TimeKeeper */
46 	{ "lcd",    OBIO_PIO1A, -1 },	/* Sharp LM16X212 LCD module */
47 	{ "le",     LANCE_ADDR, 3 },	/* Am7990 */
48 	{ "sio",    OBIO_SIO, 6 },	/* uPD7201A */
49 	{ "xpbus",  TRI_PORT_RAM, -1 },	/* HD647180XP */
50 	{ "fb",     BMAP_PALLET2, -1 },	/* BrookTree RAMDAC */
51 	{ "spc",    SCSI_ADDR, 2 },	/* internal MB89352 */
52 	{ "spc",    SCSI_2_ADDR, 2 },	/* external MB89352 (on LUNA-II) */
53 };
54 
55 static void mainbus_attach(device_t, device_t, void *);
56 static int  mainbus_match(device_t, cfdata_t, void *);
57 static int  mainbus_print(void *, const char *);
58 
59 CFATTACH_DECL_NEW(mainbus, 0,
60     mainbus_match, mainbus_attach, NULL, NULL);
61 
62 static int
mainbus_match(device_t parent,cfdata_t cf,void * args)63 mainbus_match(device_t parent, cfdata_t cf, void *args)
64 {
65 	static bool mainbus_matched;
66 
67 	if (mainbus_matched)
68 		return 0;
69 
70 	mainbus_matched = true;
71 	return 1;
72 }
73 
74 static void
mainbus_attach(device_t parent,device_t self,void * args)75 mainbus_attach(device_t parent, device_t self, void *args)
76 {
77 	int i, ndevs;
78 	const struct mainbus_attach_args *devs;
79 	struct mainbus_attach_args ma;
80 
81 	devs = luna_devs;
82 	ndevs = __arraycount(luna_devs);
83 
84 	aprint_normal("\n");
85 	for (i = 0; i < ndevs; i++) {
86 		ma = devs[i];
87 		config_found(self, &ma, mainbus_print, CFARGS_NONE);
88 	}
89 }
90 
91 static int
mainbus_print(void * aux,const char * pnp)92 mainbus_print(void *aux, const char *pnp)
93 {
94 	struct mainbus_attach_args *ma = aux;
95 
96 	if (pnp)
97 		aprint_normal("%s at %s", ma->ma_name, pnp);
98 
99 	return UNCONF;
100 }
101