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