Home | History | Annotate | Line # | Download | only in tc
tcasic.c revision 1.28
      1  1.28  nisimura /* $NetBSD: tcasic.c,v 1.28 2000/03/26 10:32:52 nisimura 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.1       cgd  *
      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.1       cgd  *
     15   1.1       cgd  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16   1.1       cgd  * 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.1       cgd  *
     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.28  nisimura __KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.28 2000/03/26 10:32:52 nisimura Exp $");
     36   1.1       cgd 
     37   1.1       cgd #include <sys/param.h>
     38   1.6       cgd #include <sys/systm.h>
     39   1.1       cgd #include <sys/device.h>
     40   1.1       cgd 
     41   1.1       cgd #include <machine/autoconf.h>
     42   1.1       cgd #include <machine/rpb.h>
     43  1.25      ross #include <machine/alpha.h>
     44  1.25      ross #include <machine/intrcnt.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.14       cgd int	tcasicmatch(struct device *, struct cfdata *, void *);
     51   1.1       cgd void	tcasicattach(struct device *, struct device *, void *);
     52   1.2   thorpej 
     53   1.2   thorpej struct cfattach tcasic_ca = {
     54   1.3       cgd 	sizeof (struct device), tcasicmatch, tcasicattach,
     55   1.2   thorpej };
     56   1.2   thorpej 
     57  1.21   thorpej extern struct cfdriver tcasic_cd;
     58   1.1       cgd 
     59   1.8       cgd int	tcasicprint __P((void *, const char *));
     60   1.1       cgd 
     61   1.1       cgd /* There can be only one. */
     62   1.1       cgd int	tcasicfound;
     63   1.1       cgd 
     64   1.1       cgd int
     65   1.1       cgd tcasicmatch(parent, cfdata, aux)
     66   1.1       cgd 	struct device *parent;
     67  1.14       cgd 	struct cfdata *cfdata;
     68   1.1       cgd 	void *aux;
     69   1.1       cgd {
     70  1.23   thorpej 	struct mainbus_attach_args *ma = aux;
     71   1.1       cgd 
     72   1.1       cgd         /* Make sure that we're looking for a TurboChannel ASIC. */
     73  1.23   thorpej         if (strcmp(ma->ma_name, tcasic_cd.cd_name))
     74   1.1       cgd                 return (0);
     75   1.1       cgd 
     76   1.1       cgd         /* Make sure that the system supports a TurboChannel ASIC. */
     77   1.1       cgd 	if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300))
     78   1.1       cgd 		return (0);
     79   1.1       cgd 
     80   1.1       cgd 	if (tcasicfound)
     81   1.1       cgd 		return (0);
     82   1.1       cgd 
     83   1.1       cgd 	return (1);
     84   1.1       cgd }
     85   1.1       cgd 
     86   1.1       cgd void
     87   1.1       cgd tcasicattach(parent, self, aux)
     88   1.1       cgd 	struct device *parent;
     89   1.1       cgd 	struct device *self;
     90   1.1       cgd 	void *aux;
     91   1.1       cgd {
     92   1.3       cgd 	struct tcbus_attach_args tba;
     93   1.1       cgd 	void (*intr_setup) __P((void));
     94   1.7       cgd 	void (*iointr) __P((void *, unsigned long));
     95   1.1       cgd 
     96  1.10  christos 	printf("\n");
     97   1.1       cgd 	tcasicfound = 1;
     98   1.1       cgd 
     99   1.1       cgd 	switch (cputype) {
    100   1.1       cgd #ifdef DEC_3000_500
    101   1.1       cgd 	case ST_DEC_3000_500:
    102   1.1       cgd 
    103   1.1       cgd 		intr_setup = tc_3000_500_intr_setup;
    104   1.1       cgd 		iointr = tc_3000_500_iointr;
    105   1.1       cgd 
    106   1.3       cgd 		tba.tba_speed = TC_SPEED_25_MHZ;
    107   1.3       cgd 		tba.tba_nslots = tc_3000_500_nslots;
    108   1.3       cgd 		tba.tba_slots = tc_3000_500_slots;
    109  1.13       cgd 		if (hwrpb->rpb_variation & SV_GRAPHICS) {
    110  1.13       cgd 			tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins;
    111  1.13       cgd 			tba.tba_builtins = tc_3000_500_graphics_builtins;
    112  1.13       cgd 		} else {
    113  1.13       cgd 			tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins;
    114  1.13       cgd 			tba.tba_builtins = tc_3000_500_nographics_builtins;
    115  1.13       cgd 		}
    116   1.3       cgd 		tba.tba_intr_establish = tc_3000_500_intr_establish;
    117   1.3       cgd 		tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
    118  1.22   thorpej 		tba.tba_get_dma_tag = tc_dma_get_tag_3000_500;
    119  1.18   thorpej 
    120  1.18   thorpej 		/* Do 3000/500-specific DMA setup now. */
    121  1.18   thorpej 		tc_dma_init_3000_500(tc_3000_500_nslots);
    122   1.1       cgd 		break;
    123   1.1       cgd #endif /* DEC_3000_500 */
    124   1.1       cgd 
    125   1.1       cgd #ifdef DEC_3000_300
    126   1.1       cgd 	case ST_DEC_3000_300:
    127   1.1       cgd 
    128   1.1       cgd 		intr_setup = tc_3000_300_intr_setup;
    129   1.1       cgd 		iointr = tc_3000_300_iointr;
    130   1.1       cgd 
    131   1.3       cgd 		tba.tba_speed = TC_SPEED_12_5_MHZ;
    132   1.3       cgd 		tba.tba_nslots = tc_3000_300_nslots;
    133   1.3       cgd 		tba.tba_slots = tc_3000_300_slots;
    134   1.3       cgd 		tba.tba_nbuiltins = tc_3000_300_nbuiltins;
    135   1.3       cgd 		tba.tba_builtins = tc_3000_300_builtins;
    136   1.3       cgd 		tba.tba_intr_establish = tc_3000_300_intr_establish;
    137   1.3       cgd 		tba.tba_intr_disestablish = tc_3000_300_intr_disestablish;
    138  1.22   thorpej 		tba.tba_get_dma_tag = tc_dma_get_tag_3000_300;
    139   1.1       cgd 		break;
    140   1.1       cgd #endif /* DEC_3000_300 */
    141   1.1       cgd 
    142   1.1       cgd 	default:
    143   1.1       cgd 		panic("tcasicattach: bad cputype");
    144   1.1       cgd 	}
    145   1.5       cgd 
    146  1.22   thorpej 	tba.tba_busname = "tc";
    147  1.11       cgd 	tba.tba_memt = tc_bus_mem_init(NULL);
    148  1.18   thorpej 
    149  1.18   thorpej 	tc_dma_init();
    150   1.1       cgd 
    151   1.1       cgd 	(*intr_setup)();
    152   1.1       cgd 	set_iointr(iointr);
    153   1.1       cgd 
    154   1.3       cgd 	config_found(self, &tba, tcasicprint);
    155   1.1       cgd }
    156   1.1       cgd 
    157   1.1       cgd int
    158   1.1       cgd tcasicprint(aux, pnp)
    159   1.1       cgd 	void *aux;
    160   1.8       cgd 	const char *pnp;
    161   1.1       cgd {
    162   1.1       cgd 
    163   1.1       cgd 	/* only TCs can attach to tcasics; easy. */
    164   1.1       cgd 	if (pnp)
    165  1.10  christos 		printf("tc at %s", pnp);
    166   1.1       cgd 	return (UNCONF);
    167   1.1       cgd }
    168  1.24    briggs 
    169  1.24    briggs #include "wsdisplay.h"
    170  1.24    briggs 
    171  1.24    briggs #if NWSDISPLAY > 0
    172  1.24    briggs 
    173  1.24    briggs #include "cfb.h"
    174  1.24    briggs #include "sfb.h"
    175  1.24    briggs 
    176  1.28  nisimura extern int	sfb_cnattach __P((tc_addr_t));
    177  1.28  nisimura extern int	cfb_cnattach __P((tc_addr_t));
    178  1.24    briggs extern int	tc_checkslot __P((tc_addr_t, char *));
    179  1.24    briggs 
    180  1.24    briggs /*
    181  1.24    briggs  * tc_fb_cnattach --
    182  1.24    briggs  *	Attempt to attach the appropriate display driver to the
    183  1.24    briggs  * output console.
    184  1.24    briggs  */
    185  1.24    briggs int
    186  1.24    briggs tc_fb_cnattach(tcaddr)
    187  1.24    briggs 	tc_addr_t tcaddr;
    188  1.24    briggs {
    189  1.24    briggs 	char tcname[TC_ROM_LLEN];
    190  1.24    briggs 
    191  1.24    briggs 	if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0)) {
    192  1.27  drochner 		return EINVAL;
    193  1.24    briggs 	}
    194  1.24    briggs 
    195  1.24    briggs #if NSFB > 0
    196  1.24    briggs 	if (strncmp("PMAGB-BA", tcname, TC_ROM_LLEN) == 0) {
    197  1.24    briggs 		sfb_cnattach(tcaddr);
    198  1.27  drochner 		return 0;
    199  1.24    briggs 	}
    200  1.24    briggs #endif
    201  1.24    briggs #if NCFB > 0
    202  1.24    briggs 	if (strncmp("PMAG-BA ", tcname, TC_ROM_LLEN) == 0) {
    203  1.24    briggs 		cfb_cnattach(tcaddr);
    204  1.27  drochner 		return 0;
    205  1.24    briggs 	}
    206  1.24    briggs #endif
    207  1.27  drochner 	return ENXIO;
    208  1.24    briggs }
    209  1.24    briggs #endif /* if NWSDISPLAY > 0 */
    210