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