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