mainbus.c revision 1.6
1/* $NetBSD: mainbus.c,v 1.6 2017/05/19 07:40:58 skrll Exp $ */ 2 3/*- 4 * Copyright (c) 2014 Michael Lorenz 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.6 2017/05/19 07:40:58 skrll Exp $"); 31 32#include "opt_multiprocessor.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/device.h> 37 38#include <mips/cache.h> 39#include <mips/cpuregs.h> 40 41#include <mips/ingenic/ingenic_regs.h> 42 43#include "opt_ingenic.h" 44 45#include "locators.h" 46 47static int mainbus_match(device_t, cfdata_t, void *); 48static void mainbus_attach(device_t, device_t, void *); 49static int mainbus_print(void *, const char *); 50 51CFATTACH_DECL_NEW(mainbus, 0, 52 mainbus_match, mainbus_attach, NULL, NULL); 53 54/* There can be only one. */ 55int mainbus_found = 0; 56 57struct mainbusdev { 58 const char *md_name; 59}; 60 61struct mainbusdev mainbusdevs[] = { 62 { "cpu", }, 63#ifdef MULTIPROCESSOR 64 { "cpu", }, 65#endif 66 { "apbus", }, 67 { NULL, } 68}; 69 70static int 71mainbus_match(device_t parent, cfdata_t match, void *aux) 72{ 73 74 if (mainbus_found) 75 return (0); 76 77 return (1); 78} 79 80static void 81mainbus_attach(device_t parent, device_t self, void *aux) 82{ 83 const struct mainbusdev *md; 84 85 mainbus_found = 1; 86 printf("\n"); 87 88 for (md = mainbusdevs; md->md_name != NULL; md++) { 89 struct mainbusdev ma = *md; 90 config_found_ia(self, "mainbus", &ma, mainbus_print); 91 } 92 93#ifdef INGENIC_DEBUG 94 printf("TFR: %08x\n", readreg(JZ_TC_TFR)); 95 printf("TMR: %08x\n", readreg(JZ_TC_TMR)); 96 97 /* send ourselves an IPI */ 98 MTC0(0x12345678, CP0_CORE_MBOX, 0); 99 delay(1000); 100 101 /* send the other core an IPI */ 102 MTC0(0x12345678, CP0_CORE_MBOX, 1); 103 delay(1000); 104#endif 105} 106 107static int 108mainbus_print(void *aux, const char *pnp) 109{ 110 111 return (QUIET); 112} 113