mainbus.c revision 1.1
11.1Sbouyer/* $NetBSD: mainbus.c,v 1.1 2011/08/27 13:42:45 bouyer Exp $ */ 21.1Sbouyer 31.1Sbouyer/* 41.1Sbouyer * Copyright 2002 Wasabi Systems, Inc. 51.1Sbouyer * All rights reserved. 61.1Sbouyer * 71.1Sbouyer * Written by Simon Burge for Wasabi Systems, Inc. 81.1Sbouyer * 91.1Sbouyer * Redistribution and use in source and binary forms, with or without 101.1Sbouyer * modification, are permitted provided that the following conditions 111.1Sbouyer * are met: 121.1Sbouyer * 1. Redistributions of source code must retain the above copyright 131.1Sbouyer * notice, this list of conditions and the following disclaimer. 141.1Sbouyer * 2. Redistributions in binary form must reproduce the above copyright 151.1Sbouyer * notice, this list of conditions and the following disclaimer in the 161.1Sbouyer * documentation and/or other materials provided with the distribution. 171.1Sbouyer * 3. All advertising materials mentioning features or use of this software 181.1Sbouyer * must display the following acknowledgement: 191.1Sbouyer * This product includes software developed for the NetBSD Project by 201.1Sbouyer * Wasabi Systems, Inc. 211.1Sbouyer * 4. The name of Wasabi Systems, Inc. may not be used to endorse 221.1Sbouyer * or promote products derived from this software without specific prior 231.1Sbouyer * written permission. 241.1Sbouyer * 251.1Sbouyer * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 261.1Sbouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 271.1Sbouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 281.1Sbouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 291.1Sbouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 301.1Sbouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 311.1Sbouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321.1Sbouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 331.1Sbouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 341.1Sbouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 351.1Sbouyer * POSSIBILITY OF SUCH DAMAGE. 361.1Sbouyer */ 371.1Sbouyer 381.1Sbouyer#include <sys/cdefs.h> 391.1Sbouyer__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.1 2011/08/27 13:42:45 bouyer Exp $"); 401.1Sbouyer 411.1Sbouyer#include "opt_pci.h" 421.1Sbouyer 431.1Sbouyer#include <sys/param.h> 441.1Sbouyer#include <sys/systm.h> 451.1Sbouyer#include <sys/device.h> 461.1Sbouyer#if defined(PCI_NETBSD_CONFIGURE) 471.1Sbouyer#include <sys/extent.h> 481.1Sbouyer#include <sys/malloc.h> 491.1Sbouyer#endif 501.1Sbouyer 511.1Sbouyer#include <dev/pci/pcivar.h> 521.1Sbouyer#if defined(PCI_NETBSD_CONFIGURE) 531.1Sbouyer#include <dev/pci/pciconf.h> 541.1Sbouyer#endif 551.1Sbouyer 561.1Sbouyer#include <mips/cache.h> 571.1Sbouyer#include <mips/cpuregs.h> 581.1Sbouyer 591.1Sbouyer#include <mips/bonito/bonitoreg.h> 601.1Sbouyer 611.1Sbouyer#include <evbmips/loongson/autoconf.h> 621.1Sbouyer 631.1Sbouyer#include "locators.h" 641.1Sbouyer#include "pci.h" 651.1Sbouyer 661.1Sbouyerstatic int mainbus_match(device_t, cfdata_t, void *); 671.1Sbouyerstatic void mainbus_attach(device_t, device_t, void *); 681.1Sbouyerstatic int mainbus_print(void *, const char *); 691.1Sbouyer 701.1SbouyerCFATTACH_DECL_NEW(mainbus, 0, 711.1Sbouyer mainbus_match, mainbus_attach, NULL, NULL); 721.1Sbouyer 731.1Sbouyer/* There can be only one. */ 741.1Sbouyerstatic bool mainbus_found; 751.1Sbouyer 761.1Sbouyerconst char * const mainbusdevs[] = { 771.1Sbouyer "cpu", 781.1Sbouyer "bonito", 791.1Sbouyer#if 0 801.1Sbouyer "i2c", 811.1Sbouyer "gpio", 821.1Sbouyer#endif 831.1Sbouyer}; 841.1Sbouyer 851.1Sbouyerstatic int 861.1Sbouyermainbus_match(device_t parent, cfdata_t match, void *aux) 871.1Sbouyer{ 881.1Sbouyer if (mainbus_found) 891.1Sbouyer return (0); 901.1Sbouyer 911.1Sbouyer return (1); 921.1Sbouyer} 931.1Sbouyer 941.1Sbouyerstatic void 951.1Sbouyermainbus_attach(device_t parent, device_t self, void *aux) 961.1Sbouyer{ 971.1Sbouyer size_t i; 981.1Sbouyer 991.1Sbouyer mainbus_found = true; 1001.1Sbouyer aprint_normal("\n"); 1011.1Sbouyer 1021.1Sbouyer#if defined(PCI_NETBSD_CONFIGURE) 1031.1Sbouyer { 1041.1Sbouyer struct extent *ioext, *memext; 1051.1Sbouyer 1061.1Sbouyer ioext = extent_create("pciio", 0x00001000, 0x00003fff, 1071.1Sbouyer M_DEVBUF, NULL, 0, EX_NOWAIT); 1081.1Sbouyer memext = extent_create("pcimem", 0, BONITO_PCILO_SIZE, 1091.1Sbouyer M_DEVBUF, NULL, 0, EX_NOWAIT); 1101.1Sbouyer 1111.1Sbouyer pci_configure_bus(&gdium_configuration.gc_pc, ioext, memext, 1121.1Sbouyer NULL, 0, mips_dcache_align); 1131.1Sbouyer extent_destroy(ioext); 1141.1Sbouyer extent_destroy(memext); 1151.1Sbouyer } 1161.1Sbouyer#endif /* PCI_NETBSD_CONFIGURE */ 1171.1Sbouyer 1181.1Sbouyer for (i = 0; i < __arraycount(mainbusdevs); i++) { 1191.1Sbouyer struct mainbus_attach_args maa; 1201.1Sbouyer maa.maa_name = mainbusdevs[i]; 1211.1Sbouyer (void) config_found(self, &maa, mainbus_print); 1221.1Sbouyer } 1231.1Sbouyer} 1241.1Sbouyer 1251.1Sbouyerstatic int 1261.1Sbouyermainbus_print(void *aux, const char *pnp) 1271.1Sbouyer{ 1281.1Sbouyer struct mainbus_attach_args *maa = aux; 1291.1Sbouyer 1301.1Sbouyer if (pnp) 1311.1Sbouyer aprint_normal("%s at %s", maa->maa_name, pnp); 1321.1Sbouyer 1331.1Sbouyer return UNCONF; 1341.1Sbouyer} 135