Home | History | Annotate | Line # | Download | only in pci
lca.c revision 1.1
      1  1.1  cgd /*	$NetBSD: lca.c,v 1.1 1995/11/23 02:37:38 cgd Exp $	*/
      2  1.1  cgd 
      3  1.1  cgd /*
      4  1.1  cgd  * Copyright (c) 1995 Carnegie-Mellon University.
      5  1.1  cgd  * All rights reserved.
      6  1.1  cgd  *
      7  1.1  cgd  * Author: Jeffrey Hsu
      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.1  cgd #include <sys/param.h>
     31  1.1  cgd #include <sys/systm.h>
     32  1.1  cgd #include <sys/kernel.h>
     33  1.1  cgd #include <sys/malloc.h>
     34  1.1  cgd #include <sys/device.h>
     35  1.1  cgd #include <vm/vm.h>
     36  1.1  cgd 
     37  1.1  cgd #include <machine/autoconf.h>
     38  1.1  cgd #include <machine/rpb.h>
     39  1.1  cgd 
     40  1.1  cgd #include <dev/isa/isareg.h>
     41  1.1  cgd #include <dev/isa/isavar.h>
     42  1.1  cgd 
     43  1.1  cgd #include <dev/pci/pcireg.h>
     44  1.1  cgd #include <dev/pci/pcivar.h>
     45  1.1  cgd #include <alpha/pci/lcareg.h>
     46  1.1  cgd #include <alpha/pci/lcavar.h>
     47  1.1  cgd 
     48  1.1  cgd int	lcamatch __P((struct device *, void *, void *));
     49  1.1  cgd void	lcaattach __P((struct device *, struct device *, void *));
     50  1.1  cgd 
     51  1.1  cgd struct cfdriver lcacd = {
     52  1.1  cgd 	NULL, "lca", lcamatch, lcaattach, DV_DULL,
     53  1.1  cgd 	    sizeof(struct lca_softc)
     54  1.1  cgd };
     55  1.1  cgd 
     56  1.1  cgd static int	lcaprint __P((void *, char *pnp));
     57  1.1  cgd 
     58  1.1  cgd /* There can be only one. */
     59  1.1  cgd int lcafound;
     60  1.1  cgd struct lca_config lca_configuration;
     61  1.1  cgd 
     62  1.1  cgd int
     63  1.1  cgd lcamatch(parent, match, aux)
     64  1.1  cgd 	struct device *parent;
     65  1.1  cgd 	void *match, *aux;
     66  1.1  cgd {
     67  1.1  cgd 	struct cfdata *cf = match;
     68  1.1  cgd 	struct confargs *ca = aux;
     69  1.1  cgd 
     70  1.1  cgd 	/* Make sure that we're looking for a LCA. */
     71  1.1  cgd 	if (strcmp(ca->ca_name, lcacd.cd_name) != 0)
     72  1.1  cgd 		return (0);
     73  1.1  cgd 
     74  1.1  cgd 	if (lcafound)
     75  1.1  cgd 		return (0);
     76  1.1  cgd 
     77  1.1  cgd 	return (1);
     78  1.1  cgd }
     79  1.1  cgd 
     80  1.1  cgd /*
     81  1.1  cgd  * Set up the chipset's function pointers.
     82  1.1  cgd  */
     83  1.1  cgd void
     84  1.1  cgd lca_init(lcp)
     85  1.1  cgd 	struct lca_config *lcp;
     86  1.1  cgd {
     87  1.1  cgd 
     88  1.1  cgd 	/*
     89  1.1  cgd 	 * Can't set up SGMAP data here; can be called before malloc().
     90  1.1  cgd 	 */
     91  1.1  cgd 
     92  1.1  cgd 	lcp->lc_conffns = &lca_conf_fns;
     93  1.1  cgd 	lcp->lc_confarg = lcp;
     94  1.1  cgd 	lcp->lc_dmafns = &lca_dma_fns;
     95  1.1  cgd 	lcp->lc_dmaarg = lcp;
     96  1.1  cgd 	/* Interrupt routines set up in 'attach' */
     97  1.1  cgd 	lcp->lc_memfns = &lca_mem_fns;
     98  1.1  cgd 	lcp->lc_memarg = lcp;
     99  1.1  cgd 	lcp->lc_piofns = &lca_pio_fns;
    100  1.1  cgd 	lcp->lc_pioarg = lcp;
    101  1.1  cgd 
    102  1.1  cgd /*
    103  1.1  cgd printf("lca_init: before IOC_HAE=0x%x\n", REGVAL(LCA_IOC_HAE));
    104  1.1  cgd 	REGVAL(LCA_IOC_HAE) = 0; */
    105  1.1  cgd 
    106  1.1  cgd 	REGVAL(LCA_IOC_CONF) = 0;
    107  1.1  cgd 
    108  1.1  cgd 	/* Turn off DMA window enables in Window Base Registers */
    109  1.1  cgd /*	REGVAL(LCA_IOC_W_BASE0) = 0;
    110  1.1  cgd 	REGVAL(LCA_IOC_W_BASE1) = 0; */
    111  1.1  cgd 	wbflush();
    112  1.1  cgd }
    113  1.1  cgd 
    114  1.1  cgd #ifdef notdef
    115  1.1  cgd void
    116  1.1  cgd lca_init_sgmap(lcp)
    117  1.1  cgd 	struct lca_config *lcp;
    118  1.1  cgd {
    119  1.1  cgd 
    120  1.1  cgd 	/* XXX */
    121  1.1  cgd 	lcp->lc_sgmap = malloc(1024 * 8, M_DEVBUF, M_WAITOK);
    122  1.1  cgd 	bzero(lcp->lc_sgmap, 1024 * 8);		/* clear all entries. */
    123  1.1  cgd 
    124  1.1  cgd 	REGVAL(LCA_IOC_W_BASE0) = 0;
    125  1.1  cgd 	wbflush();
    126  1.1  cgd 
    127  1.1  cgd 	/* Set up Translated Base Register 1; translate to sybBus addr 0. */
    128  1.1  cgd 	/* check size against APEC XXX JH */
    129  1.1  cgd         REGVAL(LCA_IOC_T_BASE_0) = vtophys(lcp->lc_sgmap) >> 1;
    130  1.1  cgd 
    131  1.1  cgd         /* Set up PCI mask register 1; map 8MB space. */
    132  1.1  cgd         REGVAL(LCA_IOC_W_MASK0) = 0x00700000;
    133  1.1  cgd 
    134  1.1  cgd         /* Enable window 1; from PCI address 8MB, direct mapped. */
    135  1.1  cgd         REGVAL(LCA_IOC_W_BASE0) = 0x300800000;
    136  1.1  cgd         wbflush();
    137  1.1  cgd }
    138  1.1  cgd #endif
    139  1.1  cgd 
    140  1.1  cgd void
    141  1.1  cgd lcaattach(parent, self, aux)
    142  1.1  cgd 	struct device *parent, *self;
    143  1.1  cgd 	void *aux;
    144  1.1  cgd {
    145  1.1  cgd 	struct confargs *ca = aux;
    146  1.1  cgd 	struct lca_softc *sc = (struct lca_softc *)self;
    147  1.1  cgd 	struct lca_config *lcp;
    148  1.1  cgd 	struct pci_attach_args pa;
    149  1.1  cgd 
    150  1.1  cgd 	/* note that we've attached the chipset; can't have 2 LCAs. */
    151  1.1  cgd 	/* Um, not sure about this.  XXX JH */
    152  1.1  cgd 	lcafound = 1;
    153  1.1  cgd 
    154  1.1  cgd 	/*
    155  1.1  cgd 	 * set up the chipset's info; done once at console init time
    156  1.1  cgd 	 * (maybe), but doesn't hurt to do twice.
    157  1.1  cgd 	 */
    158  1.1  cgd 	lcp = sc->sc_lcp = &lca_configuration;
    159  1.1  cgd 	lca_init(lcp);
    160  1.1  cgd #ifdef notdef
    161  1.1  cgd 	lca_init_sgmap(lcp);
    162  1.1  cgd #endif
    163  1.1  cgd 
    164  1.1  cgd 	/* XXX print chipset information */
    165  1.1  cgd 	printf("\n");
    166  1.1  cgd 
    167  1.1  cgd 	switch (hwrpb->rpb_type) {
    168  1.1  cgd #if defined(DEC_AXPPCI_33)
    169  1.1  cgd 	case ST_DEC_AXPPCI_33:
    170  1.1  cgd 		pci_axppci_33_pickintr(lcp->lc_conffns, lcp->lc_confarg,
    171  1.1  cgd 		    lcp->lc_piofns, lcp->lc_pioarg,
    172  1.1  cgd 		    &lcp->lc_intrfns, &lcp->lc_intrarg);
    173  1.1  cgd 		break;
    174  1.1  cgd #endif
    175  1.1  cgd 	default:
    176  1.1  cgd 		panic("lcaattach: shouldn't be here, really...");
    177  1.1  cgd 	}
    178  1.1  cgd 
    179  1.1  cgd 	pa.pa_bus = 0;
    180  1.1  cgd 	pa.pa_maxdev = 13;
    181  1.1  cgd 	pa.pa_burstlog2 = 8;
    182  1.1  cgd 
    183  1.1  cgd 	pa.pa_conffns = lcp->lc_conffns;
    184  1.1  cgd 	pa.pa_confarg = lcp->lc_confarg;
    185  1.1  cgd 	pa.pa_dmafns = lcp->lc_dmafns;
    186  1.1  cgd 	pa.pa_dmaarg = lcp->lc_dmaarg;
    187  1.1  cgd 	pa.pa_intrfns = lcp->lc_intrfns;
    188  1.1  cgd 	pa.pa_intrarg = lcp->lc_intrarg;
    189  1.1  cgd 	pa.pa_memfns = lcp->lc_memfns;
    190  1.1  cgd 	pa.pa_memarg = lcp->lc_memarg;
    191  1.1  cgd 	pa.pa_piofns = lcp->lc_piofns;
    192  1.1  cgd 	pa.pa_pioarg = lcp->lc_pioarg;
    193  1.1  cgd 
    194  1.1  cgd 	config_found(self, &pa, lcaprint);
    195  1.1  cgd }
    196  1.1  cgd 
    197  1.1  cgd static int
    198  1.1  cgd lcaprint(aux, pnp)
    199  1.1  cgd 	void *aux;
    200  1.1  cgd 	char *pnp;
    201  1.1  cgd {
    202  1.1  cgd         register struct pci_attach_args *pa = aux;
    203  1.1  cgd 
    204  1.1  cgd 	/* what does this do?  XXX JH */
    205  1.1  cgd 	/* only PCIs can attach to LCAes; easy. */
    206  1.1  cgd 	if (pnp)
    207  1.1  cgd 		printf("pci at %s", pnp);
    208  1.1  cgd 	printf(" bus %d", pa->pa_bus);
    209  1.1  cgd 	return (UNCONF);
    210  1.1  cgd }
    211