Home | History | Annotate | Line # | Download | only in mpc85xx
autoconf.c revision 1.1.4.1
      1 /*	$NetBSD: autoconf.c,v 1.1.4.1 2011/06/06 09:05:32 jruoho Exp $	*/
      2 /*-
      3  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to The NetBSD Foundation
      7  * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
      8  * Agency and which was developed by Matt Thomas of 3am Software Foundry.
      9  *
     10  * This material is based upon work supported by the Defense Advanced Research
     11  * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
     12  * Contract No. N66001-09-C-2073.
     13  * Approved for Public Release, Distribution Unlimited
     14  *
     15  * Redistribution and use in source and binary forms, with or without
     16  * modification, are permitted provided that the following conditions
     17  * are met:
     18  * 1. Redistributions of source code must retain the above copyright
     19  *    notice, this list of conditions and the following disclaimer.
     20  * 2. Redistributions in binary form must reproduce the above copyright
     21  *    notice, this list of conditions and the following disclaimer in the
     22  *    documentation and/or other materials provided with the distribution.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34  * POSSIBILITY OF SUCH DAMAGE.
     35  */
     36 
     37 #include <sys/cdefs.h>
     38 __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.1.4.1 2011/06/06 09:05:32 jruoho Exp $");
     39 
     40 #define __INTR_PRIVATE
     41 
     42 #include "locators.h"
     43 
     44 #include <sys/param.h>
     45 #include <sys/conf.h>
     46 #include <sys/device.h>
     47 #include <sys/intr.h>
     48 #include <sys/systm.h>
     49 #include <sys/bus.h>
     50 
     51 #include <sys/cpu.h>
     52 #include <powerpc/booke/cpuvar.h>
     53 
     54 /*
     55  * Determine device configuration for a machine.
     56  */
     57 void
     58 cpu_configure(void)
     59 {
     60 
     61 	(*powerpc_intrsw->intrsw_init)();
     62 	calc_delayconst();
     63 
     64 	if (config_rootfound("mainbus", NULL) == NULL)
     65 		panic("%s: mainbus not configured", __func__);
     66 
     67 	spl0();
     68 }
     69 
     70 /*
     71  * Setup root device.
     72  * Configure swap area.
     73  */
     74 void
     75 cpu_rootconf(void)
     76 {
     77 
     78 	setroot(booted_device, booted_partition);
     79 }
     80 
     81 void
     82 device_register(device_t dev, void *aux)
     83 {
     84 	if (cpu_md_ops.md_device_register != NULL)
     85 		(*cpu_md_ops.md_device_register)(dev, aux);
     86 }
     87 
     88 static bool mainbus_found;
     89 
     90 static int
     91 mainbus_print(void *aux, const char *pnp)
     92 {
     93 	struct mainbus_attach_args *ma = aux;
     94 
     95 	if (pnp != NULL)
     96 		return QUIET;
     97 
     98 	if (pnp)
     99 		aprint_normal("%s at %s", ma->ma_name, pnp);
    100 	if (ma->ma_node != MAINBUSCF_NODE_DEFAULT)
    101 		aprint_normal(" node %d", ma->ma_node);
    102 
    103 	return (UNCONF);
    104 }
    105 
    106 static int
    107 mainbus_match(device_t parent, cfdata_t cf, void *aux)
    108 {
    109 	return mainbus_found == false;
    110 }
    111 
    112 static void
    113 mainbus_attach(device_t parent, device_t self, void *aux)
    114 {
    115 	struct mainbus_attach_args ma;
    116 
    117 	mainbus_found = true;
    118 
    119 	aprint_normal("\n");
    120 
    121 	ma.ma_name = "cpunode";
    122 	ma.ma_node = 0;
    123 	ma.ma_memt = curcpu()->ci_softc->cpu_bst;
    124 	ma.ma_le_memt = curcpu()->ci_softc->cpu_le_bst;
    125 	ma.ma_dmat = &booke_bus_dma_tag;
    126 
    127 	config_found_sm_loc(self, "mainbus", NULL, &ma, mainbus_print, NULL);
    128 }
    129 
    130 CFATTACH_DECL_NEW(mainbus, 0, mainbus_match, mainbus_attach, NULL, NULL);
    131