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