Home | History | Annotate | Line # | Download | only in tc
tcbus.c revision 1.1
      1 /* $NetBSD: tcbus.c,v 1.1 1999/11/15 09:50:44 nisimura Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1999 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.1 1999/11/15 09:50:44 nisimura Exp $");
     35 
     36 #include <sys/param.h>
     37 #include <sys/systm.h>
     38 #include <sys/device.h>
     39 
     40 #include <machine/autoconf.h>
     41 
     42 #define	_PMAX_BUS_DMA_PRIVATE
     43 #include <machine/bus.h>
     44 
     45 #include <dev/tc/tcvar.h>
     46 #include <pmax/pmax/pmaxtype.h>
     47 
     48 /*
     49  * Which system models were configured?
     50  */
     51 #include "opt_dec_3max.h"
     52 #include "opt_dec_3min.h"
     53 #include "opt_dec_maxine.h"
     54 #include "opt_dec_3maxplus.h"
     55 
     56 /* XXX XXX TO BE REMOVED XXX XXX */
     57 /*
     58  * DECstation tc implementations dont' have a tcasic to handle interrupts,
     59  * and the mapping to CPU interrupt lines is model-dependent.
     60  * We have to pass TC interrupt establish/disestablish requests up to
     61  * motherboard-specific code.
     62  */
     63 void	tc_ds_intr_establish __P((struct device *, void *,
     64 				int, int (*)(void *), void *));
     65 void	tc_ds_intr_disestablish __P((struct device *, void *));
     66 extern void (*tc_enable_interrupt) __P ((unsigned, int (*)(void *), void *, int));
     67 /* XXX XXX XXX XXX XXX XXX XXX */
     68 
     69 bus_dma_tag_t tc_ds_get_dma_tag __P((int));
     70 
     71 extern struct tcbus_attach_args kn02_tc_desc[];
     72 extern struct tcbus_attach_args kmin_tc_desc[];
     73 extern struct tcbus_attach_args xine_tc_desc[];
     74 extern struct tcbus_attach_args kn03_tc_desc[];
     75 
     76 int  tcbus_match __P((struct device *, struct cfdata *, void *));
     77 void tcbus_attach __P((struct device *, struct device *, void *));
     78 
     79 struct cfattach tcbus_ca = {
     80 	sizeof(struct tc_softc), tcbus_match, tcbus_attach,
     81 };
     82 
     83 static int tcbus_found;
     84 
     85 int
     86 tcbus_match(parent, cfdata, aux)
     87 	struct device *parent;
     88 	struct cfdata *cfdata;
     89 	void *aux;
     90 {
     91 	struct mainbus_attach_args *ma = aux;
     92 
     93 	if (tcbus_found || strcmp(ma->ma_name, "tcbus"))
     94 		return 0;
     95 
     96 	return 1;
     97 }
     98 
     99 void
    100 tcbus_attach(parent, self, aux)
    101 	struct device *parent, *self;
    102 	void *aux;
    103 {
    104 	struct tcbus_attach_args *tba;
    105 
    106 	tcbus_found = 1;
    107 
    108 	switch (systype) {
    109 #ifdef DEC_3MAX
    110 	case DS_3MAX:
    111 		tba = &kn02_tc_desc[0]; break;
    112 #endif
    113 #ifdef DEC_3MIN
    114 	case DS_3MIN:
    115 		tba = &kmin_tc_desc[0]; break;
    116 #endif
    117 #ifdef DEC_MAXINE
    118 	case DS_MAXINE:
    119 		tba = &xine_tc_desc[0]; break;
    120 #endif
    121 #ifdef DEC_3MAXPLUS
    122 	case DS_3MAXPLUS:
    123 		tba = &kn03_tc_desc[0]; break;
    124 #endif
    125 	default:
    126 		panic("config_tba: no TURBOchannel configured for systype %d",
    127 		systype);
    128 	}
    129 
    130 	tba->tba_busname = "tc";
    131 	tba->tba_memt = 0;
    132 	tba->tba_intr_establish = tc_ds_intr_establish;
    133 	tba->tba_intr_disestablish = tc_ds_intr_disestablish;
    134 	tba->tba_get_dma_tag = tc_ds_get_dma_tag;
    135 
    136 	tcattach(parent, self, tba);
    137 }
    138 
    139 /*
    140  * Return the DMA tag for use by the specified TURBOchannel slot.
    141  */
    142 bus_dma_tag_t
    143 tc_ds_get_dma_tag(slot)
    144 	int slot;
    145 {
    146 	/*
    147 	 * All DECstations use the default DMA tag.
    148 	 */
    149 	return (&pmax_default_bus_dma_tag);
    150 }
    151 
    152 /*
    153  * Establish an interrupt handler.
    154  * For both TC and IOCTL asic, we must upcall to motherboard-specific
    155  * interrupt-hanlder functions,  in case we need to recompute masks for
    156  * CPU interrupt lines.
    157  */
    158 void
    159 tc_ds_intr_establish(dev, cookie, level, handler, val)
    160 	struct device *dev;
    161 	void *cookie;
    162 	int level;
    163         int (*handler) __P((void *));
    164 	void *val;
    165 {
    166 
    167 #ifdef DIAGNOSTIC
    168 	if (tc_enable_interrupt == NULL)
    169 	    panic("tc_intr_establish: tc_enable not set\n");
    170 #endif
    171 
    172 #ifdef DEBUG
    173 	printf("tc_intr_establish: slot %d level %d handler %p sc %p on\n",
    174 		(int) cookie, (int) level, handler,  val);
    175 #endif
    176 
    177 	 /*
    178 	  * Enable the interrupt from tc (or ioctl asic) slot with NetBSD/pmax
    179 	  * sw-convention name ``cookie'' on this CPU.
    180 	  * XXX store the level somewhere for selective enabling of
    181 	  * interrupts from TC option slots.
    182 	  */
    183 	 (*tc_enable_interrupt)((unsigned)cookie, handler, val, 1);
    184 }
    185 
    186 void
    187 tc_ds_intr_disestablish(dev, arg)
    188 	struct device *dev;
    189 	void *arg;
    190 {
    191 	/*(*tc_enable_interrupt) (ca->ca_slot, handler, 0);*/
    192     	printf("cannot dis-establish IOASIC interrupts\n");
    193 }
    194 
    195 #include "rasterconsole.h"
    196 
    197 #if NRASTERCONSOLE > 0
    198 
    199 #include "mfb.h"
    200 #include "cfb.h"
    201 #include "sfb.h"
    202 #include "px.h"
    203 
    204 #include <machine/fbio.h>
    205 #include <machine/fbvar.h>
    206 #include <pmax/dev/cfbvar.h>
    207 #include <pmax/dev/mfbvar.h>
    208 #include <pmax/dev/sfbvar.h>
    209 
    210 extern int px_init __P((struct fbinfo*, char *, int, int));
    211 
    212 #include <machine/dec_prom.h>
    213 
    214 int tcfb_cnattach __P((int));
    215 
    216 int
    217 tcfb_cnattach(slotno)
    218 	int slotno;
    219 {
    220 	tc_addr_t tcaddr;
    221 	char tcname[TC_ROM_LLEN];
    222 	struct fbinfo *fi;
    223 
    224 	tcaddr = (*callv->_slot_address)(slotno);
    225 	if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0)
    226 		panic("TC console designated by PROM does not exist!?");
    227 
    228 #if NSFB > 0
    229 	if (strncmp("PMAGB-BA", tcname, TC_ROM_LLEN) == 0) {
    230 		fballoc((caddr_t)tcaddr, &fi);
    231 		sfbinit(fi, (caddr_t)tcaddr, 0, 1);
    232 		return 1;
    233 	}
    234 #endif
    235 #if NCFB > 0
    236 	if (strncmp("PMAG-BA ", tcname, TC_ROM_LLEN) == 0) {
    237 		fballoc((caddr_t)tcaddr, &fi);
    238 		cfbinit(fi, (caddr_t)tcaddr, 0, 1);
    239 		return 1;
    240 	}
    241 #endif
    242 #if NMFB > 0
    243 	if (strncmp("PMAG-AA ", tcname, TC_ROM_LLEN) == 0) {
    244 		fballoc((caddr_t)tcaddr, &fi);
    245 		mfbinit(fi, (caddr_t)tcaddr, 0, 1);
    246 		return 1;
    247 	}
    248 #endif
    249 #if NPX > 0
    250 	if (strncmp("PMAG-CA ", tcname, TC_ROM_LLEN) == 0
    251 	    || strncmp("PMAG-CA ", tcname, TC_ROM_LLEN) == 0
    252 	    || strncmp("PMAG-FA ", tcname, TC_ROM_LLEN) == 0) {
    253 		fballoc((caddr_t)tcaddr, &fi);
    254 		px_init(fi, (caddr_t)tcaddr, 0, 1);
    255 		return 1;
    256 	}
    257 #endif
    258 	return 0;
    259 }
    260 
    261 #endif
    262