xref: /freebsd/sys/powerpc/powerpc/autoconf.c (revision fdafd315)
1d27f1d4cSBenno Rice /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
371e3c308SPedro F. Giffuni  *
4d27f1d4cSBenno Rice  * Copyright (c) 1998 Doug Rabson
5d27f1d4cSBenno Rice  * All rights reserved.
6d27f1d4cSBenno Rice  *
7d27f1d4cSBenno Rice  * Redistribution and use in source and binary forms, with or without
8d27f1d4cSBenno Rice  * modification, are permitted provided that the following conditions
9d27f1d4cSBenno Rice  * are met:
10d27f1d4cSBenno Rice  * 1. Redistributions of source code must retain the above copyright
11d27f1d4cSBenno Rice  *    notice, this list of conditions and the following disclaimer.
12d27f1d4cSBenno Rice  * 2. Redistributions in binary form must reproduce the above copyright
13d27f1d4cSBenno Rice  *    notice, this list of conditions and the following disclaimer in the
14d27f1d4cSBenno Rice  *    documentation and/or other materials provided with the distribution.
15d27f1d4cSBenno Rice  *
16d27f1d4cSBenno Rice  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17d27f1d4cSBenno Rice  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18d27f1d4cSBenno Rice  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19d27f1d4cSBenno Rice  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20d27f1d4cSBenno Rice  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21d27f1d4cSBenno Rice  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22d27f1d4cSBenno Rice  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23d27f1d4cSBenno Rice  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24d27f1d4cSBenno Rice  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25d27f1d4cSBenno Rice  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26d27f1d4cSBenno Rice  * SUCH DAMAGE.
27d27f1d4cSBenno Rice  */
28d27f1d4cSBenno Rice 
29ac741ae5SMarcel Moolenaar #include "opt_isa.h"
30ac741ae5SMarcel Moolenaar 
31d27f1d4cSBenno Rice #include <sys/param.h>
32d27f1d4cSBenno Rice #include <sys/systm.h>
33d27f1d4cSBenno Rice #include <sys/bus.h>
34d27f1d4cSBenno Rice #include <sys/cons.h>
35d3dce63cSPeter Grehan #include <sys/kernel.h>
36d27f1d4cSBenno Rice 
3777d40ffdSMarcel Moolenaar #include <machine/intr_machdep.h>
3877d40ffdSMarcel Moolenaar 
39ac741ae5SMarcel Moolenaar #ifdef DEV_ISA
40ac741ae5SMarcel Moolenaar extern void isa_probe_children(device_t dev);
41ac741ae5SMarcel Moolenaar 
42ac741ae5SMarcel Moolenaar device_t isa_bus_device;
43ac741ae5SMarcel Moolenaar #endif
44ac741ae5SMarcel Moolenaar 
456dacd14dSPeter Grehan static device_t nexusdev;
466dacd14dSPeter Grehan 
47b1fab0ffSPeter Grehan static void	configure_first(void *);
48812344bcSAlfred Perlstein static void	configure(void *);
49b1fab0ffSPeter Grehan static void	configure_final(void *);
50b1fab0ffSPeter Grehan 
51b1fab0ffSPeter Grehan SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
52b1fab0ffSPeter Grehan /* SI_ORDER_SECOND is hookable */
53b1fab0ffSPeter Grehan SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
54b1fab0ffSPeter Grehan /* SI_ORDER_MIDDLE is hookable */
55b1fab0ffSPeter Grehan SYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL);
56d27f1d4cSBenno Rice 
57d27f1d4cSBenno Rice /*
58d27f1d4cSBenno Rice  * Determine i/o configuration for a machine.
59d27f1d4cSBenno Rice  */
60d27f1d4cSBenno Rice static void
configure_first(void * dummy)61b1fab0ffSPeter Grehan configure_first(void *dummy)
62b1fab0ffSPeter Grehan {
63470cd51eSMarcel Moolenaar 
64470cd51eSMarcel Moolenaar 	nexusdev = device_add_child(root_bus, "nexus", 0);
65b1fab0ffSPeter Grehan }
66b1fab0ffSPeter Grehan 
67b1fab0ffSPeter Grehan static void
configure(void * dummy)68d27f1d4cSBenno Rice configure(void *dummy)
69d27f1d4cSBenno Rice {
7003ea7334SMark Peek 
71b1fab0ffSPeter Grehan 	root_bus_configure();
72ac741ae5SMarcel Moolenaar #ifdef DEV_ISA
73ac741ae5SMarcel Moolenaar 	if (isa_bus_device)
74ac741ae5SMarcel Moolenaar 		isa_probe_children(isa_bus_device);
75ac741ae5SMarcel Moolenaar #endif
76b1fab0ffSPeter Grehan }
77b1fab0ffSPeter Grehan 
78b1fab0ffSPeter Grehan static void
configure_final(void * dummy)79b1fab0ffSPeter Grehan configure_final(void *dummy)
80b1fab0ffSPeter Grehan {
8177d40ffdSMarcel Moolenaar 
82d3dce63cSPeter Grehan 	/*
8377d40ffdSMarcel Moolenaar 	 * Now that we're guaranteed to have a PIC driver (or we'll never
8477d40ffdSMarcel Moolenaar 	 * have one), program it with all the previously setup interrupts.
85d3dce63cSPeter Grehan 	 */
8677d40ffdSMarcel Moolenaar 	powerpc_enable_intr();
8777d40ffdSMarcel Moolenaar 
8877d40ffdSMarcel Moolenaar 	/* Enable external interrupts. */
896b7ba544SRafal Jaworowski 	mtmsr(mfmsr() | PSL_EE);
90cadd8774SMarcel Moolenaar 
91ba64ae0cSMarcel Moolenaar 	cninit_finish();
92d3dce63cSPeter Grehan 	cold = 0;
93d27f1d4cSBenno Rice }
94