Home | History | Annotate | Line # | Download | only in pci
lca.c revision 1.4
      1 /*	$NetBSD: lca.c,v 1.4 1996/04/12 06:08:33 cgd Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5  * All rights reserved.
      6  *
      7  * Authors: Jeffrey Hsu and 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/lcareg.h>
     46 #include <alpha/pci/lcavar.h>
     47 
     48 int	lcamatch __P((struct device *, void *, void *));
     49 void	lcaattach __P((struct device *, struct device *, void *));
     50 
     51 struct cfattach lca_ca = {
     52 	sizeof(struct lca_softc), lcamatch, lcaattach,
     53 };
     54 
     55 struct cfdriver lca_cd = {
     56 	NULL, "lca", DV_DULL,
     57 };
     58 
     59 static int	lcaprint __P((void *, char *pnp));
     60 
     61 /* There can be only one. */
     62 int lcafound;
     63 struct lca_config lca_configuration;
     64 
     65 int
     66 lcamatch(parent, match, aux)
     67 	struct device *parent;
     68 	void *match, *aux;
     69 {
     70 	struct cfdata *cf = match;
     71 	struct confargs *ca = aux;
     72 
     73 	/* Make sure that we're looking for a LCA. */
     74 	if (strcmp(ca->ca_name, lca_cd.cd_name) != 0)
     75 		return (0);
     76 
     77 	if (lcafound)
     78 		return (0);
     79 
     80 	return (1);
     81 }
     82 
     83 /*
     84  * Set up the chipset's function pointers.
     85  */
     86 void
     87 lca_init(lcp)
     88 	struct lca_config *lcp;
     89 {
     90 
     91 	/*
     92 	 * Can't set up SGMAP data here; can be called before malloc().
     93 	 */
     94 
     95 	apecs_lca_bus_io_init(&lcp->lc_bc, lcp);
     96 	apecs_lca_bus_mem_init(&lcp->lc_bc, lcp);
     97 	lca_pci_init(&lcp->lc_pc, lcp);
     98 
     99 /*
    100 printf("lca_init: before IOC_HAE=0x%x\n", REGVAL(LCA_IOC_HAE));
    101 	REGVAL(LCA_IOC_HAE) = 0; */
    102 
    103 	REGVAL(LCA_IOC_CONF) = 0;
    104 
    105 	/* Turn off DMA window enables in Window Base Registers */
    106 /*	REGVAL(LCA_IOC_W_BASE0) = 0;
    107 	REGVAL(LCA_IOC_W_BASE1) = 0; */
    108 	wbflush();
    109 }
    110 
    111 #ifdef notdef
    112 void
    113 lca_init_sgmap(lcp)
    114 	struct lca_config *lcp;
    115 {
    116 
    117 	/* XXX */
    118 	lcp->lc_sgmap = malloc(1024 * 8, M_DEVBUF, M_WAITOK);
    119 	bzero(lcp->lc_sgmap, 1024 * 8);		/* clear all entries. */
    120 
    121 	REGVAL(LCA_IOC_W_BASE0) = 0;
    122 	wbflush();
    123 
    124 	/* Set up Translated Base Register 1; translate to sybBus addr 0. */
    125 	/* check size against APEC XXX JH */
    126         REGVAL(LCA_IOC_T_BASE_0) = vtophys(lcp->lc_sgmap) >> 1;
    127 
    128         /* Set up PCI mask register 1; map 8MB space. */
    129         REGVAL(LCA_IOC_W_MASK0) = 0x00700000;
    130 
    131         /* Enable window 1; from PCI address 8MB, direct mapped. */
    132         REGVAL(LCA_IOC_W_BASE0) = 0x300800000;
    133         wbflush();
    134 }
    135 #endif
    136 
    137 void
    138 lcaattach(parent, self, aux)
    139 	struct device *parent, *self;
    140 	void *aux;
    141 {
    142 	struct lca_softc *sc = (struct lca_softc *)self;
    143 	struct lca_config *lcp;
    144 	struct pcibus_attach_args pba;
    145 
    146 	/* note that we've attached the chipset; can't have 2 LCAs. */
    147 	/* Um, not sure about this.  XXX JH */
    148 	lcafound = 1;
    149 
    150 	/*
    151 	 * set up the chipset's info; done once at console init time
    152 	 * (maybe), but doesn't hurt to do twice.
    153 	 */
    154 	lcp = sc->sc_lcp = &lca_configuration;
    155 	lca_init(lcp);
    156 #ifdef notdef
    157 	lca_init_sgmap(lcp);
    158 #endif
    159 
    160 	/* XXX print chipset information */
    161 	printf("\n");
    162 
    163 	switch (hwrpb->rpb_type) {
    164 #if defined(DEC_AXPPCI_33)
    165 	case ST_DEC_AXPPCI_33:
    166 		pci_axppci_33_pickintr(lcp);
    167 		break;
    168 #endif
    169 	default:
    170 		panic("lcaattach: shouldn't be here, really...");
    171 	}
    172 
    173 	pba.pba_busname = "pci";
    174 	pba.pba_bc = &lcp->lc_bc;
    175 	pba.pba_pc = &lcp->lc_pc;
    176 	pba.pba_bus = 0;
    177 	config_found(self, &pba, lcaprint);
    178 }
    179 
    180 static int
    181 lcaprint(aux, pnp)
    182 	void *aux;
    183 	char *pnp;
    184 {
    185         register struct pcibus_attach_args *pba = aux;
    186 
    187 	/* only PCIs can attach to LCAes; easy. */
    188 	if (pnp)
    189 		printf("%s at %s", pba->pba_busname, pnp);
    190 	printf(" bus %d", pba->pba_bus);
    191 	return (UNCONF);
    192 }
    193