Home | History | Annotate | Line # | Download | only in tc
tcasic.c revision 1.36
      1 /* $NetBSD: tcasic.c,v 1.36 2001/08/23 01:16:52 nisimura Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
      5  * All rights reserved.
      6  *
      7  * Author: Chris G. Demetriou
      8  *
      9  * Permission to use, copy, modify and distribute this software and
     10  * its documentation is hereby granted, provided that both the copyright
     11  * notice and this permission notice appear in all copies of the
     12  * software, derivative works or modified versions, and any portions
     13  * thereof, and that both notices appear in supporting documentation.
     14  *
     15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  *
     19  * Carnegie Mellon requests users of this software to return to
     20  *
     21  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  *  School of Computer Science
     23  *  Carnegie Mellon University
     24  *  Pittsburgh PA 15213-3890
     25  *
     26  * any improvements or extensions that they make and grant Carnegie the
     27  * rights to redistribute these changes.
     28  */
     29 
     30 #include "opt_dec_3000_300.h"
     31 #include "opt_dec_3000_500.h"
     32 
     33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     34 
     35 __KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.36 2001/08/23 01:16:52 nisimura Exp $");
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/device.h>
     40 
     41 #include <machine/autoconf.h>
     42 #include <machine/rpb.h>
     43 #include <machine/alpha.h>
     44 
     45 #include <dev/tc/tcvar.h>
     46 #include <alpha/tc/tc_conf.h>
     47 
     48 /* Definition of the driver for autoconfig. */
     49 int	tcasicmatch(struct device *, struct cfdata *, void *);
     50 void	tcasicattach(struct device *, struct device *, void *);
     51 
     52 struct cfattach tcasic_ca = {
     53 	sizeof (struct device), tcasicmatch, tcasicattach,
     54 };
     55 
     56 extern struct cfdriver tcasic_cd;
     57 
     58 int	tcasicprint __P((void *, const char *));
     59 
     60 /* There can be only one. */
     61 int	tcasicfound;
     62 
     63 int
     64 tcasicmatch(parent, cfdata, aux)
     65 	struct device *parent;
     66 	struct cfdata *cfdata;
     67 	void *aux;
     68 {
     69 	struct mainbus_attach_args *ma = aux;
     70 
     71         /* Make sure that we're looking for a TurboChannel ASIC. */
     72         if (strcmp(ma->ma_name, tcasic_cd.cd_name))
     73                 return (0);
     74 
     75         /* Make sure that the system supports a TurboChannel ASIC. */
     76 	if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300))
     77 		return (0);
     78 
     79 	if (tcasicfound)
     80 		return (0);
     81 
     82 	return (1);
     83 }
     84 
     85 void
     86 tcasicattach(parent, self, aux)
     87 	struct device *parent;
     88 	struct device *self;
     89 	void *aux;
     90 {
     91 	struct tcbus_attach_args tba;
     92 	void (*intr_setup) __P((void));
     93 	void (*iointr) __P((void *, unsigned long));
     94 
     95 	printf("\n");
     96 	tcasicfound = 1;
     97 
     98 	switch (cputype) {
     99 #ifdef DEC_3000_500
    100 	case ST_DEC_3000_500:
    101 
    102 		intr_setup = tc_3000_500_intr_setup;
    103 		iointr = tc_3000_500_iointr;
    104 
    105 		tba.tba_speed = TC_SPEED_25_MHZ;
    106 		tba.tba_nslots = tc_3000_500_nslots;
    107 		tba.tba_slots = tc_3000_500_slots;
    108 		if (hwrpb->rpb_variation & SV_GRAPHICS) {
    109 			tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins;
    110 			tba.tba_builtins = tc_3000_500_graphics_builtins;
    111 		} else {
    112 			tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins;
    113 			tba.tba_builtins = tc_3000_500_nographics_builtins;
    114 		}
    115 		tba.tba_intr_evcnt = tc_3000_500_intr_evcnt;
    116 		tba.tba_intr_establish = tc_3000_500_intr_establish;
    117 		tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
    118 		tba.tba_get_dma_tag = tc_dma_get_tag_3000_500;
    119 
    120 		/* Do 3000/500-specific DMA setup now. */
    121 		tc_dma_init_3000_500(tc_3000_500_nslots);
    122 		break;
    123 #endif /* DEC_3000_500 */
    124 
    125 #ifdef DEC_3000_300
    126 	case ST_DEC_3000_300:
    127 
    128 		intr_setup = tc_3000_300_intr_setup;
    129 		iointr = tc_3000_300_iointr;
    130 
    131 		tba.tba_speed = TC_SPEED_12_5_MHZ;
    132 		tba.tba_nslots = tc_3000_300_nslots;
    133 		tba.tba_slots = tc_3000_300_slots;
    134 		tba.tba_nbuiltins = tc_3000_300_nbuiltins;
    135 		tba.tba_builtins = tc_3000_300_builtins;
    136 		tba.tba_intr_evcnt = tc_3000_300_intr_evcnt;
    137 		tba.tba_intr_establish = tc_3000_300_intr_establish;
    138 		tba.tba_intr_disestablish = tc_3000_300_intr_disestablish;
    139 		tba.tba_get_dma_tag = tc_dma_get_tag_3000_300;
    140 		break;
    141 #endif /* DEC_3000_300 */
    142 
    143 	default:
    144 		panic("tcasicattach: bad cputype");
    145 	}
    146 
    147 	tba.tba_busname = "tc";
    148 	tba.tba_memt = tc_bus_mem_init(NULL);
    149 
    150 	tc_dma_init();
    151 
    152 	(*intr_setup)();
    153 
    154 	/* They all come in at 0x800. */
    155 	scb_set(0x800, iointr, NULL);
    156 
    157 	config_found(self, &tba, tcasicprint);
    158 }
    159 
    160 int
    161 tcasicprint(aux, pnp)
    162 	void *aux;
    163 	const char *pnp;
    164 {
    165 
    166 	/* only TCs can attach to tcasics; easy. */
    167 	if (pnp)
    168 		printf("tc at %s", pnp);
    169 	return (UNCONF);
    170 }
    171 
    172 #include "wsdisplay.h"
    173 
    174 #if NWSDISPLAY > 0
    175 
    176 #include "sfb.h"
    177 #include "sfbp.h"
    178 #include "cfb.h"
    179 #include "mfb.h"
    180 #include "tfb.h"
    181 #include "px.h"
    182 #include "pxg.h"
    183 
    184 extern void	sfb_cnattach __P((tc_addr_t));
    185 extern void	sfbp_cnattach __P((tc_addr_t));
    186 extern void	cfb_cnattach __P((tc_addr_t));
    187 extern void	mfb_cnattach __P((tc_addr_t));
    188 extern void	tfb_cnattach __P((tc_addr_t));
    189 extern void	px_cnattach __P((tc_addr_t));
    190 extern void	pxg_cnattach __P((tc_addr_t));
    191 extern int	tc_checkslot __P((tc_addr_t, char *));
    192 
    193 struct cnboards {
    194 	const char	*cb_tcname;
    195 	void	(*cb_cnattach)(tc_addr_t);
    196 } static const cnboards[] = {
    197 #if NSFB > 0
    198 	{ "PMAGB-BA", sfb_cnattach },
    199 #endif
    200 #if NSFBP > 0
    201 	{ "PMAGD   ", sfbp_cnattach },
    202 #endif
    203 #if NCFB > 0
    204 	{ "PMAG-BA ", cfb_cnattach },
    205 #endif
    206 #if NMFB > 0
    207 	{ "PMAG-AA ", mfb_cnattach },
    208 #endif
    209 #if NTFB > 0
    210 	{ "PMAG-JA ", tfb_cnattach },
    211 #endif
    212 #if NPX > 0
    213 	{ "PMAG-CA ", px_cnattach },
    214 #endif
    215 #if NPXG > 0
    216 	{ "PMAG-DA ", pxg_cnattach },
    217 	{ "PMAG-FA ", pxg_cnattach },
    218 	{ "PMAG-FB ", pxg_cnattach },
    219 	{ "PMAGB-FA", pxg_cnattach },
    220 	{ "PMAGB-FB", pxg_cnattach },
    221 #endif
    222 };
    223 
    224 /*
    225  * tc_fb_cnattach --
    226  *	Attempt to attach the appropriate display driver to the
    227  * output console.
    228  */
    229 int
    230 tc_fb_cnattach(tcaddr)
    231 	tc_addr_t tcaddr;
    232 {
    233 	char tcname[TC_ROM_LLEN];
    234 	int i;
    235 
    236 	if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0))
    237 		return (EINVAL);
    238 
    239 	for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++)
    240 		if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0)
    241 			break;
    242 
    243 	if (i == sizeof(cnboards) / sizeof(cnboards[0]))
    244 		return (ENXIO);
    245 
    246 	(cnboards[i].cb_cnattach)(tcaddr);
    247 	return (0);
    248 }
    249 #endif /* if NWSDISPLAY > 0 */
    250