autoconf.c revision 176771
1161754Sru/*-
288276Smarkm * Copyright (c) 1998 Doug Rabson
388276Smarkm * All rights reserved.
47527Sjkh *
57527Sjkh * Redistribution and use in source and binary forms, with or without
67527Sjkh * modification, are permitted provided that the following conditions
77527Sjkh * are met:
87527Sjkh * 1. Redistributions of source code must retain the above copyright
97527Sjkh *    notice, this list of conditions and the following disclaimer.
107527Sjkh * 2. Redistributions in binary form must reproduce the above copyright
117527Sjkh *    notice, this list of conditions and the following disclaimer in the
127527Sjkh *    documentation and/or other materials provided with the distribution.
137527Sjkh *
147527Sjkh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
157527Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16161754Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
177527Sjkh * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
187527Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
197527Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
207527Sjkh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
217527Sjkh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
227527Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
237527Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
247527Sjkh * SUCH DAMAGE.
257527Sjkh */
267527Sjkh
277527Sjkh#include <sys/cdefs.h>
287527Sjkh__FBSDID("$FreeBSD: head/sys/powerpc/powerpc/autoconf.c 176771 2008-03-03 17:17:00Z raj $");
297527Sjkh
307527Sjkh#include <sys/param.h>
317527Sjkh#include <sys/systm.h>
327527Sjkh#include <sys/bus.h>
3388276Smarkm#include <sys/cons.h>
3488276Smarkm#include <sys/kernel.h>
3588276Smarkm
367527Sjkh#include <machine/intr_machdep.h>
3788276Smarkm
387527Sjkhstatic device_t nexusdev;
39161754Sru
4088276Smarkmstatic void	configure_first(void *);
417527Sjkhstatic void	configure(void *);
427527Sjkhstatic void	configure_final(void *);
437527Sjkh
447527SjkhSYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
457527Sjkh/* SI_ORDER_SECOND is hookable */
467527SjkhSYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
477527Sjkh/* SI_ORDER_MIDDLE is hookable */
48161754SruSYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL);
49161754Sru
50161754Sru/*
51161754Sru * Determine i/o configuration for a machine.
52161754Sru */
53161754Srustatic void
54161754Sruconfigure_first(void *dummy)
55161754Sru{
567527Sjkh
577527Sjkh	nexusdev = device_add_child(root_bus, "nexus", 0);
587527Sjkh}
597527Sjkh
607527Sjkhstatic void
617527Sjkhconfigure(void *dummy)
627527Sjkh{
637527Sjkh
647527Sjkh	root_bus_configure();
65161754Sru}
667527Sjkh
6788276Smarkmstatic void
687527Sjkhconfigure_final(void *dummy)
697527Sjkh{
707527Sjkh
717527Sjkh	/*
727527Sjkh	 * Now that we're guaranteed to have a PIC driver (or we'll never
737527Sjkh	 * have one), program it with all the previously setup interrupts.
747527Sjkh	 */
757527Sjkh	powerpc_enable_intr();
767527Sjkh
777527Sjkh	/* Enable external interrupts. */
787527Sjkh#if defined(AIM)
797527Sjkh	mtmsr(mfmsr() | PSL_EE | PSL_RI);
807527Sjkh#elif defined(E500)
817527Sjkh	mtmsr(mfmsr() | PSL_EE);
827527Sjkh#endif
837527Sjkh	cninit_finish();
847527Sjkh	cold = 0;
857527Sjkh}
867527Sjkh