1 /* $NetBSD: mainbus.c,v 1.3 2008/04/28 20:23:26 martin Exp $ */ 2 3 /*- 4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #include <sys/cdefs.h> 30 __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.3 2008/04/28 20:23:26 martin Exp $"); 31 32 #include "obio.h" 33 #include "pci.h" 34 35 #include <sys/param.h> 36 #include <sys/systm.h> 37 #include <sys/device.h> 38 39 #include <machine/autoconf.h> 40 #include <machine/bus.h> 41 42 #include <landisk/dev/obiovar.h> 43 44 static int mainbus_match(device_t, cfdata_t, void *); 45 static void mainbus_attach(device_t, device_t, void *); 46 47 CFATTACH_DECL_NEW(mainbus, 0, 48 mainbus_match, mainbus_attach, NULL, NULL); 49 50 static int mainbus_print(void *, const char *); 51 52 /* There can be only one. */ 53 static int mainbus_found = 0; 54 55 static int 56 mainbus_match(device_t parent, cfdata_t cf, void *aux) 57 { 58 59 if (mainbus_found) 60 return (0); 61 62 return (1); 63 } 64 65 static void 66 mainbus_attach(device_t parent, device_t self, void *aux) 67 { 68 union { 69 struct mainbus_attach_args mba_mba; 70 struct confargs mba_ca; 71 struct obiobus_attach_args mba_oba; 72 } mba; 73 74 mainbus_found = 1; 75 76 aprint_naive("\n"); 77 aprint_normal("\n"); 78 79 /* CPU */ 80 memset(&mba, 0, sizeof(mba)); 81 mba.mba_ca.ca_name = "cpu"; 82 mba.mba_ca.ca_node = 0; 83 config_found(self, &mba, mainbus_print); 84 85 #if NPCI > 0 86 /* SH PCIC */ 87 memset(&mba, 0, sizeof(mba)); 88 mba.mba_mba.ma_name = "shpcic"; 89 config_found(self, &mba, mainbus_print); 90 #endif 91 92 /* SH bus */ 93 memset(&mba, 0, sizeof(mba)); 94 mba.mba_mba.ma_name = "shb"; 95 config_found(self, &mba, mainbus_print); 96 97 #if NOBIO > 0 98 /* on-board I/O */ 99 memset(&mba, 0, sizeof(mba)); 100 mba.mba_oba.oba_busname = "obio"; 101 mba.mba_oba.oba_iot = &obio_bus_io; 102 mba.mba_oba.oba_memt = &obio_bus_mem; 103 config_found(self, &mba, mainbus_print); 104 #endif 105 } 106 107 static int 108 mainbus_print(void *aux, const char *pnp) 109 { 110 111 return (pnp ? QUIET : UNCONF); 112 } 113