Home | History | Annotate | Line # | Download | only in pci
apecs.c revision 1.14
      1 /*	$NetBSD: apecs.c,v 1.14 1996/11/11 21:02:32 cgd 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 <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 #if defined(DEC_2100_A50)
     48 #include <alpha/pci/pci_2100_a50.h>
     49 #endif
     50 
     51 int	apecsmatch __P((struct device *, void *, void *));
     52 void	apecsattach __P((struct device *, struct device *, void *));
     53 
     54 struct cfattach apecs_ca = {
     55 	sizeof(struct apecs_softc), apecsmatch, apecsattach,
     56 };
     57 
     58 struct cfdriver apecs_cd = {
     59 	NULL, "apecs", DV_DULL,
     60 };
     61 
     62 static int	apecsprint __P((void *, const char *pnp));
     63 
     64 /* There can be only one. */
     65 int apecsfound;
     66 struct apecs_config apecs_configuration;
     67 
     68 int
     69 apecsmatch(parent, match, aux)
     70 	struct device *parent;
     71 	void *match, *aux;
     72 {
     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_iot = apecs_lca_bus_io_init(acp);
    105 	acp->ac_memt = apecs_lca_bus_mem_init(acp);
    106 	apecs_pci_init(&acp->ac_pc, acp);
    107 
    108 	/* Turn off DMA window enables in PCI Base Reg 1. */
    109 	REGVAL(EPIC_PCI_BASE_1) = 0;
    110 	alpha_mb();
    111 
    112 	/* XXX SGMAP? */
    113 
    114 	/* XXX XXX BEGIN XXX XXX */
    115 	{							/* XXX */
    116 		extern vm_offset_t alpha_XXX_dmamap_or;		/* XXX */
    117 		alpha_XXX_dmamap_or = 0x40000000;		/* XXX */
    118 	}							/* XXX */
    119 	/* XXX XXX END XXX XXX */
    120 }
    121 
    122 void
    123 apecsattach(parent, self, aux)
    124 	struct device *parent, *self;
    125 	void *aux;
    126 {
    127 	struct apecs_softc *sc = (struct apecs_softc *)self;
    128 	struct apecs_config *acp;
    129 	struct pcibus_attach_args pba;
    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);
    158 		break;
    159 #endif
    160 
    161 	default:
    162 		panic("apecsattach: shouldn't be here, really...");
    163 	}
    164 
    165 	pba.pba_busname = "pci";
    166 	pba.pba_iot = acp->ac_iot;
    167 	pba.pba_memt = acp->ac_memt;
    168 	pba.pba_pc = &acp->ac_pc;
    169 	pba.pba_bus = 0;
    170 	config_found(self, &pba, apecsprint);
    171 }
    172 
    173 static int
    174 apecsprint(aux, pnp)
    175 	void *aux;
    176 	const char *pnp;
    177 {
    178         register struct pcibus_attach_args *pba = aux;
    179 
    180 	/* only PCIs can attach to APECSes; easy. */
    181 	if (pnp)
    182 		printf("%s at %s", pba->pba_busname, pnp);
    183 	printf(" bus %d", pba->pba_bus);
    184 	return (UNCONF);
    185 }
    186