cia.c revision 1.19
1/* $NetBSD: cia.c,v 1.19 1997/04/07 23:40:29 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@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 <machine/options.h> /* Config options headers */ 31#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 32 33__KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.19 1997/04/07 23:40:29 cgd Exp $"); 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/kernel.h> 38#include <sys/malloc.h> 39#include <sys/device.h> 40#include <vm/vm.h> 41 42#include <machine/autoconf.h> 43#include <machine/rpb.h> 44 45#include <dev/isa/isareg.h> 46#include <dev/isa/isavar.h> 47 48#include <dev/pci/pcireg.h> 49#include <dev/pci/pcivar.h> 50#include <alpha/pci/ciareg.h> 51#include <alpha/pci/ciavar.h> 52#ifdef DEC_KN20AA 53#include <alpha/pci/pci_kn20aa.h> 54#endif 55#ifdef DEC_EB164 56#include <alpha/pci/pci_eb164.h> 57#endif 58 59int ciamatch __P((struct device *, struct cfdata *, void *)); 60void ciaattach __P((struct device *, struct device *, void *)); 61 62struct cfattach cia_ca = { 63 sizeof(struct cia_softc), ciamatch, ciaattach, 64}; 65 66struct cfdriver cia_cd = { 67 NULL, "cia", DV_DULL, 68}; 69 70static int ciaprint __P((void *, const char *pnp)); 71 72/* There can be only one. */ 73int ciafound; 74struct cia_config cia_configuration; 75 76int 77ciamatch(parent, match, aux) 78 struct device *parent; 79 struct cfdata *match; 80 void *aux; 81{ 82 struct confargs *ca = aux; 83 84 /* Make sure that we're looking for a CIA. */ 85 if (strcmp(ca->ca_name, cia_cd.cd_name) != 0) 86 return (0); 87 88 if (ciafound) 89 return (0); 90 91 return (1); 92} 93 94/* 95 * Set up the chipset's function pointers. 96 */ 97void 98cia_init(ccp, mallocsafe) 99 struct cia_config *ccp; 100 int mallocsafe; 101{ 102 103 /* 104 * Can't set up SGMAP data here; can be called before malloc(). 105 * XXX THIS COMMENT NO LONGER MAKES SENSE. 106 */ 107 108 ccp->cc_hae_mem = REGVAL(CIA_CSR_HAE_MEM); 109 ccp->cc_hae_io = REGVAL(CIA_CSR_HAE_IO); 110 111 if (!ccp->cc_initted) { 112 /* don't do these twice since they set up extents */ 113 ccp->cc_iot = cia_bus_io_init(ccp); 114 ccp->cc_memt = cia_bus_mem_init(ccp); 115 } 116 ccp->cc_mallocsafe = mallocsafe; 117 118 cia_pci_init(&ccp->cc_pc, ccp); 119 120 /* XXX XXX BEGIN XXX XXX */ 121 { /* XXX */ 122 extern vm_offset_t alpha_XXX_dmamap_or; /* XXX */ 123 alpha_XXX_dmamap_or = 0x40000000; /* XXX */ 124 } /* XXX */ 125 /* XXX XXX END XXX XXX */ 126 127 ccp->cc_initted = 1; 128} 129 130void 131ciaattach(parent, self, aux) 132 struct device *parent, *self; 133 void *aux; 134{ 135 struct cia_softc *sc = (struct cia_softc *)self; 136 struct cia_config *ccp; 137 struct pcibus_attach_args pba; 138 139 /* note that we've attached the chipset; can't have 2 CIAs. */ 140 ciafound = 1; 141 142 /* 143 * set up the chipset's info; done once at console init time 144 * (maybe), but doesn't hurt to do twice. 145 */ 146 ccp = sc->sc_ccp = &cia_configuration; 147 cia_init(ccp, 1); 148 149 /* XXX print chipset information */ 150 printf("\n"); 151 152 switch (hwrpb->rpb_type) { 153#ifdef DEC_KN20AA 154 case ST_DEC_KN20AA: 155 pci_kn20aa_pickintr(ccp); 156#ifdef EVCNT_COUNTERS 157 evcnt_attach(self, "intr", &kn20aa_intr_evcnt); 158#endif 159 break; 160#endif 161 162#ifdef DEC_EB164 163 case ST_EB164: 164 pci_eb164_pickintr(ccp); 165#ifdef EVCNT_COUNTERS 166 evcnt_attach(self, "intr", &eb164_intr_evcnt); 167#endif 168 break; 169#endif 170 171 default: 172 panic("ciaattach: shouldn't be here, really..."); 173 } 174 175 pba.pba_busname = "pci"; 176 pba.pba_iot = ccp->cc_iot; 177 pba.pba_memt = ccp->cc_memt; 178 pba.pba_pc = &ccp->cc_pc; 179 pba.pba_bus = 0; 180 config_found(self, &pba, ciaprint); 181} 182 183static int 184ciaprint(aux, pnp) 185 void *aux; 186 const char *pnp; 187{ 188 register struct pcibus_attach_args *pba = aux; 189 190 /* only PCIs can attach to CIAs; easy. */ 191 if (pnp) 192 printf("%s at %s", pba->pba_busname, pnp); 193 printf(" bus %d", pba->pba_bus); 194 return (UNCONF); 195} 196