tcbus.c revision 1.24
1/* $NetBSD: tcbus.c,v 1.24 2009/03/14 21:04:14 dsl 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.24 2009/03/14 21:04:14 dsl 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 56static const struct evcnt *tc_ds_intr_evcnt(struct device *, void *); 57static void tc_ds_intr_establish(struct device *, void *, 58 int, int (*)(void *), void *); 59static void tc_ds_intr_disestablish(struct device *, void *); 60static bus_dma_tag_t tc_ds_get_dma_tag(int); 61 62extern struct tcbus_attach_args kn02_tc_desc[]; /* XXX */ 63extern struct tcbus_attach_args kmin_tc_desc[]; /* XXX */ 64extern struct tcbus_attach_args xine_tc_desc[]; /* XXX */ 65extern struct tcbus_attach_args kn03_tc_desc[]; /* XXX */ 66 67static int tcbus_match(struct device *, struct cfdata *, void *); 68static void tcbus_attach(struct device *, struct device *, void *); 69 70CFATTACH_DECL(tcbus, sizeof(struct tc_softc), 71 tcbus_match, tcbus_attach, NULL, NULL); 72 73static int tcbus_found; 74 75static int 76tcbus_match(struct device *parent, struct cfdata *cfdata, void *aux) 77{ 78 struct mainbus_attach_args *ma = aux; 79 80 if (tcbus_found || strcmp(ma->ma_name, "tcbus")) 81 return 0; 82 83 return 1; 84} 85 86static void 87tcbus_attach(struct device *parent, struct device *self, void *aux) 88{ 89 struct tcbus_attach_args *tba; 90 91 tcbus_found = 1; 92 93 switch (systype) { 94#ifdef DEC_3MAX 95 case DS_3MAX: 96 tba = &kn02_tc_desc[0]; break; 97#endif 98#ifdef DEC_3MIN 99 case DS_3MIN: 100 tba = &kmin_tc_desc[0]; break; 101#endif 102#ifdef DEC_MAXINE 103 case DS_MAXINE: 104 tba = &xine_tc_desc[0]; break; 105#endif 106#ifdef DEC_3MAXPLUS 107 case DS_3MAXPLUS: 108 tba = &kn03_tc_desc[0]; break; 109#endif 110 default: 111 panic("tcbus_attach: no TURBOchannel configured for systype = %d", systype); 112 } 113 114 tba->tba_busname = "tc"; 115 tba->tba_memt = 0; 116 tba->tba_intr_evcnt = tc_ds_intr_evcnt; 117 tba->tba_intr_establish = tc_ds_intr_establish; 118 tba->tba_intr_disestablish = tc_ds_intr_disestablish; 119 tba->tba_get_dma_tag = tc_ds_get_dma_tag; 120 121 tcattach(parent, self, tba); 122} 123 124/* 125 * Dispatch to model specific interrupt line evcnt fetch rontine 126 */ 127static const struct evcnt * 128tc_ds_intr_evcnt(struct device *dev, void *cookie) 129{ 130 131 /* XXX for now, no evcnt parent reported */ 132 return NULL; 133} 134 135/* 136 * Dispatch to model specific interrupt establishing routine 137 */ 138static void 139tc_ds_intr_establish(dev, cookie, level, handler, val) 140 struct device *dev; 141 void *cookie; 142 int level; 143 int (*handler)(void *); 144 void *val; 145{ 146 147 (*platform.intr_establish)(dev, cookie, level, handler, val); 148} 149 150static void 151tc_ds_intr_disestablish(struct device *dev, void *arg) 152{ 153 154 printf("cannot disestablish TC interrupts\n"); 155} 156 157/* 158 * Return the DMA tag for use by the specified TURBOchannel slot. 159 */ 160static bus_dma_tag_t 161tc_ds_get_dma_tag(int slot) 162{ 163 /* 164 * All DECstations use the default DMA tag. 165 */ 166 return (&pmax_default_bus_dma_tag); 167} 168 169#include "wsdisplay.h" 170 171#if NWSDISPLAY > 0 172 173#include "sfb.h" 174/* #include "sfbp.h" */ 175#include "cfb.h" 176#include "mfb.h" 177#include "tfb.h" 178#include "xcfb.h" 179#include "px.h" 180#include "pxg.h" 181 182#include <pmax/pmax/cons.h> 183#include <machine/dec_prom.h> 184 185int tc_checkslot(tc_addr_t, char *); 186 187struct cnboards { 188 const char *cb_tcname; 189 void (*cb_cnattach)(tc_addr_t); 190} static const cnboards[] = { 191#if NXCFB > 0 192 { "PMAG-DV ", xcfb_cnattach }, 193#endif 194#if NSFB > 0 195 { "PMAGB-BA", sfb_cnattach }, 196#endif 197#if NSFBP > 0 198 { "PMAGD ", sfbp_cnattach }, 199#endif 200#if NCFB > 0 201 { "PMAG-BA ", cfb_cnattach }, 202#endif 203#if NMFB > 0 204 { "PMAG-AA ", mfb_cnattach }, 205#endif 206#if NTFB > 0 207 { "PMAG-JA ", tfb_cnattach }, 208#endif 209#if NPX > 0 210 { "PMAG-CA ", px_cnattach }, 211#endif 212#if NPXG > 0 213 { "PMAG-DA ", pxg_cnattach }, 214 { "PMAG-FA ", pxg_cnattach }, 215 { "PMAG-FB ", pxg_cnattach }, 216 { "PMAGB-FA", pxg_cnattach }, 217 { "PMAGB-FB", pxg_cnattach }, 218#endif 219}; 220 221int 222tcfb_cnattach(int slotno) 223{ 224 paddr_t tcaddr; 225 char tcname[TC_ROM_LLEN]; 226 int i; 227 228 tcaddr = (*callv->_slot_address)(slotno); 229 if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0) 230 panic("TC console designated by PROM does not exist!?"); 231 232 for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++) 233 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0) 234 break; 235 236 if (i == sizeof(cnboards) / sizeof(cnboards[0])) 237 return (0); 238 239 (cnboards[i].cb_cnattach)((tc_addr_t)TC_PHYS_TO_UNCACHED(tcaddr)); 240 return (1); 241} 242 243#endif /* NWSDISPLAY */ 244