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