Home | History | Annotate | Line # | Download | only in pci
cia.c revision 1.9
      1 /*	$NetBSD: cia.c,v 1.9 1996/08/27 21:53:56 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/ciareg.h>
     46 #include <alpha/pci/ciavar.h>
     47 #if defined(DEC_KN20AA)
     48 #include <alpha/pci/pci_kn20aa.h>
     49 #endif
     50 
     51 int	ciamatch __P((struct device *, void *, void *));
     52 void	ciaattach __P((struct device *, struct device *, void *));
     53 
     54 struct cfattach cia_ca = {
     55 	sizeof(struct cia_softc), ciamatch, ciaattach,
     56 };
     57 
     58 struct cfdriver cia_cd = {
     59 	NULL, "cia", DV_DULL,
     60 };
     61 
     62 static int	ciaprint __P((void *, const char *pnp));
     63 
     64 /* There can be only one. */
     65 int ciafound;
     66 struct cia_config cia_configuration;
     67 
     68 int
     69 ciamatch(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 a CIA. */
     76 	if (strcmp(ca->ca_name, cia_cd.cd_name) != 0)
     77 		return (0);
     78 
     79 	if (ciafound)
     80 		return (0);
     81 
     82 	return (1);
     83 }
     84 
     85 /*
     86  * Set up the chipset's function pointers.
     87  */
     88 void
     89 cia_init(ccp)
     90 	struct cia_config *ccp;
     91 {
     92 
     93 	/*
     94 	 * Can't set up SGMAP data here; can be called before malloc().
     95 	 */
     96 
     97         cia_bus_io_init(&ccp->cc_bc, ccp);
     98         cia_bus_mem_init(&ccp->cc_bc, ccp);
     99         cia_pci_init(&ccp->cc_pc, ccp);
    100 
    101 	ccp->cc_hae_mem = REGVAL(CIA_CSR_HAE_MEM);
    102 	ccp->cc_hae_io = REGVAL(CIA_CSR_HAE_IO);
    103 }
    104 
    105 void
    106 ciaattach(parent, self, aux)
    107 	struct device *parent, *self;
    108 	void *aux;
    109 {
    110 	struct cia_softc *sc = (struct cia_softc *)self;
    111 	struct cia_config *ccp;
    112 	struct pcibus_attach_args pba;
    113 
    114 	/* note that we've attached the chipset; can't have 2 CIAs. */
    115 	ciafound = 1;
    116 
    117 	/*
    118 	 * set up the chipset's info; done once at console init time
    119 	 * (maybe), but doesn't hurt to do twice.
    120 	 */
    121 	ccp = sc->sc_ccp = &cia_configuration;
    122 	cia_init(ccp);
    123 
    124 	/* XXX print chipset information */
    125 	printf("\n");
    126 
    127 	switch (hwrpb->rpb_type) {
    128 #if defined(DEC_KN20AA)
    129 	case ST_DEC_KN20AA:
    130 		pci_kn20aa_pickintr(ccp);
    131 #ifdef EVCNT_COUNTERS
    132 		evcnt_attach(self, "intr", &kn20aa_intr_evcnt);
    133 #endif
    134 		break;
    135 #endif
    136 	default:
    137 		panic("ciaattach: shouldn't be here, really...");
    138 	}
    139 
    140 	pba.pba_busname = "pci";
    141 	pba.pba_bc = &ccp->cc_bc;
    142 	pba.pba_pc = &ccp->cc_pc;
    143 	pba.pba_bus = 0;
    144 	config_found(self, &pba, ciaprint);
    145 }
    146 
    147 static int
    148 ciaprint(aux, pnp)
    149 	void *aux;
    150 	const char *pnp;
    151 {
    152 	register struct pcibus_attach_args *pba = aux;
    153 
    154 	/* only PCIs can attach to CIAs; easy. */
    155 	if (pnp)
    156 		printf("%s at %s", pba->pba_busname, pnp);
    157 	printf(" bus %d", pba->pba_bus);
    158 	return (UNCONF);
    159 }
    160