Home | History | Annotate | Line # | Download | only in pci
cia.c revision 1.14.2.3
      1  1.14.2.3       cgd /* $NetBSD: cia.c,v 1.14.2.3 1997/06/01 04:13:05 cgd Exp $ */
      2       1.1       cgd 
      3       1.1       cgd /*
      4       1.4       cgd  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5       1.1       cgd  * All rights reserved.
      6       1.1       cgd  *
      7       1.1       cgd  * Author: Chris G. Demetriou
      8       1.1       cgd  *
      9       1.1       cgd  * Permission to use, copy, modify and distribute this software and
     10       1.1       cgd  * its documentation is hereby granted, provided that both the copyright
     11       1.1       cgd  * notice and this permission notice appear in all copies of the
     12       1.1       cgd  * software, derivative works or modified versions, and any portions
     13       1.1       cgd  * thereof, and that both notices appear in supporting documentation.
     14       1.1       cgd  *
     15       1.1       cgd  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16       1.1       cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17       1.1       cgd  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18       1.1       cgd  *
     19       1.1       cgd  * Carnegie Mellon requests users of this software to return to
     20       1.1       cgd  *
     21       1.1       cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22       1.1       cgd  *  School of Computer Science
     23       1.1       cgd  *  Carnegie Mellon University
     24       1.1       cgd  *  Pittsburgh PA 15213-3890
     25       1.1       cgd  *
     26       1.1       cgd  * any improvements or extensions that they make and grant Carnegie the
     27       1.1       cgd  * rights to redistribute these changes.
     28       1.1       cgd  */
     29       1.1       cgd 
     30  1.14.2.3       cgd #include <machine/options.h>		/* Config options headers */
     31  1.14.2.3       cgd #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     32  1.14.2.3       cgd 
     33  1.14.2.3       cgd __KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.14.2.3 1997/06/01 04:13:05 cgd Exp $");
     34  1.14.2.3       cgd 
     35       1.1       cgd #include <sys/param.h>
     36       1.1       cgd #include <sys/systm.h>
     37       1.1       cgd #include <sys/kernel.h>
     38       1.1       cgd #include <sys/malloc.h>
     39       1.1       cgd #include <sys/device.h>
     40       1.1       cgd #include <vm/vm.h>
     41       1.1       cgd 
     42       1.1       cgd #include <machine/autoconf.h>
     43       1.1       cgd #include <machine/rpb.h>
     44       1.1       cgd 
     45       1.1       cgd #include <dev/isa/isareg.h>
     46       1.1       cgd #include <dev/isa/isavar.h>
     47       1.1       cgd 
     48       1.1       cgd #include <dev/pci/pcireg.h>
     49       1.1       cgd #include <dev/pci/pcivar.h>
     50       1.1       cgd #include <alpha/pci/ciareg.h>
     51       1.1       cgd #include <alpha/pci/ciavar.h>
     52  1.14.2.3       cgd #ifdef DEC_KN20AA
     53       1.1       cgd #include <alpha/pci/pci_kn20aa.h>
     54       1.1       cgd #endif
     55  1.14.2.3       cgd #ifdef DEC_EB164
     56      1.13       cgd #include <alpha/pci/pci_eb164.h>
     57      1.13       cgd #endif
     58       1.1       cgd 
     59  1.14.2.1       cgd int	ciamatch __P((struct device *, struct cfdata *, void *));
     60       1.1       cgd void	ciaattach __P((struct device *, struct device *, void *));
     61       1.1       cgd 
     62       1.5       cgd struct cfattach cia_ca = {
     63       1.5       cgd 	sizeof(struct cia_softc), ciamatch, ciaattach,
     64       1.5       cgd };
     65       1.5       cgd 
     66       1.5       cgd struct cfdriver cia_cd = {
     67       1.5       cgd 	NULL, "cia", DV_DULL,
     68       1.1       cgd };
     69       1.1       cgd 
     70       1.9       cgd static int	ciaprint __P((void *, const char *pnp));
     71       1.1       cgd 
     72       1.1       cgd /* There can be only one. */
     73       1.1       cgd int ciafound;
     74       1.1       cgd struct cia_config cia_configuration;
     75       1.1       cgd 
     76       1.1       cgd int
     77       1.1       cgd ciamatch(parent, match, aux)
     78       1.1       cgd 	struct device *parent;
     79  1.14.2.1       cgd 	struct cfdata *match;
     80  1.14.2.1       cgd 	void *aux;
     81       1.1       cgd {
     82       1.1       cgd 	struct confargs *ca = aux;
     83       1.1       cgd 
     84       1.1       cgd 	/* Make sure that we're looking for a CIA. */
     85       1.5       cgd 	if (strcmp(ca->ca_name, cia_cd.cd_name) != 0)
     86       1.1       cgd 		return (0);
     87       1.1       cgd 
     88       1.1       cgd 	if (ciafound)
     89       1.1       cgd 		return (0);
     90       1.1       cgd 
     91       1.1       cgd 	return (1);
     92       1.1       cgd }
     93       1.1       cgd 
     94       1.1       cgd /*
     95       1.1       cgd  * Set up the chipset's function pointers.
     96       1.1       cgd  */
     97       1.1       cgd void
     98      1.14       cgd cia_init(ccp, mallocsafe)
     99       1.1       cgd 	struct cia_config *ccp;
    100      1.14       cgd 	int mallocsafe;
    101       1.1       cgd {
    102       1.1       cgd 
    103       1.1       cgd 	/*
    104       1.1       cgd 	 * Can't set up SGMAP data here; can be called before malloc().
    105      1.14       cgd 	 * XXX THIS COMMENT NO LONGER MAKES SENSE.
    106       1.1       cgd 	 */
    107       1.1       cgd 
    108       1.6       cgd 	ccp->cc_hae_mem = REGVAL(CIA_CSR_HAE_MEM);
    109       1.6       cgd 	ccp->cc_hae_io = REGVAL(CIA_CSR_HAE_IO);
    110      1.12       cgd 
    111      1.14       cgd 	if (!ccp->cc_initted) {
    112      1.14       cgd 		/* don't do these twice since they set up extents */
    113      1.14       cgd 		ccp->cc_iot = cia_bus_io_init(ccp);
    114      1.14       cgd 		ccp->cc_memt = cia_bus_mem_init(ccp);
    115      1.14       cgd 	}
    116      1.14       cgd 	ccp->cc_mallocsafe = mallocsafe;
    117      1.14       cgd 
    118      1.14       cgd 	cia_pci_init(&ccp->cc_pc, ccp);
    119      1.14       cgd 
    120      1.12       cgd 	/* XXX XXX BEGIN XXX XXX */
    121      1.12       cgd 	{							/* XXX */
    122      1.12       cgd 		extern vm_offset_t alpha_XXX_dmamap_or;		/* XXX */
    123      1.12       cgd 		alpha_XXX_dmamap_or = 0x40000000;		/* XXX */
    124      1.12       cgd 	}							/* XXX */
    125      1.12       cgd 	/* XXX XXX END XXX XXX */
    126      1.14       cgd 
    127      1.14       cgd 	ccp->cc_initted = 1;
    128       1.1       cgd }
    129       1.1       cgd 
    130       1.1       cgd void
    131       1.1       cgd ciaattach(parent, self, aux)
    132       1.1       cgd 	struct device *parent, *self;
    133       1.1       cgd 	void *aux;
    134       1.1       cgd {
    135       1.1       cgd 	struct cia_softc *sc = (struct cia_softc *)self;
    136       1.1       cgd 	struct cia_config *ccp;
    137       1.5       cgd 	struct pcibus_attach_args pba;
    138       1.1       cgd 
    139       1.1       cgd 	/* note that we've attached the chipset; can't have 2 CIAs. */
    140       1.1       cgd 	ciafound = 1;
    141       1.1       cgd 
    142       1.1       cgd 	/*
    143       1.1       cgd 	 * set up the chipset's info; done once at console init time
    144       1.1       cgd 	 * (maybe), but doesn't hurt to do twice.
    145       1.1       cgd 	 */
    146       1.1       cgd 	ccp = sc->sc_ccp = &cia_configuration;
    147      1.14       cgd 	cia_init(ccp, 1);
    148       1.1       cgd 
    149       1.1       cgd 	/* XXX print chipset information */
    150      1.11  christos 	printf("\n");
    151       1.1       cgd 
    152       1.1       cgd 	switch (hwrpb->rpb_type) {
    153  1.14.2.3       cgd #ifdef DEC_KN20AA
    154       1.1       cgd 	case ST_DEC_KN20AA:
    155       1.5       cgd 		pci_kn20aa_pickintr(ccp);
    156       1.1       cgd #ifdef EVCNT_COUNTERS
    157       1.1       cgd 		evcnt_attach(self, "intr", &kn20aa_intr_evcnt);
    158       1.1       cgd #endif
    159       1.1       cgd 		break;
    160       1.1       cgd #endif
    161      1.13       cgd 
    162  1.14.2.3       cgd #ifdef DEC_EB164
    163      1.13       cgd 	case ST_EB164:
    164      1.13       cgd 		pci_eb164_pickintr(ccp);
    165      1.13       cgd #ifdef EVCNT_COUNTERS
    166      1.13       cgd 		evcnt_attach(self, "intr", &eb164_intr_evcnt);
    167      1.13       cgd #endif
    168      1.13       cgd 		break;
    169      1.13       cgd #endif
    170      1.13       cgd 
    171       1.1       cgd 	default:
    172       1.1       cgd 		panic("ciaattach: shouldn't be here, really...");
    173       1.1       cgd 	}
    174       1.1       cgd 
    175       1.5       cgd 	pba.pba_busname = "pci";
    176      1.12       cgd 	pba.pba_iot = ccp->cc_iot;
    177      1.12       cgd 	pba.pba_memt = ccp->cc_memt;
    178       1.5       cgd 	pba.pba_pc = &ccp->cc_pc;
    179       1.5       cgd 	pba.pba_bus = 0;
    180  1.14.2.3       cgd 	pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
    181       1.5       cgd 	config_found(self, &pba, ciaprint);
    182       1.1       cgd }
    183       1.1       cgd 
    184       1.1       cgd static int
    185       1.1       cgd ciaprint(aux, pnp)
    186       1.1       cgd 	void *aux;
    187       1.9       cgd 	const char *pnp;
    188       1.1       cgd {
    189       1.5       cgd 	register struct pcibus_attach_args *pba = aux;
    190       1.1       cgd 
    191       1.1       cgd 	/* only PCIs can attach to CIAs; easy. */
    192       1.1       cgd 	if (pnp)
    193      1.11  christos 		printf("%s at %s", pba->pba_busname, pnp);
    194      1.11  christos 	printf(" bus %d", pba->pba_bus);
    195       1.1       cgd 	return (UNCONF);
    196       1.1       cgd }
    197