Home | History | Annotate | Line # | Download | only in tc
tcbus.c revision 1.10
      1 /*	$NetBSD: tcbus.c,v 1.10 2000/02/29 09:03:30 nisimura Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1999, 2000 Tohru Nishimura.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *      This product includes software developed by Tohru Nishimura
     17  *	for the NetBSD Project.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     34 __KERNEL_RCSID(0, "$NetBSD: tcbus.c,v 1.10 2000/02/29 09:03:30 nisimura Exp $");
     35 
     36 /*
     37  * Which system models were configured?
     38  */
     39 #include "opt_dec_3max.h"
     40 #include "opt_dec_3min.h"
     41 #include "opt_dec_maxine.h"
     42 #include "opt_dec_3maxplus.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/sysconf.h>
     50 
     51 #define	_PMAX_BUS_DMA_PRIVATE
     52 #include <machine/bus.h>
     53 
     54 #include <dev/tc/tcvar.h>
     55 #include <pmax/pmax/pmaxtype.h>
     56 
     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 struct cfattach tcbus_ca = {
     71 	sizeof(struct tc_softc), tcbus_match, tcbus_attach,
     72 };
     73 
     74 static int tcbus_found;
     75 
     76 static int
     77 tcbus_match(parent, cfdata, aux)
     78 	struct device *parent;
     79 	struct cfdata *cfdata;
     80 	void *aux;
     81 {
     82 	struct mainbus_attach_args *ma = aux;
     83 
     84 	if (tcbus_found || strcmp(ma->ma_name, "tcbus"))
     85 		return 0;
     86 
     87 	return 1;
     88 }
     89 
     90 static void
     91 tcbus_attach(parent, self, aux)
     92 	struct device *parent, *self;
     93 	void *aux;
     94 {
     95 	struct tcbus_attach_args *tba;
     96 
     97 	tcbus_found = 1;
     98 
     99 	switch (systype) {
    100 #ifdef DEC_3MAX
    101 	case DS_3MAX:
    102 		tba = &kn02_tc_desc[0]; break;
    103 #endif
    104 #ifdef DEC_3MIN
    105 	case DS_3MIN:
    106 		tba = &kmin_tc_desc[0]; break;
    107 #endif
    108 #ifdef DEC_MAXINE
    109 	case DS_MAXINE:
    110 		tba = &xine_tc_desc[0]; break;
    111 #endif
    112 #ifdef DEC_3MAXPLUS
    113 	case DS_3MAXPLUS:
    114 		tba = &kn03_tc_desc[0]; break;
    115 #endif
    116 	default:
    117 		panic("tcbus_attach: no TURBOchannel configured for systype = %d", systype);
    118 	}
    119 
    120 	tba->tba_busname = "tc";
    121 	tba->tba_memt = 0;
    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 establishing routine
    131  */
    132 static void
    133 tc_ds_intr_establish(dev, cookie, level, handler, val)
    134 	struct device *dev;
    135 	void *cookie;
    136 	int level;
    137         int (*handler) __P((void *));
    138 	void *val;
    139 {
    140 
    141 	 (*platform.intr_establish)(dev, cookie, level, handler, val);
    142 }
    143 
    144 static void
    145 tc_ds_intr_disestablish(dev, arg)
    146 	struct device *dev;
    147 	void *arg;
    148 {
    149 
    150     	printf("cannot disestablish TC interrupts\n");
    151 }
    152 
    153 /*
    154  * Return the DMA tag for use by the specified TURBOchannel slot.
    155  */
    156 static bus_dma_tag_t
    157 tc_ds_get_dma_tag(slot)
    158 	int slot;
    159 {
    160 	/*
    161 	 * All DECstations use the default DMA tag.
    162 	 */
    163 	return (&pmax_default_bus_dma_tag);
    164 }
    165 
    166 #include "rasterconsole.h"
    167 
    168 #if NRASTERCONSOLE > 0
    169 
    170 #include "mfb.h"
    171 #include "cfb.h"
    172 #include "sfb.h"
    173 #include "px.h"
    174 
    175 #include <machine/pmioctl.h>	/* XXX */
    176 #include <machine/fbio.h>	/* XXX */
    177 #include <machine/fbvar.h>	/* XXX */
    178 #include <pmax/dev/fbreg.h>	/* XXX */
    179 #include <pmax/dev/cfbvar.h>
    180 #include <pmax/dev/mfbvar.h>
    181 #include <pmax/dev/sfbvar.h>
    182 #include <pmax/dev/pxreg.h>
    183 #include <pmax/dev/pxvar.h>
    184 
    185 #include <machine/dec_prom.h>
    186 
    187 int
    188 tcfb_cnattach(slotno)
    189 	int slotno;
    190 {
    191 	paddr_t tcaddr;
    192 	char tcname[TC_ROM_LLEN];
    193 
    194 	tcaddr = (*callv->_slot_address)(slotno);
    195 	if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0)
    196 		panic("TC console designated by PROM does not exist!?");
    197 
    198 #if NSFB > 0
    199 	if (strncmp("PMAGB-BA", tcname, TC_ROM_LLEN) == 0) {
    200 		return sfb_cnattach(tcaddr);
    201 	}
    202 #endif
    203 #if NCFB > 0
    204 	if (strncmp("PMAG-BA ", tcname, TC_ROM_LLEN) == 0) {
    205 		return cfb_cnattach(tcaddr);
    206 	}
    207 #endif
    208 #if NMFB > 0
    209 	if (strncmp("PMAG-AA ", tcname, TC_ROM_LLEN) == 0) {
    210 		return mfb_cnattach(tcaddr);
    211 	}
    212 #endif
    213 #if NPX > 0
    214 	if (strncmp("PMAG-CA ", tcname, TC_ROM_LLEN) == 0
    215 	    || strncmp("PMAG-DA ", tcname, TC_ROM_LLEN) == 0
    216 	    || strncmp("PMAG-FA ", tcname, TC_ROM_LLEN) == 0) {
    217 		int px_cnattach __P((paddr_t)); /* XXX much simpler XXX */
    218 
    219 		return px_cnattach(tcaddr);
    220 	}
    221 #endif
    222 	return 0;
    223 }
    224 
    225 #endif
    226