Home | History | Annotate | Line # | Download | only in pci
apecs.c revision 1.5
      1 /*	$NetBSD: apecs.c,v 1.5 1996/03/17 01:06:30 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1995 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 <sys/param.h>
     31 #include <sys/systm.h>
     32 #include <sys/kernel.h>
     33 #include <sys/malloc.h>
     34 #include <sys/device.h>
     35 #include <vm/vm.h>
     36 
     37 #include <machine/autoconf.h>
     38 #include <machine/rpb.h>
     39 
     40 #include <dev/isa/isareg.h>
     41 #include <dev/isa/isavar.h>
     42 
     43 #include <dev/pci/pcireg.h>
     44 #include <dev/pci/pcivar.h>
     45 #include <alpha/pci/apecsreg.h>
     46 #include <alpha/pci/apecsvar.h>
     47 
     48 int	apecsmatch __P((struct device *, void *, void *));
     49 void	apecsattach __P((struct device *, struct device *, void *));
     50 
     51 struct cfattach apecs_ca = {
     52 	sizeof(struct apecs_softc), apecsmatch, apecsattach
     53 };
     54 
     55 struct cfdriver apecs_cd = {
     56 	NULL, "apecs", DV_DULL
     57 };
     58 
     59 static int	apecsprint __P((void *, char *pnp));
     60 
     61 #define	REGVAL(r)	(*(int32_t *)phystok0seg(r))
     62 
     63 /* There can be only one. */
     64 int apecsfound;
     65 struct apecs_config apecs_configuration;
     66 
     67 int
     68 apecsmatch(parent, match, aux)
     69 	struct device *parent;
     70 	void *match, *aux;
     71 {
     72 	struct cfdata *cf = match;
     73 	struct confargs *ca = aux;
     74 
     75 	/* Make sure that we're looking for an APECS. */
     76 	if (strcmp(ca->ca_name, apecs_cd.cd_name) != 0)
     77 		return (0);
     78 
     79 	if (apecsfound)
     80 		return (0);
     81 
     82 	return (1);
     83 }
     84 
     85 /*
     86  * Set up the chipset's function pointers.
     87  */
     88 void
     89 apecs_init(acp)
     90 	struct apecs_config *acp;
     91 {
     92 
     93 	acp->ac_comanche_pass2 =
     94 	    (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
     95 	acp->ac_memwidth =
     96 	    (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
     97 	acp->ac_epic_pass2 =
     98 	    (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
     99 
    100 	/*
    101 	 * Can't set up SGMAP data here; can be called before malloc().
    102 	 */
    103 
    104 	acp->ac_conffns = &apecs_conf_fns;
    105 	acp->ac_confarg = acp;
    106 	acp->ac_dmafns = &apecs_dma_fns;
    107 	acp->ac_dmaarg = acp;
    108 	/* Interrupt routines set up in 'attach' */
    109 	acp->ac_memfns = &apecs_mem_fns;
    110 	acp->ac_memarg = acp;
    111 	acp->ac_piofns = &apecs_pio_fns;
    112 	acp->ac_pioarg = acp;
    113 
    114 	/* Turn off DMA window enables in PCI Base Reg 1. */
    115 	REGVAL(EPIC_PCI_BASE_1) = 0;
    116 	wbflush();
    117 
    118 	/* XXX SGMAP? */
    119 }
    120 
    121 void
    122 apecsattach(parent, self, aux)
    123 	struct device *parent, *self;
    124 	void *aux;
    125 {
    126 	struct confargs *ca = aux;
    127 	struct apecs_softc *sc = (struct apecs_softc *)self;
    128 	struct apecs_config *acp;
    129 	struct pci_attach_args pa;
    130 
    131 	/* note that we've attached the chipset; can't have 2 APECSes. */
    132 	apecsfound = 1;
    133 
    134 	/*
    135 	 * set up the chipset's info; done once at console init time
    136 	 * (maybe), but doesn't hurt to do twice.
    137 	 */
    138 	acp = sc->sc_acp = &apecs_configuration;
    139 	apecs_init(acp);
    140 
    141 	/* XXX SGMAP FOO */
    142 
    143 	printf(": DECchip %s Core Logic chipset\n",
    144 	    acp->ac_memwidth == 128 ? "21072" : "21071");
    145 	printf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
    146 	    self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
    147 	printf("%s: DC21071-DA pass %d\n", self->dv_xname,
    148 	    acp->ac_epic_pass2 ? 2 : 1);
    149 	/* XXX print bcache size */
    150 
    151 	if (!acp->ac_epic_pass2)
    152 		printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
    153 
    154 	switch (hwrpb->rpb_type) {
    155 #if defined(DEC_2100_A50)
    156 	case ST_DEC_2100_A50:
    157 		pci_2100_a50_pickintr(acp->ac_conffns, acp->ac_confarg,
    158 		    acp->ac_piofns, acp->ac_pioarg,
    159 		    &acp->ac_intrfns, &acp->ac_intrarg);
    160 		break;
    161 #endif
    162 	default:
    163 		panic("apecsattach: shouldn't be here, really...");
    164 	}
    165 
    166 	pa.pa_bus = 0;
    167 	pa.pa_maxdev = 32;
    168 	pa.pa_burstlog2 = 8;
    169 
    170 	pa.pa_conffns = acp->ac_conffns;
    171 	pa.pa_confarg = acp->ac_confarg;
    172 	pa.pa_dmafns = acp->ac_dmafns;
    173 	pa.pa_dmaarg = acp->ac_dmaarg;
    174 	pa.pa_intrfns = acp->ac_intrfns;
    175 	pa.pa_intrarg = acp->ac_intrarg;
    176 	pa.pa_memfns = acp->ac_memfns;
    177 	pa.pa_memarg = acp->ac_memarg;
    178 	pa.pa_piofns = acp->ac_piofns;
    179 	pa.pa_pioarg = acp->ac_pioarg;
    180 
    181 	config_found(self, &pa, apecsprint);
    182 }
    183 
    184 static int
    185 apecsprint(aux, pnp)
    186 	void *aux;
    187 	char *pnp;
    188 {
    189         register struct pci_attach_args *pa = aux;
    190 
    191 	/* only PCIs can attach to APECSes; easy. */
    192 	if (pnp)
    193 		printf("pci at %s", pnp);
    194 	printf(" bus %d", pa->pa_bus);
    195 	return (UNCONF);
    196 }
    197