1996-12-08 03:22:08 +03:00
|
|
|
/* $NetBSD: lca.c,v 1.15 1996/12/08 00:22:16 cgd Exp $ */
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
/*
|
1996-04-12 10:07:05 +04:00
|
|
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
1995-11-23 05:33:17 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1996-04-12 08:40:49 +04:00
|
|
|
* Authors: Jeffrey Hsu and Chris G. Demetriou
|
1995-11-23 05:33:17 +03:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
|
|
|
#include <machine/autoconf.h>
|
|
|
|
#include <machine/rpb.h>
|
|
|
|
|
|
|
|
#include <dev/isa/isareg.h>
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <alpha/pci/lcareg.h>
|
|
|
|
#include <alpha/pci/lcavar.h>
|
1996-07-11 07:30:11 +04:00
|
|
|
#if defined(DEC_AXPPCI_33)
|
|
|
|
#include <alpha/pci/pci_axppci_33.h>
|
|
|
|
#endif
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-12-05 04:39:27 +03:00
|
|
|
int lcamatch __P((struct device *, struct cfdata *, void *));
|
1995-11-23 05:33:17 +03:00
|
|
|
void lcaattach __P((struct device *, struct device *, void *));
|
|
|
|
|
1996-03-17 04:03:02 +03:00
|
|
|
struct cfattach lca_ca = {
|
1996-04-12 08:40:49 +04:00
|
|
|
sizeof(struct lca_softc), lcamatch, lcaattach,
|
1996-03-17 04:03:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver lca_cd = {
|
1996-04-12 08:40:49 +04:00
|
|
|
NULL, "lca", DV_DULL,
|
1995-11-23 05:33:17 +03:00
|
|
|
};
|
|
|
|
|
1996-08-28 01:53:46 +04:00
|
|
|
static int lcaprint __P((void *, const char *pnp));
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
/* There can be only one. */
|
|
|
|
int lcafound;
|
|
|
|
struct lca_config lca_configuration;
|
|
|
|
|
|
|
|
int
|
|
|
|
lcamatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
1996-12-05 04:39:27 +03:00
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1995-11-23 05:33:17 +03:00
|
|
|
{
|
|
|
|
struct confargs *ca = aux;
|
|
|
|
|
|
|
|
/* Make sure that we're looking for a LCA. */
|
1996-03-17 04:03:02 +03:00
|
|
|
if (strcmp(ca->ca_name, lca_cd.cd_name) != 0)
|
1995-11-23 05:33:17 +03:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
if (lcafound)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the chipset's function pointers.
|
|
|
|
*/
|
|
|
|
void
|
1996-11-25 06:56:48 +03:00
|
|
|
lca_init(lcp, mallocsafe)
|
1995-11-23 05:33:17 +03:00
|
|
|
struct lca_config *lcp;
|
1996-11-25 06:56:48 +03:00
|
|
|
int mallocsafe;
|
1995-11-23 05:33:17 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Can't set up SGMAP data here; can be called before malloc().
|
|
|
|
*/
|
|
|
|
|
1996-11-25 06:56:48 +03:00
|
|
|
/*
|
|
|
|
* The LCA HAE register is WRITE-ONLY, so we can't tell where
|
|
|
|
* the second sparse window is actually mapped. Therefore,
|
|
|
|
* we have to guess where it is. This seems to be the normal
|
|
|
|
* address.
|
|
|
|
*/
|
|
|
|
lcp->lc_s_mem_w2_masked_base = 0x80000000;
|
|
|
|
|
|
|
|
if (!lcp->lc_initted) {
|
|
|
|
/* don't do these twice since they set up extents */
|
|
|
|
lcp->lc_iot = lca_bus_io_init(lcp);
|
|
|
|
lcp->lc_memt = lca_bus_mem_init(lcp);
|
|
|
|
}
|
|
|
|
lcp->lc_mallocsafe = mallocsafe;
|
|
|
|
|
1996-04-12 08:40:49 +04:00
|
|
|
lca_pci_init(&lcp->lc_pc, lcp);
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-04-23 18:00:53 +04:00
|
|
|
/*
|
|
|
|
* Refer to ``DECchip 21066 and DECchip 21068 Alpha AXP Microprocessors
|
|
|
|
* Hardware Reference Manual''.
|
|
|
|
* ...
|
|
|
|
*/
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-04-23 18:00:53 +04:00
|
|
|
/*
|
|
|
|
* According to section 6.4.1, all bits of the IOC_HAE register are
|
|
|
|
* undefined after reset. Bits <31:27> are write-only. However, we
|
|
|
|
* cannot blindly set it to zero. The serial ROM code that initializes
|
|
|
|
* the PCI devices' address spaces, allocates sparse memory blocks in
|
|
|
|
* the range that must use the IOC_HAE register for address translation,
|
|
|
|
* and sets this register accordingly (see section 6.4.14).
|
|
|
|
*
|
|
|
|
* IOC_HAE left AS IS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* According to section 6.4.2, all bits of the IOC_CONF register are
|
|
|
|
* undefined after reset. Bits <1:0> are write-only. Set them to
|
|
|
|
* 0x00 for PCI Type 0 configuration access.
|
|
|
|
*
|
|
|
|
* IOC_CONF set to ZERO.
|
|
|
|
*/
|
1995-11-23 05:33:17 +03:00
|
|
|
REGVAL(LCA_IOC_CONF) = 0;
|
|
|
|
|
|
|
|
/* Turn off DMA window enables in Window Base Registers */
|
|
|
|
/* REGVAL(LCA_IOC_W_BASE0) = 0;
|
|
|
|
REGVAL(LCA_IOC_W_BASE1) = 0; */
|
1996-07-09 04:53:48 +04:00
|
|
|
alpha_mb();
|
1996-10-23 08:12:13 +04:00
|
|
|
|
|
|
|
/* XXX XXX BEGIN XXX XXX */
|
|
|
|
{ /* XXX */
|
|
|
|
extern vm_offset_t alpha_XXX_dmamap_or; /* XXX */
|
|
|
|
alpha_XXX_dmamap_or = 0x40000000; /* XXX */
|
|
|
|
} /* XXX */
|
|
|
|
/* XXX XXX END XXX XXX */
|
1996-11-25 06:56:48 +03:00
|
|
|
|
|
|
|
lcp->lc_initted = 1;
|
1995-11-23 05:33:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef notdef
|
|
|
|
void
|
|
|
|
lca_init_sgmap(lcp)
|
|
|
|
struct lca_config *lcp;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* XXX */
|
|
|
|
lcp->lc_sgmap = malloc(1024 * 8, M_DEVBUF, M_WAITOK);
|
|
|
|
bzero(lcp->lc_sgmap, 1024 * 8); /* clear all entries. */
|
|
|
|
|
|
|
|
REGVAL(LCA_IOC_W_BASE0) = 0;
|
1996-07-09 04:53:48 +04:00
|
|
|
alpha_mb();
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
/* Set up Translated Base Register 1; translate to sybBus addr 0. */
|
|
|
|
/* check size against APEC XXX JH */
|
1996-11-25 06:56:48 +03:00
|
|
|
REGVAL(LCA_IOC_T_BASE_0) = vtophys(lcp->lc_sgmap) >> 1;
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-11-25 06:56:48 +03:00
|
|
|
/* Set up PCI mask register 1; map 8MB space. */
|
|
|
|
REGVAL(LCA_IOC_W_MASK0) = 0x00700000;
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-11-25 06:56:48 +03:00
|
|
|
/* Enable window 1; from PCI address 8MB, direct mapped. */
|
|
|
|
REGVAL(LCA_IOC_W_BASE0) = 0x300800000;
|
|
|
|
alpha_mb();
|
1995-11-23 05:33:17 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
lcaattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct lca_softc *sc = (struct lca_softc *)self;
|
|
|
|
struct lca_config *lcp;
|
1996-04-12 08:40:49 +04:00
|
|
|
struct pcibus_attach_args pba;
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
/* note that we've attached the chipset; can't have 2 LCAs. */
|
|
|
|
/* Um, not sure about this. XXX JH */
|
|
|
|
lcafound = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set up the chipset's info; done once at console init time
|
|
|
|
* (maybe), but doesn't hurt to do twice.
|
|
|
|
*/
|
|
|
|
lcp = sc->sc_lcp = &lca_configuration;
|
1996-11-25 06:56:48 +03:00
|
|
|
lca_init(lcp, 1);
|
1995-11-23 05:33:17 +03:00
|
|
|
#ifdef notdef
|
|
|
|
lca_init_sgmap(lcp);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* XXX print chipset information */
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("\n");
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
switch (hwrpb->rpb_type) {
|
|
|
|
#if defined(DEC_AXPPCI_33)
|
|
|
|
case ST_DEC_AXPPCI_33:
|
1996-04-12 08:40:49 +04:00
|
|
|
pci_axppci_33_pickintr(lcp);
|
1995-11-23 05:33:17 +03:00
|
|
|
break;
|
|
|
|
#endif
|
1996-11-12 00:02:32 +03:00
|
|
|
|
1995-11-23 05:33:17 +03:00
|
|
|
default:
|
|
|
|
panic("lcaattach: shouldn't be here, really...");
|
|
|
|
}
|
|
|
|
|
1996-04-12 08:40:49 +04:00
|
|
|
pba.pba_busname = "pci";
|
1996-10-23 08:12:13 +04:00
|
|
|
pba.pba_iot = lcp->lc_iot;
|
|
|
|
pba.pba_memt = lcp->lc_memt;
|
1996-04-12 08:40:49 +04:00
|
|
|
pba.pba_pc = &lcp->lc_pc;
|
|
|
|
pba.pba_bus = 0;
|
|
|
|
config_found(self, &pba, lcaprint);
|
1995-11-23 05:33:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lcaprint(aux, pnp)
|
|
|
|
void *aux;
|
1996-08-28 01:53:46 +04:00
|
|
|
const char *pnp;
|
1995-11-23 05:33:17 +03:00
|
|
|
{
|
1996-11-25 06:56:48 +03:00
|
|
|
register struct pcibus_attach_args *pba = aux;
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
/* only PCIs can attach to LCAes; easy. */
|
|
|
|
if (pnp)
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("%s at %s", pba->pba_busname, pnp);
|
|
|
|
printf(" bus %d", pba->pba_bus);
|
1995-11-23 05:33:17 +03:00
|
|
|
return (UNCONF);
|
|
|
|
}
|