Home | History | Annotate | Line # | Download | only in pci
lca.c revision 1.6
      1 /*	$NetBSD: lca.c,v 1.6 1996/07/09 00:54:46 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 	 * Refer to ``DECchip 21066 and DECchip 21068 Alpha AXP Microprocessors
    101 	 * Hardware Reference Manual''.
    102 	 * ...
    103 	 */
    104 
    105 	/*
    106 	 * According to section 6.4.1, all bits of the IOC_HAE register are
    107 	 * undefined after reset.  Bits <31:27> are write-only.  However, we
    108 	 * cannot blindly set it to zero.  The serial ROM code that initializes
    109 	 * the PCI devices' address spaces, allocates sparse memory blocks in
    110 	 * the range that must use the IOC_HAE register for address translation,
    111 	 * and sets this register accordingly (see section 6.4.14).
    112 	 *
    113 	 *	IOC_HAE left AS IS.
    114 	 */
    115 
    116 	/* According to section 6.4.2, all bits of the IOC_CONF register are
    117 	 * undefined after reset.  Bits <1:0> are write-only.  Set them to
    118 	 * 0x00 for PCI Type 0 configuration access.
    119 	 *
    120 	 *	IOC_CONF set to ZERO.
    121 	 */
    122 	REGVAL(LCA_IOC_CONF) = 0;
    123 
    124 	/* Turn off DMA window enables in Window Base Registers */
    125 /*	REGVAL(LCA_IOC_W_BASE0) = 0;
    126 	REGVAL(LCA_IOC_W_BASE1) = 0; */
    127 	alpha_mb();
    128 }
    129 
    130 #ifdef notdef
    131 void
    132 lca_init_sgmap(lcp)
    133 	struct lca_config *lcp;
    134 {
    135 
    136 	/* XXX */
    137 	lcp->lc_sgmap = malloc(1024 * 8, M_DEVBUF, M_WAITOK);
    138 	bzero(lcp->lc_sgmap, 1024 * 8);		/* clear all entries. */
    139 
    140 	REGVAL(LCA_IOC_W_BASE0) = 0;
    141 	alpha_mb();
    142 
    143 	/* Set up Translated Base Register 1; translate to sybBus addr 0. */
    144 	/* check size against APEC XXX JH */
    145         REGVAL(LCA_IOC_T_BASE_0) = vtophys(lcp->lc_sgmap) >> 1;
    146 
    147         /* Set up PCI mask register 1; map 8MB space. */
    148         REGVAL(LCA_IOC_W_MASK0) = 0x00700000;
    149 
    150         /* Enable window 1; from PCI address 8MB, direct mapped. */
    151         REGVAL(LCA_IOC_W_BASE0) = 0x300800000;
    152         alpha_mb();
    153 }
    154 #endif
    155 
    156 void
    157 lcaattach(parent, self, aux)
    158 	struct device *parent, *self;
    159 	void *aux;
    160 {
    161 	struct lca_softc *sc = (struct lca_softc *)self;
    162 	struct lca_config *lcp;
    163 	struct pcibus_attach_args pba;
    164 
    165 	/* note that we've attached the chipset; can't have 2 LCAs. */
    166 	/* Um, not sure about this.  XXX JH */
    167 	lcafound = 1;
    168 
    169 	/*
    170 	 * set up the chipset's info; done once at console init time
    171 	 * (maybe), but doesn't hurt to do twice.
    172 	 */
    173 	lcp = sc->sc_lcp = &lca_configuration;
    174 	lca_init(lcp);
    175 #ifdef notdef
    176 	lca_init_sgmap(lcp);
    177 #endif
    178 
    179 	/* XXX print chipset information */
    180 	printf("\n");
    181 
    182 	switch (hwrpb->rpb_type) {
    183 #if defined(DEC_AXPPCI_33)
    184 	case ST_DEC_AXPPCI_33:
    185 		pci_axppci_33_pickintr(lcp);
    186 		break;
    187 #endif
    188 	default:
    189 		panic("lcaattach: shouldn't be here, really...");
    190 	}
    191 
    192 	pba.pba_busname = "pci";
    193 	pba.pba_bc = &lcp->lc_bc;
    194 	pba.pba_pc = &lcp->lc_pc;
    195 	pba.pba_bus = 0;
    196 	config_found(self, &pba, lcaprint);
    197 }
    198 
    199 static int
    200 lcaprint(aux, pnp)
    201 	void *aux;
    202 	char *pnp;
    203 {
    204         register struct pcibus_attach_args *pba = aux;
    205 
    206 	/* only PCIs can attach to LCAes; easy. */
    207 	if (pnp)
    208 		printf("%s at %s", pba->pba_busname, pnp);
    209 	printf(" bus %d", pba->pba_bus);
    210 	return (UNCONF);
    211 }
    212