Home | History | Annotate | Line # | Download | only in ev64260
mainbus.c revision 1.5.100.2
      1  1.5.100.2  rmind /*	$NetBSD: mainbus.c,v 1.5.100.2 2011/06/12 00:23:57 rmind Exp $	*/
      2        1.1   matt 
      3        1.1   matt /*
      4        1.1   matt  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
      5        1.1   matt  *
      6        1.1   matt  * Redistribution and use in source and binary forms, with or without
      7        1.1   matt  * modification, are permitted provided that the following conditions
      8        1.1   matt  * are met:
      9        1.1   matt  * 1. Redistributions of source code must retain the above copyright
     10        1.1   matt  *    notice, this list of conditions and the following disclaimer.
     11        1.1   matt  * 2. Redistributions in binary form must reproduce the above copyright
     12        1.1   matt  *    notice, this list of conditions and the following disclaimer in the
     13        1.1   matt  *    documentation and/or other materials provided with the distribution.
     14        1.1   matt  * 3. All advertising materials mentioning features or use of this software
     15        1.1   matt  *    must display the following acknowledgement:
     16        1.1   matt  *      This product includes software developed by Christopher G. Demetriou
     17        1.1   matt  *	for the NetBSD Project.
     18        1.1   matt  * 4. The name of the author may not be used to endorse or promote products
     19        1.1   matt  *    derived from this software without specific prior written permission
     20        1.1   matt  *
     21        1.1   matt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22        1.1   matt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23        1.1   matt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24        1.1   matt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25        1.1   matt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26        1.1   matt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27        1.1   matt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28        1.1   matt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29        1.1   matt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30        1.1   matt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31        1.1   matt  */
     32        1.4  lukem 
     33        1.4  lukem #include <sys/cdefs.h>
     34  1.5.100.2  rmind __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.5.100.2 2011/06/12 00:23:57 rmind Exp $");
     35        1.1   matt 
     36        1.1   matt #include "mainbus.h"
     37        1.2   matt #include "opt_multiprocessor.h"
     38        1.1   matt 
     39        1.1   matt #include <sys/param.h>
     40  1.5.100.1  rmind #include <sys/bus.h>
     41        1.1   matt #include <sys/device.h>
     42  1.5.100.1  rmind #include <sys/errno.h>
     43        1.1   matt 
     44  1.5.100.1  rmind #include <evbppc/ev64260/ev64260.h>
     45        1.1   matt 
     46  1.5.100.1  rmind #include "locators.h"
     47        1.1   matt 
     48        1.1   matt #if NCPU == 0
     49        1.1   matt #error	A cpu device is now required
     50        1.1   matt #endif
     51        1.1   matt 
     52        1.1   matt 
     53  1.5.100.1  rmind int	mainbus_match(device_t, cfdata_t, void *);
     54  1.5.100.1  rmind void	mainbus_attach(device_t, device_t, void *);
     55        1.1   matt int	mainbus_cfprint(void *, const char *);
     56        1.1   matt 
     57  1.5.100.2  rmind CFATTACH_DECL_NEW(mainbus, 0,
     58        1.1   matt 	mainbus_match, mainbus_attach, NULL, NULL);
     59        1.1   matt 
     60        1.1   matt /*
     61        1.1   matt  * Probe for the mainbus; always succeeds.
     62        1.1   matt  */
     63        1.1   matt int
     64  1.5.100.1  rmind mainbus_match(device_t parent, cfdata_t match, void *aux)
     65        1.1   matt {
     66  1.5.100.1  rmind 
     67        1.1   matt 	return 1;
     68        1.1   matt }
     69        1.1   matt 
     70        1.1   matt /*
     71        1.1   matt  * Attach the mainbus.
     72        1.1   matt  */
     73        1.1   matt void
     74  1.5.100.1  rmind mainbus_attach(device_t parent, device_t self, void *aux)
     75        1.1   matt {
     76        1.1   matt 	struct mainbus_attach_args mba;
     77  1.5.100.1  rmind 	extern bus_addr_t gt_base;
     78        1.1   matt 
     79        1.1   matt 	printf("\n");
     80        1.1   matt 
     81        1.1   matt 	memset(&mba, 0, sizeof(mba));
     82        1.1   matt 
     83        1.1   matt 	/*
     84        1.1   matt 	 * Always find the CPU
     85        1.1   matt 	 */
     86  1.5.100.1  rmind 	mba.mba_name = "cpu";
     87        1.1   matt 	mba.mba_unit = 0;
     88  1.5.100.1  rmind 	mba.mba_addr = MAINBUSCF_ADDR_DEFAULT;
     89        1.1   matt 	config_found(self, &mba, mainbus_cfprint);
     90        1.1   matt 
     91        1.2   matt #ifdef MULTIPROCESSOR
     92        1.1   matt 	/*
     93        1.1   matt 	 * Try for a second one...
     94        1.1   matt 	 */
     95  1.5.100.1  rmind 	mba.mba_name = "cpu";
     96        1.1   matt 	mba.mba_unit = 1;
     97  1.5.100.1  rmind 	mba.mba_addr = MAINBUSCF_ADDR_DEFAULT;
     98        1.1   matt 	config_found(self, &mba, mainbus_cfprint);
     99        1.2   matt #endif
    100        1.1   matt 
    101        1.1   matt 	/*
    102        1.1   matt 	 * Now try to configure the Discovery
    103        1.1   matt 	 */
    104  1.5.100.1  rmind 	mba.mba_name = "gt";
    105  1.5.100.1  rmind 	mba.mba_unit = -1;
    106  1.5.100.1  rmind 	mba.mba_addr = gt_base;
    107        1.1   matt 	config_found(self, &mba, mainbus_cfprint);
    108        1.1   matt }
    109        1.1   matt 
    110  1.5.100.1  rmind int
    111  1.5.100.1  rmind mainbus_cfprint(void *aux, const char *pnp)
    112  1.5.100.1  rmind {
    113  1.5.100.1  rmind 	struct mainbus_attach_args *mba = aux;
    114  1.5.100.1  rmind 
    115  1.5.100.1  rmind 	if (pnp)
    116  1.5.100.1  rmind 		aprint_normal("%s at %s", mba->mba_name, pnp);
    117  1.5.100.1  rmind 	if (mba->mba_unit != -1)
    118  1.5.100.1  rmind 		aprint_normal(" unit %d", mba->mba_unit);
    119  1.5.100.1  rmind 	if (mba->mba_addr != MAINBUSCF_ADDR_DEFAULT)
    120  1.5.100.1  rmind 		aprint_normal(" addr 0x%08x", mba->mba_addr);
    121  1.5.100.1  rmind 	return UNCONF;
    122  1.5.100.1  rmind }
    123  1.5.100.1  rmind 
    124        1.1   matt 
    125  1.5.100.1  rmind static int	cpu_match(device_t, cfdata_t, void *);
    126  1.5.100.1  rmind static void	cpu_attach(device_t, device_t, void *);
    127        1.1   matt 
    128  1.5.100.2  rmind CFATTACH_DECL_NEW(cpu, 0, cpu_match, cpu_attach, NULL, NULL);
    129        1.1   matt 
    130        1.1   matt int
    131  1.5.100.1  rmind cpu_match(device_t parent, cfdata_t cf, void *aux)
    132        1.1   matt {
    133        1.1   matt 	struct mainbus_attach_args *mba = aux;
    134        1.1   matt 
    135  1.5.100.1  rmind 	if (strcmp(mba->mba_name, "cpu") != 0)
    136        1.1   matt 		return 0;
    137        1.1   matt 
    138        1.1   matt 	return 1;
    139        1.1   matt }
    140        1.1   matt 
    141        1.1   matt void
    142  1.5.100.1  rmind cpu_attach(device_t parent, device_t self, void *aux)
    143        1.1   matt {
    144  1.5.100.1  rmind 	struct mainbus_attach_args *mba = aux;
    145  1.5.100.1  rmind 
    146  1.5.100.1  rmind 	(void) cpu_attach_common(self, mba->mba_unit);
    147        1.1   matt }
    148