mainbus.c revision 1.3
11.3Smacallan/* $NetBSD: mainbus.c,v 1.3 2014/12/23 15:09:13 macallan Exp $ */ 21.1Smacallan 31.1Smacallan/*- 41.1Smacallan * Copyright (c) 2014 Michael Lorenz 51.1Smacallan * All rights reserved. 61.1Smacallan * 71.1Smacallan * Redistribution and use in source and binary forms, with or without 81.1Smacallan * modification, are permitted provided that the following conditions 91.1Smacallan * are met: 101.1Smacallan * 1. Redistributions of source code must retain the above copyright 111.1Smacallan * notice, this list of conditions and the following disclaimer. 121.1Smacallan * 2. Redistributions in binary form must reproduce the above copyright 131.1Smacallan * notice, this list of conditions and the following disclaimer in the 141.1Smacallan * documentation and/or other materials provided with the distribution. 151.1Smacallan * 161.1Smacallan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 171.1Smacallan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 181.1Smacallan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 191.1Smacallan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 201.1Smacallan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 211.1Smacallan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 221.1Smacallan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 231.1Smacallan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 241.1Smacallan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 251.1Smacallan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 261.1Smacallan * POSSIBILITY OF SUCH DAMAGE. 271.1Smacallan */ 281.1Smacallan 291.1Smacallan#include <sys/cdefs.h> 301.3Smacallan__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.3 2014/12/23 15:09:13 macallan Exp $"); 311.1Smacallan 321.1Smacallan#include <sys/param.h> 331.1Smacallan#include <sys/systm.h> 341.1Smacallan#include <sys/device.h> 351.1Smacallan 361.1Smacallan#include <mips/cache.h> 371.1Smacallan#include <mips/cpuregs.h> 381.1Smacallan 391.2Smacallan#include <mips/ingenic/ingenic_regs.h> 401.2Smacallan 411.3Smacallan#include "opt_ingenic.h" 421.3Smacallan 431.1Smacallan#include "locators.h" 441.1Smacallan 451.1Smacallanstatic int mainbus_match(device_t, cfdata_t, void *); 461.1Smacallanstatic void mainbus_attach(device_t, device_t, void *); 471.1Smacallanstatic int mainbus_print(void *, const char *); 481.1Smacallan 491.1SmacallanCFATTACH_DECL_NEW(mainbus, 0, 501.1Smacallan mainbus_match, mainbus_attach, NULL, NULL); 511.1Smacallan 521.1Smacallan/* There can be only one. */ 531.1Smacallanint mainbus_found = 0; 541.1Smacallan 551.1Smacallanstruct mainbusdev { 561.1Smacallan const char *md_name; 571.1Smacallan}; 581.1Smacallan 591.1Smacallanstruct mainbusdev mainbusdevs[] = { 601.1Smacallan { "cpu", }, 611.1Smacallan { "com", }, 621.2Smacallan { "apbus", }, 631.1Smacallan { NULL, } 641.1Smacallan}; 651.1Smacallan 661.1Smacallanstatic int 671.1Smacallanmainbus_match(device_t parent, cfdata_t match, void *aux) 681.1Smacallan{ 691.1Smacallan 701.1Smacallan if (mainbus_found) 711.1Smacallan return (0); 721.1Smacallan 731.1Smacallan return (1); 741.1Smacallan} 751.1Smacallan 761.1Smacallanstatic void 771.1Smacallanmainbus_attach(device_t parent, device_t self, void *aux) 781.1Smacallan{ 791.1Smacallan const struct mainbusdev *md; 801.1Smacallan 811.1Smacallan mainbus_found = 1; 821.1Smacallan printf("\n"); 831.1Smacallan 841.1Smacallan for (md = mainbusdevs; md->md_name != NULL; md++) { 851.1Smacallan struct mainbusdev ma = *md; 861.1Smacallan config_found_ia(self, "mainbus", &ma, mainbus_print); 871.1Smacallan } 881.2Smacallan 891.2Smacallan#ifdef INGENIC_DEBUG 901.2Smacallan printf("TFR: %08x\n", readreg(JZ_TC_TFR)); 911.2Smacallan printf("TMR: %08x\n", readreg(JZ_TC_TMR)); 921.2Smacallan 931.2Smacallan /* send ourselves an IPI */ 941.2Smacallan MTC0(0x12345678, CP0_CORE_MBOX, 0); 951.2Smacallan delay(1000); 961.2Smacallan#endif 971.1Smacallan} 981.1Smacallan 991.1Smacallanstatic int 1001.1Smacallanmainbus_print(void *aux, const char *pnp) 1011.1Smacallan{ 1021.1Smacallan 1031.1Smacallan return (QUIET); 1041.1Smacallan} 105