Home | History | Annotate | Line # | Download | only in pmppc
mainbus.c revision 1.2.4.2
      1  1.2.4.2  yamt /*	$NetBSD: mainbus.c,v 1.2.4.2 2007/10/27 11:25:57 yamt Exp $	*/
      2  1.2.4.2  yamt 
      3  1.2.4.2  yamt /*
      4  1.2.4.2  yamt  * Copyright (c) 2002 The NetBSD Foundation, Inc.
      5  1.2.4.2  yamt  * All rights reserved.
      6  1.2.4.2  yamt  *
      7  1.2.4.2  yamt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2.4.2  yamt  * by Lennart Augustsson (lennart (at) augustsson.net) at Sandburst Corp.
      9  1.2.4.2  yamt  *
     10  1.2.4.2  yamt  * Redistribution and use in source and binary forms, with or without
     11  1.2.4.2  yamt  * modification, are permitted provided that the following conditions
     12  1.2.4.2  yamt  * are met:
     13  1.2.4.2  yamt  * 1. Redistributions of source code must retain the above copyright
     14  1.2.4.2  yamt  *    notice, this list of conditions and the following disclaimer.
     15  1.2.4.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.2.4.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     17  1.2.4.2  yamt  *    documentation and/or other materials provided with the distribution.
     18  1.2.4.2  yamt  * 3. All advertising materials mentioning features or use of this software
     19  1.2.4.2  yamt  *    must display the following acknowledgement:
     20  1.2.4.2  yamt  *        This product includes software developed by the NetBSD
     21  1.2.4.2  yamt  *        Foundation, Inc. and its contributors.
     22  1.2.4.2  yamt  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.2.4.2  yamt  *    contributors may be used to endorse or promote products derived
     24  1.2.4.2  yamt  *    from this software without specific prior written permission.
     25  1.2.4.2  yamt  *
     26  1.2.4.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.2.4.2  yamt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.2.4.2  yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.2.4.2  yamt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.2.4.2  yamt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.2.4.2  yamt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.2.4.2  yamt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.2.4.2  yamt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.2.4.2  yamt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.2.4.2  yamt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.2.4.2  yamt  * POSSIBILITY OF SUCH DAMAGE.
     37  1.2.4.2  yamt  */
     38  1.2.4.2  yamt 
     39  1.2.4.2  yamt #include <sys/cdefs.h>
     40  1.2.4.2  yamt __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.2.4.2 2007/10/27 11:25:57 yamt Exp $");
     41  1.2.4.2  yamt 
     42  1.2.4.2  yamt #include <sys/param.h>
     43  1.2.4.2  yamt #include <sys/device.h>
     44  1.2.4.2  yamt #include <sys/systm.h>
     45  1.2.4.2  yamt 
     46  1.2.4.2  yamt #include <machine/bus.h>
     47  1.2.4.2  yamt #include <machine/pmppc.h>
     48  1.2.4.2  yamt #include <arch/evbppc/pmppc/dev/mainbus.h>
     49  1.2.4.2  yamt 
     50  1.2.4.2  yamt #include <dev/ic/cpc700reg.h>
     51  1.2.4.2  yamt 
     52  1.2.4.2  yamt #include "locators.h"
     53  1.2.4.2  yamt #include "mainbus.h"
     54  1.2.4.2  yamt 
     55  1.2.4.2  yamt #if NCPU == 0
     56  1.2.4.2  yamt #error	A cpu device is now required
     57  1.2.4.2  yamt #endif
     58  1.2.4.2  yamt 
     59  1.2.4.2  yamt int	mainbus_match(struct device *, struct cfdata *, void *);
     60  1.2.4.2  yamt void	mainbus_attach(struct device *, struct device *, void *);
     61  1.2.4.2  yamt 
     62  1.2.4.2  yamt CFATTACH_DECL(mainbus, sizeof(struct device),
     63  1.2.4.2  yamt     mainbus_match, mainbus_attach, NULL, NULL);
     64  1.2.4.2  yamt 
     65  1.2.4.2  yamt static int mainbus_print(void *, const char *);
     66  1.2.4.2  yamt 
     67  1.2.4.2  yamt /*
     68  1.2.4.2  yamt  * Probe for the mainbus; always succeeds.
     69  1.2.4.2  yamt  */
     70  1.2.4.2  yamt int
     71  1.2.4.2  yamt mainbus_match(struct device *parent, struct cfdata *match, void *aux)
     72  1.2.4.2  yamt {
     73  1.2.4.2  yamt 
     74  1.2.4.2  yamt 	return 1;
     75  1.2.4.2  yamt }
     76  1.2.4.2  yamt 
     77  1.2.4.2  yamt static int
     78  1.2.4.2  yamt mainbus_submatch(struct device *parent, struct cfdata *cf,
     79  1.2.4.2  yamt 		 const int *ldesc, void *aux)
     80  1.2.4.2  yamt {
     81  1.2.4.2  yamt 	struct mainbus_attach_args *maa = aux;
     82  1.2.4.2  yamt 
     83  1.2.4.2  yamt 	if (cf->cf_loc[MAINBUSCF_ADDR] != maa->mb_addr)
     84  1.2.4.2  yamt 		return (0);
     85  1.2.4.2  yamt 
     86  1.2.4.2  yamt 	return (config_match(parent, cf, aux));
     87  1.2.4.2  yamt }
     88  1.2.4.2  yamt 
     89  1.2.4.2  yamt static int
     90  1.2.4.2  yamt mainbus_print(void *aux, const char *pnp)
     91  1.2.4.2  yamt {
     92  1.2.4.2  yamt 	struct mainbus_attach_args *mba = aux;
     93  1.2.4.2  yamt 
     94  1.2.4.2  yamt 	if (pnp)
     95  1.2.4.2  yamt 		aprint_normal("%s at %s", mba->mb_name, pnp);
     96  1.2.4.2  yamt 	if (mba->mb_addr != MAINBUSCF_ADDR_DEFAULT)
     97  1.2.4.2  yamt 		aprint_normal(" addr 0x%08lx", mba->mb_addr);
     98  1.2.4.2  yamt 	if (mba->mb_irq != MAINBUSCF_IRQ_DEFAULT)
     99  1.2.4.2  yamt 		aprint_normal(" irq %d", mba->mb_irq);
    100  1.2.4.2  yamt 	return (UNCONF);
    101  1.2.4.2  yamt }
    102  1.2.4.2  yamt 
    103  1.2.4.2  yamt /*
    104  1.2.4.2  yamt  * Attach the mainbus.
    105  1.2.4.2  yamt  */
    106  1.2.4.2  yamt void
    107  1.2.4.2  yamt mainbus_attach(struct device *parent, struct device *self, void *aux)
    108  1.2.4.2  yamt {
    109  1.2.4.2  yamt 	struct mainbus_attach_args maa;
    110  1.2.4.2  yamt 
    111  1.2.4.2  yamt 	printf(": Artesyn PM/PPC\n");
    112  1.2.4.2  yamt 	printf("%s: %sPCI bus Monarch\n", self->dv_xname,
    113  1.2.4.2  yamt 	       a_config.a_is_monarch ? "" : "not");
    114  1.2.4.2  yamt 	printf("%s: boot from %s, %sECC, %s L2 cache\n",
    115  1.2.4.2  yamt 	       self->dv_xname,
    116  1.2.4.2  yamt 	       a_config.a_boot_device == A_BOOT_ROM ? "ROM" : "flash",
    117  1.2.4.2  yamt 	       a_config.a_has_ecc ? "" : "no ",
    118  1.2.4.2  yamt 	       a_config.a_l2_cache == A_CACHE_PARITY ? "parity" :
    119  1.2.4.2  yamt 	       a_config.a_l2_cache == A_CACHE_NO_PARITY ? "no-parity" : "no");
    120  1.2.4.2  yamt 
    121  1.2.4.2  yamt 	maa.mb_bt = &pmppc_mem_tag;
    122  1.2.4.2  yamt 
    123  1.2.4.2  yamt 	maa.mb_name = "cpu";
    124  1.2.4.2  yamt 	maa.mb_addr = MAINBUSCF_ADDR_DEFAULT;
    125  1.2.4.2  yamt 	maa.mb_irq = MAINBUSCF_IRQ_DEFAULT;
    126  1.2.4.2  yamt 	config_found(self, &maa, mainbus_print);
    127  1.2.4.2  yamt 
    128  1.2.4.2  yamt 	if (a_config.a_has_rtc) {
    129  1.2.4.2  yamt 		maa.mb_name = "rtc";
    130  1.2.4.2  yamt 		maa.mb_addr = PMPPC_RTC;
    131  1.2.4.2  yamt 		maa.mb_irq = PMPPC_I_RTC_INT;
    132  1.2.4.2  yamt 		config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print,
    133  1.2.4.2  yamt 				    mainbus_submatch);
    134  1.2.4.2  yamt 	}
    135  1.2.4.2  yamt 
    136  1.2.4.2  yamt 	if (a_config.a_has_eth) {
    137  1.2.4.2  yamt 		maa.mb_name = "cs";
    138  1.2.4.2  yamt 		maa.mb_addr = PMPPC_CS_IO_BASE;
    139  1.2.4.2  yamt 		maa.mb_irq = PMPPC_I_ETH_INT;
    140  1.2.4.2  yamt 		config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print,
    141  1.2.4.2  yamt 				    mainbus_submatch);
    142  1.2.4.2  yamt 		maa.mb_bt = &pmppc_mem_tag;
    143  1.2.4.2  yamt 	}
    144  1.2.4.2  yamt 	if (a_config.a_flash_width != 0) {
    145  1.2.4.2  yamt 		maa.mb_name = "flash";
    146  1.2.4.2  yamt 		maa.mb_addr = PMPPC_FLASH_BASE;
    147  1.2.4.2  yamt 		maa.mb_irq = MAINBUSCF_IRQ_DEFAULT;
    148  1.2.4.2  yamt 		maa.u.mb_flash.size = a_config.a_flash_size;
    149  1.2.4.2  yamt 		maa.u.mb_flash.width = a_config.a_flash_width;
    150  1.2.4.2  yamt 		config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print,
    151  1.2.4.2  yamt 				    mainbus_submatch);
    152  1.2.4.2  yamt 	}
    153  1.2.4.2  yamt 
    154  1.2.4.2  yamt 	maa.mb_name = "cpc";
    155  1.2.4.2  yamt 	maa.mb_addr = MAINBUSCF_ADDR_DEFAULT;
    156  1.2.4.2  yamt 	maa.mb_irq = MAINBUSCF_IRQ_DEFAULT;
    157  1.2.4.2  yamt 	config_found(self, &maa, mainbus_print);
    158  1.2.4.2  yamt }
    159  1.2.4.2  yamt 
    160  1.2.4.2  yamt static int	cpu_match(struct device *, struct cfdata *, void *);
    161  1.2.4.2  yamt static void	cpu_attach(struct device *, struct device *, void *);
    162  1.2.4.2  yamt 
    163  1.2.4.2  yamt CFATTACH_DECL(cpu, sizeof(struct device),
    164  1.2.4.2  yamt     cpu_match, cpu_attach, NULL, NULL);
    165  1.2.4.2  yamt 
    166  1.2.4.2  yamt extern struct cfdriver cpu_cd;
    167  1.2.4.2  yamt 
    168  1.2.4.2  yamt int
    169  1.2.4.2  yamt cpu_match(struct device *parent, struct cfdata *cf, void *aux)
    170  1.2.4.2  yamt {
    171  1.2.4.2  yamt 	struct mainbus_attach_args *maa = aux;
    172  1.2.4.2  yamt 
    173  1.2.4.2  yamt 	if (strcmp(maa->mb_name, cpu_cd.cd_name) != 0)
    174  1.2.4.2  yamt 		return 0;
    175  1.2.4.2  yamt 
    176  1.2.4.2  yamt 	if (cpu_info[0].ci_dev != NULL)
    177  1.2.4.2  yamt 		return 0;
    178  1.2.4.2  yamt 
    179  1.2.4.2  yamt 	return 1;
    180  1.2.4.2  yamt }
    181  1.2.4.2  yamt 
    182  1.2.4.2  yamt void
    183  1.2.4.2  yamt cpu_attach(struct device *parent, struct device *self, void *aux)
    184  1.2.4.2  yamt {
    185  1.2.4.2  yamt 	(void) cpu_attach_common(self, 0);
    186  1.2.4.2  yamt }
    187