1 /* $NetBSD: tcbus.c,v 1.21 2008/05/26 10:31:22 nisimura Exp $ */ 2 3 /*- 4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Tohru Nishimura. 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 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 __KERNEL_RCSID(0, "$NetBSD: tcbus.c,v 1.21 2008/05/26 10:31:22 nisimura Exp $"); 34 35 /* 36 * Which system models were configured? 37 */ 38 #include "opt_dec_3max.h" 39 #include "opt_dec_3min.h" 40 #include "opt_dec_maxine.h" 41 #include "opt_dec_3maxplus.h" 42 43 #include <sys/param.h> 44 #include <sys/systm.h> 45 #include <sys/device.h> 46 47 #include <machine/autoconf.h> 48 #include <machine/sysconf.h> 49 50 #define _PMAX_BUS_DMA_PRIVATE 51 #include <machine/bus.h> 52 53 #include <dev/tc/tcvar.h> 54 #include <pmax/pmax/pmaxtype.h> 55 56 static const struct evcnt *tc_ds_intr_evcnt __P((struct device *, void *)); 57 static void tc_ds_intr_establish __P((struct device *, void *, 58 int, int (*)(void *), void *)); 59 static void tc_ds_intr_disestablish __P((struct device *, void *)); 60 static bus_dma_tag_t tc_ds_get_dma_tag __P((int)); 61 62 extern struct tcbus_attach_args kn02_tc_desc[]; /* XXX */ 63 extern struct tcbus_attach_args kmin_tc_desc[]; /* XXX */ 64 extern struct tcbus_attach_args xine_tc_desc[]; /* XXX */ 65 extern struct tcbus_attach_args kn03_tc_desc[]; /* XXX */ 66 67 static int tcbus_match __P((struct device *, struct cfdata *, void *)); 68 static void tcbus_attach __P((struct device *, struct device *, void *)); 69 70 CFATTACH_DECL(tcbus, sizeof(struct tc_softc), 71 tcbus_match, tcbus_attach, NULL, NULL); 72 73 static int tcbus_found; 74 75 static int 76 tcbus_match(parent, cfdata, aux) 77 struct device *parent; 78 struct cfdata *cfdata; 79 void *aux; 80 { 81 struct mainbus_attach_args *ma = aux; 82 83 if (tcbus_found || strcmp(ma->ma_name, "tcbus")) 84 return 0; 85 86 return 1; 87 } 88 89 static void 90 tcbus_attach(parent, self, aux) 91 struct device *parent, *self; 92 void *aux; 93 { 94 struct tcbus_attach_args *tba; 95 96 tcbus_found = 1; 97 98 switch (systype) { 99 #ifdef DEC_3MAX 100 case DS_3MAX: 101 tba = &kn02_tc_desc[0]; break; 102 #endif 103 #ifdef DEC_3MIN 104 case DS_3MIN: 105 tba = &kmin_tc_desc[0]; break; 106 #endif 107 #ifdef DEC_MAXINE 108 case DS_MAXINE: 109 tba = &xine_tc_desc[0]; break; 110 #endif 111 #ifdef DEC_3MAXPLUS 112 case DS_3MAXPLUS: 113 tba = &kn03_tc_desc[0]; break; 114 #endif 115 default: 116 panic("tcbus_attach: no TURBOchannel configured for systype = %d", systype); 117 } 118 119 tba->tba_busname = "tc"; 120 tba->tba_memt = 0; 121 tba->tba_intr_evcnt = tc_ds_intr_evcnt; 122 tba->tba_intr_establish = tc_ds_intr_establish; 123 tba->tba_intr_disestablish = tc_ds_intr_disestablish; 124 tba->tba_get_dma_tag = tc_ds_get_dma_tag; 125 126 tcattach(parent, self, tba); 127 } 128 129 /* 130 * Dispatch to model specific interrupt line evcnt fetch rontine 131 */ 132 static const struct evcnt * 133 tc_ds_intr_evcnt(dev, cookie) 134 struct device *dev; 135 void *cookie; 136 { 137 138 /* XXX for now, no evcnt parent reported */ 139 return NULL; 140 } 141 142 /* 143 * Dispatch to model specific interrupt establishing routine 144 */ 145 static void 146 tc_ds_intr_establish(dev, cookie, level, handler, val) 147 struct device *dev; 148 void *cookie; 149 int level; 150 int (*handler) __P((void *)); 151 void *val; 152 { 153 154 (*platform.intr_establish)(dev, cookie, level, handler, val); 155 } 156 157 static void 158 tc_ds_intr_disestablish(dev, arg) 159 struct device *dev; 160 void *arg; 161 { 162 163 printf("cannot disestablish TC interrupts\n"); 164 } 165 166 /* 167 * Return the DMA tag for use by the specified TURBOchannel slot. 168 */ 169 static bus_dma_tag_t 170 tc_ds_get_dma_tag(slot) 171 int slot; 172 { 173 /* 174 * All DECstations use the default DMA tag. 175 */ 176 return (&pmax_default_bus_dma_tag); 177 } 178 179 #include "wsdisplay.h" 180 181 #if NWSDISPLAY > 0 182 183 #include "sfb.h" 184 /* #include "sfbp.h" */ 185 #include "cfb.h" 186 #include "mfb.h" 187 #include "tfb.h" 188 #include "xcfb.h" 189 #include "px.h" 190 #include "pxg.h" 191 192 #include <pmax/pmax/cons.h> 193 #include <machine/dec_prom.h> 194 195 int tc_checkslot __P((tc_addr_t, char *)); 196 197 struct cnboards { 198 const char *cb_tcname; 199 void (*cb_cnattach)(tc_addr_t); 200 } static const cnboards[] = { 201 #if NXCFB > 0 202 { "PMAG-DV ", xcfb_cnattach }, 203 #endif 204 #if NSFB > 0 205 { "PMAGB-BA", sfb_cnattach }, 206 #endif 207 #if NSFBP > 0 208 { "PMAGD ", sfbp_cnattach }, 209 #endif 210 #if NCFB > 0 211 { "PMAG-BA ", cfb_cnattach }, 212 #endif 213 #if NMFB > 0 214 { "PMAG-AA ", mfb_cnattach }, 215 #endif 216 #if NTFB > 0 217 { "PMAG-JA ", tfb_cnattach }, 218 #endif 219 #if NPX > 0 220 { "PMAG-CA ", px_cnattach }, 221 #endif 222 #if NPXG > 0 223 { "PMAG-DA ", pxg_cnattach }, 224 { "PMAG-FA ", pxg_cnattach }, 225 { "PMAG-FB ", pxg_cnattach }, 226 { "PMAGB-FA", pxg_cnattach }, 227 { "PMAGB-FB", pxg_cnattach }, 228 #endif 229 }; 230 231 int 232 tcfb_cnattach(slotno) 233 int slotno; 234 { 235 paddr_t tcaddr; 236 char tcname[TC_ROM_LLEN]; 237 int i; 238 239 tcaddr = (*callv->_slot_address)(slotno); 240 if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0) 241 panic("TC console designated by PROM does not exist!?"); 242 243 for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++) 244 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0) 245 break; 246 247 if (i == sizeof(cnboards) / sizeof(cnboards[0])) 248 return (0); 249 250 (cnboards[i].cb_cnattach)((tc_addr_t)TC_PHYS_TO_UNCACHED(tcaddr)); 251 return (1); 252 } 253 254 #endif /* NWSDISPLAY */ 255