1*39de0dfdSvisa /* $OpenBSD: mainbus.c,v 1.10 2017/01/19 15:09:04 visa Exp $ */
2f1558498Smiod
3f1558498Smiod /*
4f1558498Smiod * Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com)
5f1558498Smiod *
6f1558498Smiod * Redistribution and use in source and binary forms, with or without
7f1558498Smiod * modification, are permitted provided that the following conditions
8f1558498Smiod * are met:
9f1558498Smiod * 1. Redistributions of source code must retain the above copyright
10f1558498Smiod * notice, this list of conditions and the following disclaimer.
11f1558498Smiod * 2. Redistributions in binary form must reproduce the above copyright
12f1558498Smiod * notice, this list of conditions and the following disclaimer in the
13f1558498Smiod * documentation and/or other materials provided with the distribution.
14f1558498Smiod *
15f1558498Smiod * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16f1558498Smiod * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17f1558498Smiod * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18f1558498Smiod * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19f1558498Smiod * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20f1558498Smiod * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21f1558498Smiod * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22f1558498Smiod * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23f1558498Smiod * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24f1558498Smiod * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25f1558498Smiod * SUCH DAMAGE.
26f1558498Smiod *
27f1558498Smiod */
28f1558498Smiod
29f1558498Smiod #include <sys/param.h>
30f1558498Smiod #include <sys/systm.h>
31f1558498Smiod #include <sys/device.h>
32f1558498Smiod
33f1558498Smiod #include <machine/autoconf.h>
34f1558498Smiod
35f1558498Smiod int mainbus_match(struct device *, void *, void *);
36f1558498Smiod void mainbus_attach(struct device *, struct device *, void *);
37f1558498Smiod int mainbus_print(void *, const char *);
38f1558498Smiod
39f1558498Smiod const struct cfattach mainbus_ca = {
40c06fda6dSderaadt sizeof(struct device), mainbus_match, mainbus_attach
41f1558498Smiod };
42f1558498Smiod
43f1558498Smiod struct cfdriver mainbus_cd = {
44f1558498Smiod NULL, "mainbus", DV_DULL
45f1558498Smiod };
46f1558498Smiod
47f1558498Smiod int
mainbus_match(struct device * parent,void * cfdata,void * aux)48f1558498Smiod mainbus_match(struct device *parent, void *cfdata, void *aux)
49f1558498Smiod {
50f1558498Smiod static int mainbus_attached = 0;
51f1558498Smiod
52f1558498Smiod if (mainbus_attached != 0)
53f1558498Smiod return 0;
54f1558498Smiod
55f1558498Smiod return mainbus_attached = 1;
56f1558498Smiod }
57f1558498Smiod
58f1558498Smiod void
mainbus_attach(struct device * parent,struct device * self,void * aux)59f1558498Smiod mainbus_attach(struct device *parent, struct device *self, void *aux)
60f1558498Smiod {
61c301e791Smiod struct cpu_attach_args caa;
62f1558498Smiod
63ff1de91aSmiod printf(": %s %s\n", sys_platform->vendor, sys_platform->product);
64f1558498Smiod
65c301e791Smiod bzero(&caa, sizeof caa);
66c301e791Smiod caa.caa_maa.maa_name = "cpu";
67c301e791Smiod caa.caa_hw = &bootcpu_hwinfo;
68c301e791Smiod config_found(self, &caa, mainbus_print);
69f1558498Smiod
70*39de0dfdSvisa #ifdef MULTIPROCESSOR
71*39de0dfdSvisa if (sys_platform->config_secondary_cpus != NULL)
72*39de0dfdSvisa sys_platform->config_secondary_cpus(self, mainbus_print);
73*39de0dfdSvisa #endif
74*39de0dfdSvisa
7580a0c0cfSpirofti caa.caa_maa.maa_name = "bonito";
76c301e791Smiod config_found(self, &caa.caa_maa, mainbus_print);
77c301e791Smiod
787d353fccSvisa caa.caa_maa.maa_name = "htb";
797d353fccSvisa config_found(self, &caa.caa_maa, mainbus_print);
807d353fccSvisa
817d353fccSvisa caa.caa_maa.maa_name = "leioc";
827d353fccSvisa config_found(self, &caa.caa_maa, mainbus_print);
837d353fccSvisa
840660f804Spirofti if (md_startclock == NULL) {
8580a0c0cfSpirofti caa.caa_maa.maa_name = "clock";
86c301e791Smiod config_found(self, &caa.caa_maa, mainbus_print);
870660f804Spirofti }
8813bfa4beSotto
8913bfa4beSotto caa.caa_maa.maa_name = "apm";
9013bfa4beSotto config_found(self, &caa.caa_maa, mainbus_print);
91f1558498Smiod }
92f1558498Smiod
93f1558498Smiod int
mainbus_print(void * aux,const char * pnp)94f1558498Smiod mainbus_print(void *aux, const char *pnp)
95f1558498Smiod {
96f1558498Smiod return pnp != NULL ? QUIET : UNCONF;
97f1558498Smiod }
98