1 /* $NetBSD: obio.c,v 1.12 2005/12/11 12:18:13 christos Exp $ */ 2 3 /*- 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Wayne Knowles 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include <sys/cdefs.h> 40 __KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.12 2005/12/11 12:18:13 christos Exp $"); 41 42 #include "locators.h" 43 44 #include <sys/param.h> 45 #include <sys/systm.h> 46 #include <sys/device.h> 47 48 #include <machine/autoconf.h> 49 #include <machine/mainboard.h> 50 #include <machine/bus.h> 51 #include <machine/sysconf.h> 52 53 static int obio_match __P((struct device *, struct cfdata *, void *)); 54 static void obio_attach __P((struct device *, struct device *, void *)); 55 static int obio_search __P((struct device *, struct cfdata *, 56 const int *, void *)); 57 static int obio_print __P((void *, const char *)); 58 static void obio_intr_establish __P((bus_space_tag_t, int, int, int, 59 int (*)(void *), void *)); 60 61 CFATTACH_DECL(obio, sizeof(struct device), 62 obio_match, obio_attach, NULL, NULL); 63 64 extern struct cfdriver obio_cd; 65 66 struct mipsco_bus_space obio_bustag; 67 struct mipsco_bus_dma_tag obio_dmatag; 68 69 static int 70 obio_match(parent, cf, aux) 71 struct device *parent; 72 struct cfdata *cf; 73 void *aux; 74 { 75 struct confargs *ca = aux; 76 77 if (strcmp(ca->ca_name, obio_cd.cd_name) != 0) 78 return 0; 79 80 return 1; 81 } 82 83 static void 84 obio_attach(parent, self, aux) 85 struct device *parent; 86 struct device *self; 87 void *aux; 88 { 89 struct confargs *ca = aux; 90 91 /* PIZAZZ (Mips 3000 Magnum) Address Map */ 92 mipsco_bus_space_init(&obio_bustag, "obio", 93 0x18000000, 0xb8000000, 94 0xb8000000, 0x08000000); 95 96 _bus_dma_tag_init(&obio_dmatag); 97 obio_bustag.bs_intr_establish = obio_intr_establish; /* XXX */ 98 99 ca->ca_bustag = &obio_bustag; 100 ca->ca_dmatag = &obio_dmatag; 101 102 printf("\n"); 103 config_search_ia(obio_search, self, "obio", ca); 104 } 105 106 static int 107 obio_search(parent, cf, ldesc, aux) 108 struct device *parent; 109 struct cfdata *cf; 110 const int *ldesc; 111 void *aux; 112 { 113 struct confargs *ca = aux; 114 115 ca->ca_addr = cf->cf_addr; 116 ca->ca_name = cf->cf_name; 117 118 if (config_match(parent, cf, ca) != 0) 119 config_attach(parent, cf, ca, obio_print); 120 121 return 0; 122 } 123 124 /* 125 * Print out the confargs. The (parent) name is non-NULL 126 * when there was no match found by config_found(). 127 */ 128 static int 129 obio_print(args, name) 130 void *args; 131 const char *name; 132 { 133 struct confargs *ca = args; 134 135 if (name) 136 return(QUIET); 137 138 if (ca->ca_addr != -1) 139 aprint_normal(" addr 0x%x", ca->ca_addr); 140 141 return(UNCONF); 142 } 143 144 void 145 obio_intr_establish(bst, level, pri, flags, func, arg) 146 bus_space_tag_t bst; 147 int level; 148 int pri; 149 int flags; 150 int (*func) __P((void *)); 151 void *arg; 152 { 153 (*platform.intr_establish)(level, func, arg); 154 } 155