Home | History | Annotate | Line # | Download | only in pci
apecs.c revision 1.27
      1 /* $NetBSD: apecs.c,v 1.27 1997/09/02 13:23:56 thorpej Exp $ */
      2 
      3 /*
      4  * Copyright (c) 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_2100_a50.h"
     31 #include "opt_dec_eb64plus.h"
     32 
     33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     34 
     35 __KERNEL_RCSID(0, "$NetBSD: apecs.c,v 1.27 1997/09/02 13:23:56 thorpej Exp $");
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/kernel.h>
     40 #include <sys/malloc.h>
     41 #include <sys/device.h>
     42 #include <vm/vm.h>
     43 
     44 #include <machine/autoconf.h>
     45 #include <machine/rpb.h>
     46 
     47 #include <dev/isa/isareg.h>
     48 #include <dev/isa/isavar.h>
     49 
     50 #include <dev/pci/pcireg.h>
     51 #include <dev/pci/pcivar.h>
     52 #include <alpha/pci/apecsreg.h>
     53 #include <alpha/pci/apecsvar.h>
     54 #ifdef DEC_2100_A50
     55 #include <alpha/pci/pci_2100_a50.h>
     56 #endif
     57 
     58 int	apecsmatch __P((struct device *, struct cfdata *, void *));
     59 void	apecsattach __P((struct device *, struct device *, void *));
     60 
     61 struct cfattach apecs_ca = {
     62 	sizeof(struct apecs_softc), apecsmatch, apecsattach,
     63 };
     64 
     65 struct cfdriver apecs_cd = {
     66 	NULL, "apecs", DV_DULL,
     67 };
     68 
     69 static int	apecsprint __P((void *, const char *pnp));
     70 
     71 /* There can be only one. */
     72 int apecsfound;
     73 struct apecs_config apecs_configuration;
     74 
     75 int
     76 apecsmatch(parent, match, aux)
     77 	struct device *parent;
     78 	struct cfdata *match;
     79 	void *aux;
     80 {
     81 	struct confargs *ca = aux;
     82 
     83 	/* Make sure that we're looking for an APECS. */
     84 	if (strcmp(ca->ca_name, apecs_cd.cd_name) != 0)
     85 		return (0);
     86 
     87 	if (apecsfound)
     88 		return (0);
     89 
     90 	return (1);
     91 }
     92 
     93 /*
     94  * Set up the chipset's function pointers.
     95  */
     96 void
     97 apecs_init(acp, mallocsafe)
     98 	struct apecs_config *acp;
     99 	int mallocsafe;
    100 {
    101 	acp->ac_comanche_pass2 =
    102 	    (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
    103 	acp->ac_memwidth =
    104 	    (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
    105 	acp->ac_epic_pass2 =
    106 	    (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
    107 
    108 	acp->ac_haxr1 = REGVAL(EPIC_HAXR1);
    109 	acp->ac_haxr2 = REGVAL(EPIC_HAXR2);
    110 
    111 	if (!acp->ac_initted) {
    112 		/* don't do these twice since they set up extents */
    113 		apecs_bus_io_init(&acp->ac_iot, acp);
    114 		apecs_bus_mem_init(&acp->ac_memt, acp);
    115 	}
    116 	acp->ac_mallocsafe = mallocsafe;
    117 
    118 	apecs_pci_init(&acp->ac_pc, acp);
    119 
    120 	apecs_dma_init(acp);
    121 
    122 	acp->ac_initted = 1;
    123 }
    124 
    125 void
    126 apecsattach(parent, self, aux)
    127 	struct device *parent, *self;
    128 	void *aux;
    129 {
    130 	struct apecs_softc *sc = (struct apecs_softc *)self;
    131 	struct apecs_config *acp;
    132 	struct pcibus_attach_args pba;
    133 
    134 	/* note that we've attached the chipset; can't have 2 APECSes. */
    135 	apecsfound = 1;
    136 
    137 	/*
    138 	 * set up the chipset's info; done once at console init time
    139 	 * (maybe), but doesn't hurt to do twice.
    140 	 */
    141 	acp = sc->sc_acp = &apecs_configuration;
    142 	apecs_init(acp, 1);
    143 
    144 	/* XXX SGMAP FOO */
    145 
    146 	printf(": DECchip %s Core Logic chipset\n",
    147 	    acp->ac_memwidth == 128 ? "21072" : "21071");
    148 	printf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
    149 	    self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
    150 	printf("%s: DC21071-DA pass %d\n", self->dv_xname,
    151 	    acp->ac_epic_pass2 ? 2 : 1);
    152 	/* XXX print bcache size */
    153 
    154 	if (!acp->ac_epic_pass2)
    155 		printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
    156 
    157 	switch (hwrpb->rpb_type) {
    158 #ifdef DEC_2100_A50
    159 	case ST_DEC_2100_A50:
    160 		pci_2100_a50_pickintr(acp);
    161 		break;
    162 #endif
    163 
    164 	default:
    165 		panic("apecsattach: shouldn't be here, really...");
    166 	}
    167 
    168 	pba.pba_busname = "pci";
    169 	pba.pba_iot = &acp->ac_iot;
    170 	pba.pba_memt = &acp->ac_memt;
    171 	pba.pba_dmat = &acp->ac_dmat_direct;
    172 	pba.pba_pc = &acp->ac_pc;
    173 	pba.pba_bus = 0;
    174 	pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
    175 	config_found(self, &pba, apecsprint);
    176 }
    177 
    178 static int
    179 apecsprint(aux, pnp)
    180 	void *aux;
    181 	const char *pnp;
    182 {
    183 	register struct pcibus_attach_args *pba = aux;
    184 
    185 	/* only PCIs can attach to APECSes; easy. */
    186 	if (pnp)
    187 		printf("%s at %s", pba->pba_busname, pnp);
    188 	printf(" bus %d", pba->pba_bus);
    189 	return (UNCONF);
    190 }
    191