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