mainbus.c revision 1.1
11.1Sjmcneill/* $NetBSD: mainbus.c,v 1.1 2026/01/09 22:54:29 jmcneill Exp $ */ 21.1Sjmcneill 31.1Sjmcneill/* 41.1Sjmcneill * Copyright (c) 2002, 2024 The NetBSD Foundation, Inc. 51.1Sjmcneill * All rights reserved. 61.1Sjmcneill * 71.1Sjmcneill * This code is derived from software contributed to The NetBSD Foundation 81.1Sjmcneill * by Lennart Augustsson (lennart@augustsson.net) at Sandburst Corp. 91.1Sjmcneill * 101.1Sjmcneill * Redistribution and use in source and binary forms, with or without 111.1Sjmcneill * modification, are permitted provided that the following conditions 121.1Sjmcneill * are met: 131.1Sjmcneill * 1. Redistributions of source code must retain the above copyright 141.1Sjmcneill * notice, this list of conditions and the following disclaimer. 151.1Sjmcneill * 2. Redistributions in binary form must reproduce the above copyright 161.1Sjmcneill * notice, this list of conditions and the following disclaimer in the 171.1Sjmcneill * documentation and/or other materials provided with the distribution. 181.1Sjmcneill * 191.1Sjmcneill * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sjmcneill * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sjmcneill * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sjmcneill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sjmcneill * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sjmcneill * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sjmcneill * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sjmcneill * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sjmcneill * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sjmcneill * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sjmcneill * POSSIBILITY OF SUCH DAMAGE. 301.1Sjmcneill */ 311.1Sjmcneill 321.1Sjmcneill#include <sys/cdefs.h> 331.1Sjmcneill__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.1 2026/01/09 22:54:29 jmcneill Exp $"); 341.1Sjmcneill 351.1Sjmcneill#include <sys/param.h> 361.1Sjmcneill#include <sys/device.h> 371.1Sjmcneill#include <sys/systm.h> 381.1Sjmcneill 391.1Sjmcneill#include <sys/bus.h> 401.1Sjmcneill#include <machine/wii.h> 411.1Sjmcneill#include <machine/wiiu.h> 421.1Sjmcneill#include <machine/pio.h> 431.1Sjmcneill#include <arch/evbppc/nintendo/dev/mainbus.h> 441.1Sjmcneill 451.1Sjmcneill#include "locators.h" 461.1Sjmcneill 471.1Sjmcneillextern struct powerpc_bus_space wii_mem_tag; 481.1Sjmcneillextern struct powerpc_bus_dma_tag wii_bus_dma_tag; 491.1Sjmcneill 501.1Sjmcneillint mainbus_match(device_t, cfdata_t, void *); 511.1Sjmcneillvoid mainbus_attach(device_t, device_t, void *); 521.1Sjmcneill 531.1SjmcneillCFATTACH_DECL_NEW(mainbus, 0, 541.1Sjmcneill mainbus_match, mainbus_attach, NULL, NULL); 551.1Sjmcneill 561.1Sjmcneillint 571.1Sjmcneillmainbus_match(device_t parent, cfdata_t match, void *aux) 581.1Sjmcneill{ 591.1Sjmcneill return 1; 601.1Sjmcneill} 611.1Sjmcneill 621.1Sjmcneillstatic int 631.1Sjmcneillmainbus_print(void *aux, const char *pnp) 641.1Sjmcneill{ 651.1Sjmcneill struct mainbus_attach_args *mba = aux; 661.1Sjmcneill 671.1Sjmcneill if (pnp) { 681.1Sjmcneill aprint_normal("%s at %s", mba->maa_name, pnp); 691.1Sjmcneill } 701.1Sjmcneill if (mba->maa_addr != MAINBUSCF_ADDR_DEFAULT) { 711.1Sjmcneill aprint_normal(" addr 0x%08lx", mba->maa_addr); 721.1Sjmcneill } 731.1Sjmcneill if (mba->maa_irq != MAINBUSCF_IRQ_DEFAULT) { 741.1Sjmcneill aprint_normal(" irq %d", mba->maa_irq); 751.1Sjmcneill } 761.1Sjmcneill return UNCONF; 771.1Sjmcneill} 781.1Sjmcneill 791.1Sjmcneillvoid 801.1Sjmcneillmainbus_attach(device_t parent, device_t self, void *aux) 811.1Sjmcneill{ 821.1Sjmcneill struct mainbus_attach_args maa; 831.1Sjmcneill int maxcpu, n; 841.1Sjmcneill 851.1Sjmcneill aprint_normal(": Nintendo Wii%s%s\n", 861.1Sjmcneill wiiu_plat ? " U" : "", 871.1Sjmcneill (!wiiu_plat || wiiu_native) ? "" : " (vWii)"); 881.1Sjmcneill 891.1Sjmcneill maa.maa_bst = &wii_mem_tag; 901.1Sjmcneill maa.maa_dmat = &wii_bus_dma_tag; 911.1Sjmcneill 921.1Sjmcneill maxcpu = wiiu_native ? 3 : 1; 931.1Sjmcneill 941.1Sjmcneill for (n = 0; n < uimin(maxcpu, CPU_MAXNUM); n++) { 951.1Sjmcneill maa.maa_name = "cpu"; 961.1Sjmcneill maa.maa_addr = MAINBUSCF_ADDR_DEFAULT; 971.1Sjmcneill maa.maa_irq = MAINBUSCF_IRQ_DEFAULT; 981.1Sjmcneill config_found(self, &maa, mainbus_print, CFARGS_NONE); 991.1Sjmcneill } 1001.1Sjmcneill 1011.1Sjmcneill maa.maa_name = "exi"; 1021.1Sjmcneill maa.maa_addr = EXI_BASE; 1031.1Sjmcneill maa.maa_irq = PI_IRQ_EXI; 1041.1Sjmcneill config_found(self, &maa, mainbus_print, CFARGS_NONE); 1051.1Sjmcneill 1061.1Sjmcneill maa.maa_name = "genfb"; 1071.1Sjmcneill maa.maa_addr = VI_BASE; 1081.1Sjmcneill maa.maa_irq = PI_IRQ_VI; 1091.1Sjmcneill config_found(self, &maa, mainbus_print, CFARGS_NONE); 1101.1Sjmcneill 1111.1Sjmcneill maa.maa_name = "ahb"; 1121.1Sjmcneill maa.maa_addr = MAINBUSCF_ADDR_DEFAULT; 1131.1Sjmcneill maa.maa_irq = PI_IRQ_HOLLYWOOD; 1141.1Sjmcneill config_found(self, &maa, mainbus_print, CFARGS_NONE); 1151.1Sjmcneill 1161.1Sjmcneill maa.maa_name = "bwai"; 1171.1Sjmcneill maa.maa_addr = AI_BASE; 1181.1Sjmcneill maa.maa_irq = PI_IRQ_AI; 1191.1Sjmcneill config_found(self, &maa, mainbus_print, CFARGS_NONE); 1201.1Sjmcneill 1211.1Sjmcneill maa.maa_name = "bwdsp"; 1221.1Sjmcneill maa.maa_addr = wiiu_native ? WIIU_DSP_BASE : DSP_BASE; 1231.1Sjmcneill maa.maa_irq = MAINBUSCF_IRQ_DEFAULT; 1241.1Sjmcneill config_found(self, &maa, mainbus_print, CFARGS_NONE); 1251.1Sjmcneill 1261.1Sjmcneill if (!wiiu_native) { 1271.1Sjmcneill maa.maa_name = "si"; 1281.1Sjmcneill maa.maa_addr = SI_BASE; 1291.1Sjmcneill maa.maa_irq = PI_IRQ_SI; 1301.1Sjmcneill config_found(self, &maa, mainbus_print, CFARGS_NONE); 1311.1Sjmcneill } 1321.1Sjmcneill} 133