summaryrefslogtreecommitdiff
path: root/sys/arch/alpha
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-04-14 17:51:42 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-04-14 17:51:42 +0000
commit2a74271538330794b7d36b9d86e65fd2c3ae8b4f (patch)
tree424d797db685ee4ca2dbcb31c4c5860ef1b2f756 /sys/arch/alpha
parent9a7a8889ff5ab54b0caaa3cd0565968050615543 (diff)
Add support for Alpha Processor, Inc. UP1000.
From NetBSD.
Diffstat (limited to 'sys/arch/alpha')
-rw-r--r--sys/arch/alpha/alpha/api_up1000.c295
-rw-r--r--sys/arch/alpha/conf/GENERIC5
-rw-r--r--sys/arch/alpha/conf/files.alpha13
-rw-r--r--sys/arch/alpha/pci/irongate.c235
-rw-r--r--sys/arch/alpha/pci/irongate_bus_io.c66
-rw-r--r--sys/arch/alpha/pci/irongate_bus_mem.c92
-rw-r--r--sys/arch/alpha/pci/irongate_dma.c172
-rw-r--r--sys/arch/alpha/pci/irongate_pci.c169
-rw-r--r--sys/arch/alpha/pci/irongatereg.h96
-rw-r--r--sys/arch/alpha/pci/irongatevar.h78
-rw-r--r--sys/arch/alpha/pci/pci_up1000.c218
-rw-r--r--sys/arch/alpha/pci/pci_up1000.h39
12 files changed, 1475 insertions, 3 deletions
diff --git a/sys/arch/alpha/alpha/api_up1000.c b/sys/arch/alpha/alpha/api_up1000.c
new file mode 100644
index 00000000000..be2a5815c8e
--- /dev/null
+++ b/sys/arch/alpha/alpha/api_up1000.c
@@ -0,0 +1,295 @@
+/* $NetBSD: api_up1000.c,v 1.4 2000/06/20 03:48:53 matt Exp $ */
+
+/*
+ * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * 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.
+ */
+/*
+ * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/termios.h>
+#include <dev/cons.h>
+#include <sys/conf.h>
+
+#include <machine/rpb.h>
+#include <machine/autoconf.h>
+#include <machine/cpuconf.h>
+#include <machine/bus.h>
+
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+#include <dev/ic/i8042reg.h>
+#include <dev/ic/pckbcvar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+
+#include <alpha/pci/irongatereg.h>
+#include <alpha/pci/irongatevar.h>
+
+#include <scsi/scsi_all.h>
+#include <scsi/scsiconf.h>
+#include <dev/ata/atavar.h>
+
+#include "pckbd.h"
+
+#ifndef CONSPEED
+#define CONSPEED TTYDEF_SPEED
+#endif
+static int comcnrate = CONSPEED;
+
+#ifdef DEBUG
+int bootdev_debug;
+#define DPRINTF(x) if (bootdev_debug) printf x
+#else
+#define DPRINTF(x)
+#endif
+
+void api_up1000_init __P((void));
+static void api_up1000_cons_init __P((void));
+static void api_up1000_device_register __P((struct device *, void *));
+
+void
+api_up1000_init()
+{
+
+ platform.family = "Alpha Processor, Inc. UP1000";
+
+ if ((platform.model = alpha_dsr_sysname()) == NULL) {
+ /* XXX Don't know the system variations, yet. */
+ platform.model = alpha_unknown_sysname();
+ }
+
+ platform.iobus = "irongate";
+ platform.cons_init = api_up1000_cons_init;
+ platform.device_register = api_up1000_device_register;
+}
+
+static void
+api_up1000_cons_init()
+{
+ struct ctb *ctb;
+ struct irongate_config *icp;
+ extern struct irongate_config irongate_configuration;
+
+ icp = &irongate_configuration;
+ irongate_init(icp, 0);
+
+ ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
+
+ switch (ctb->ctb_term_type) {
+ case 2:
+ /* serial console ... */
+ /* XXX */
+ {
+ /*
+ * Delay to allow PROM putchars to complete.
+ * FIFO depth * character time,
+ * character time = (1000000 / (defaultrate / 10))
+ */
+ DELAY(160000000 / comcnrate);
+
+ if (comcnattach(icp->ic_iot, 0x3f8, comcnrate,
+ COM_FREQ,
+ (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
+ panic("can't init serial console");
+
+ break;
+ }
+
+ case 3:
+#if NPCKBD > 0
+ /* display console ... */
+ /* XXX */
+ (void) pckbc_cnattach(icp->ic_iot, IO_KBD, KBCMDP,
+ PCKBC_KBD_SLOT);
+
+ if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) ==
+ CTB_TURBOSLOT_TYPE_ISA)
+ isa_display_console(icp->ic_iot, icp->ic_memt);
+ else
+ pci_display_console(icp->ic_iot, icp->ic_memt,
+ &icp->ic_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
+ CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
+#else
+ panic("not configured to use display && keyboard console");
+#endif
+ break;
+
+ default:
+ printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
+ printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
+
+ panic("consinit: unknown console type %ld\n",
+ ctb->ctb_term_type);
+ }
+}
+
+static void
+api_up1000_device_register(dev, aux)
+ struct device *dev;
+ void *aux;
+{
+ static int found, initted, scsiboot, ideboot, netboot;
+ static struct device *pcidev, *scsidev;
+ struct bootdev_data *b = bootdev_data;
+ struct device *parent = dev->dv_parent;
+ struct cfdata *cf = dev->dv_cfdata;
+ struct cfdriver *cd = cf->cf_driver;
+
+ if (found)
+ return;
+
+ if (!initted) {
+ scsiboot = (strcmp(b->protocol, "SCSI") == 0);
+ netboot = (strcmp(b->protocol, "BOOTP") == 0) ||
+ (strcmp(b->protocol, "MOP") == 0);
+ /*
+ * Add an extra check to boot from ide drives:
+ * Newer SRM firmware use the protocol identifier IDE,
+ * older SRM firmware use the protocol identifier SCSI.
+ */
+ ideboot = (strcmp(b->protocol, "IDE") == 0);
+ DPRINTF(("\nscsiboot = %d, ideboot = %d, netboot = %d\n",
+ scsiboot, ideboot, netboot));
+ initted = 1;
+ }
+
+ if (pcidev == NULL) {
+ if (strcmp(cd->cd_name, "pci"))
+ return;
+ else {
+ struct pcibus_attach_args *pba = aux;
+
+ if ((b->slot / 1000) != pba->pba_bus)
+ return;
+
+ pcidev = dev;
+ DPRINTF(("\npcidev = %s\n", pcidev->dv_xname));
+ return;
+ }
+ }
+
+ if ((ideboot || scsiboot) && (scsidev == NULL)) {
+ if (parent != pcidev)
+ return;
+ else {
+ struct pci_attach_args *pa = aux;
+
+ if (b->slot % 1000 / 100 != pa->pa_function)
+ return;
+ if (b->slot % 100 != pa->pa_device)
+ return;
+
+ scsidev = dev;
+ DPRINTF(("\nscsidev = %s\n", scsidev->dv_xname));
+ return;
+ }
+ }
+
+ if ((ideboot || scsiboot) &&
+ (!strcmp(cd->cd_name, "sd") ||
+ !strcmp(cd->cd_name, "st") ||
+ !strcmp(cd->cd_name, "cd"))) {
+ struct scsibus_attach_args *sa = aux;
+
+ if (parent->dv_parent != scsidev)
+ return;
+
+ if (b->unit / 100 != sa->sa_sc_link->target)
+ return;
+
+ /* XXX LUN! */
+
+ switch (b->boot_dev_type) {
+ case 0:
+ if (strcmp(cd->cd_name, "sd") &&
+ strcmp(cd->cd_name, "cd"))
+ return;
+ break;
+ case 1:
+ if (strcmp(cd->cd_name, "st"))
+ return;
+ break;
+ default:
+ return;
+ }
+
+ /* we've found it! */
+ booted_device = dev;
+ DPRINTF(("\nbooted_device = %s\n", booted_device->dv_xname));
+ found = 1;
+ }
+
+ /*
+ * Support to boot from IDE drives.
+ */
+ if ((ideboot || scsiboot) && !strcmp(cd->cd_name, "wd")) {
+ struct ata_atapi_attach *aa_link = aux;
+ if ((strncmp("pciide", parent->dv_xname, 6) != 0)) {
+ return;
+ } else {
+ if (parent != scsidev)
+ return;
+ }
+ DPRINTF(("\natapi info: drive %d, channel %d\n",
+ aa_link->aa_drv_data->drive, aa_link->aa_channel));
+ DPRINTF(("bootdev info: unit: %d, channel: %d\n",
+ b->unit, b->channel));
+ if (b->unit != aa_link->aa_drv_data->drive ||
+ b->channel != aa_link->aa_channel)
+ return;
+
+ /* we've found it! */
+ booted_device = dev;
+ DPRINTF(("booted_device = %s\n", booted_device->dv_xname));
+ found = 1;
+ }
+
+ if (netboot) {
+ if (parent != pcidev)
+ return;
+ else {
+ struct pci_attach_args *pa = aux;
+
+ if ((b->slot % 1000) != pa->pa_device)
+ return;
+
+ /* XXX function? */
+
+ booted_device = dev;
+ DPRINTF(("\nbooted_device = %s\n",
+ booted_device->dv_xname));
+ found = 1;
+ return;
+ }
+ }
+}
diff --git a/sys/arch/alpha/conf/GENERIC b/sys/arch/alpha/conf/GENERIC
index 9d2494c567d..3edda2f6c0f 100644
--- a/sys/arch/alpha/conf/GENERIC
+++ b/sys/arch/alpha/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.70 2001/04/09 20:40:50 deraadt Exp $
+# $OpenBSD: GENERIC,v 1.71 2001/04/14 17:51:41 art Exp $
# $NetBSD: GENERIC,v 1.31 1996/12/03 17:25:29 cgd Exp $
#
# Generic Alpha kernel. Enough to get booted, etc., but not much more.
@@ -21,6 +21,7 @@ option DEC_EB164 # EB164: AlphaPC 164
option DEC_2000_300 # "Jensen": 2000/300 (DECpc AXP 150)
option DEC_550 # Miata: Digital Personal Workstation
option DEC_6600 # EV6: 264DP OEM Board
+option API_UP1000 # EV6: Alpha Processor, Inc. UP1000
option COMPAT_OSF1 # OSF/1 binary compatibility
option COMPAT_NETBSD # NetBSD compatibility
@@ -104,12 +105,14 @@ fta* at tc? slot ? offset ? # DEC DEFTA FDDI cards
# PCI host bus adapter support
apecs* at mainbus?
cia* at mainbus?
+irongate* at mainbus?
lca* at mainbus?
tsp* at tsc?
# PCI bus support
pci* at apecs?
pci* at cia?
+pci* at irongate?
pci* at lca?
pci* at ppb?
pci* at tsp?
diff --git a/sys/arch/alpha/conf/files.alpha b/sys/arch/alpha/conf/files.alpha
index 8795ac9080a..0309853c0c3 100644
--- a/sys/arch/alpha/conf/files.alpha
+++ b/sys/arch/alpha/conf/files.alpha
@@ -1,4 +1,4 @@
-# $OpenBSD: files.alpha,v 1.46 2001/03/21 17:26:38 art Exp $
+# $OpenBSD: files.alpha,v 1.47 2001/04/14 17:51:41 art Exp $
# $NetBSD: files.alpha,v 1.32 1996/11/25 04:03:21 cgd Exp $
#
# alpha-specific configuration info
@@ -188,6 +188,14 @@ file arch/alpha/pci/cia_bus_mem.c cia
file arch/alpha/pci/cia_bwx_bus_io.c cia
file arch/alpha/pci/cia_bwx_bus_mem.c cia
+device irongate: pcibus
+attach irongate at mainbus
+file arch/alpha/pci/irongate.c irongate
+file arch/alpha/pci/irongate_bus_io.c irongate
+file arch/alpha/pci/irongate_bus_mem.c irongate
+file arch/alpha/pci/irongate_dma.c irongate
+file arch/alpha/pci/irongate_pci.c irongate
+
device tsc { }
attach tsc at mainbus
file arch/alpha/pci/tsc.c dec_6600
@@ -206,6 +214,7 @@ file arch/alpha/pci/pci_eb164_intr.s dec_eb164
file arch/alpha/pci/pci_kn20aa.c dec_kn20aa
file arch/alpha/pci/pci_550.c dec_550
file arch/alpha/pci/pci_6600.c dec_6600
+file arch/alpha/pci/pci_up1000.c api_up1000
#
# PCI Bus devices
@@ -289,7 +298,7 @@ file arch/alpha/alpha/dec_eb164.c dec_eb164 needs-flag
file arch/alpha/alpha/dec_kn20aa.c dec_kn20aa needs-flag
file arch/alpha/alpha/dec_550.c dec_550 needs-flag
file arch/alpha/alpha/dec_6600.c dec_6600 needs-flag
-
+file arch/alpha/alpha/api_up1000.c api_up1000 needs-flag
# OSF/1 Binary Compatibility (COMPAT_OSF1)
include "compat/osf1/files.osf1"
diff --git a/sys/arch/alpha/pci/irongate.c b/sys/arch/alpha/pci/irongate.c
new file mode 100644
index 00000000000..2d478b85527
--- /dev/null
+++ b/sys/arch/alpha/pci/irongate.c
@@ -0,0 +1,235 @@
+/* $NetBSD: irongate.c,v 1.3 2000/11/29 06:29:10 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.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/irongatereg.h>
+#include <alpha/pci/irongatevar.h>
+
+#ifdef API_UP1000
+#include <alpha/pci/pci_up1000.h>
+#endif
+
+int irongate_match(struct device *, void *, void *);
+void irongate_attach(struct device *, struct device *, void *);
+
+struct cfattach irongate_ca = {
+ sizeof(struct irongate_softc), irongate_match, irongate_attach,
+};
+
+int irongate_print(void *, const char *pnp);
+
+struct cfdriver irongate_cd = {
+ NULL, "irongate", DV_DULL,
+};
+
+/* There can be only one. */
+struct irongate_config irongate_configuration;
+int irongate_found;
+
+#if 0
+int irongate_bus_get_window(int, int,
+ struct alpha_bus_space_translation *);
+#endif
+
+/*
+ * Set up the chipset's function pointers.
+ */
+void
+irongate_init(struct irongate_config *icp, int mallocsafe)
+{
+ pcitag_t tag;
+ pcireg_t reg;
+
+ icp->ic_mallocsafe = mallocsafe;
+
+ /*
+ * Set up PCI configuration space; we can only read the
+ * revision info through configuration space.
+ */
+ irongate_pci_init(&icp->ic_pc, icp);
+#if 0
+ alpha_pci_chipset = &icp->ic_pc;
+#endif
+
+ tag = pci_make_tag(&icp->ic_pc, 0, IRONGATE_PCIHOST_DEV, 0);
+
+ /* Read the revision. */
+ reg = irongate_conf_read0(icp, tag, PCI_CLASS_REG);
+ icp->ic_rev = PCI_REVISION(reg);
+
+ if (icp->ic_initted == 0) {
+ /* Don't do these twice, since they set up extents. */
+ icp->ic_iot = irongate_bus_io_init(icp);
+ icp->ic_memt = irongate_bus_mem_init(icp);
+
+#if 0
+ /* Only one each PCI I/O and MEM window. */
+ alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 1;
+ alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 1;
+
+ alpha_bus_get_window = irongate_bus_get_window;
+#endif
+ }
+
+ icp->ic_initted = 1;
+}
+
+int
+irongate_match(struct device *parent, void *match, void *aux)
+{
+ struct mainbus_attach_args *ma = aux;
+
+ /* Make sure we're looking for an Irongate. */
+ if (strcmp(ma->ma_name, irongate_cd.cd_name) != 0)
+ return (0);
+
+ if (irongate_found)
+ return (0);
+
+ return (1);
+}
+
+void
+irongate_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct irongate_softc *sc = (void *) self;
+ struct irongate_config *icp;
+ struct pcibus_attach_args pba;
+
+ /* Note that we've attached the chipset; can't have 2 Irongates. */
+ irongate_found = 1;
+
+ /*
+ * Set up the chipset's info; done once at console init time
+ * (maybe), but we must do it here as well to take care of things
+ * that need to use memory allocation.
+ */
+ icp = sc->sc_icp = &irongate_configuration;
+ irongate_init(icp, 1);
+
+ printf(": AMD 751 Core Logic + AGP Chipset, rev. %d\n", icp->ic_rev);
+
+ irongate_dma_init(icp);
+
+ /*
+ * Do PCI memory initialization that needs to be deferred until
+ * malloc is safe.
+ */
+ irongate_bus_mem_init2(icp->ic_memt, icp);
+
+ switch (cputype) {
+#ifdef API_UP1000
+ case ST_API_NAUTILUS:
+ pci_up1000_pickintr(icp);
+ break;
+#endif
+
+ default:
+ panic("irongate_attach: shouldn't be here, really...");
+ }
+
+ pba.pba_busname = "pci";
+ pba.pba_iot = icp->ic_iot;
+ pba.pba_memt = icp->ic_memt;
+ pba.pba_dmat =
+ alphabus_dma_get_tag(&icp->ic_dmat_pci, ALPHA_BUS_PCI);
+ pba.pba_pc = &icp->ic_pc;
+ pba.pba_bus = 0;
+#ifdef notyet
+ pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
+ PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
+#endif
+ (void) config_found(self, &pba, irongate_print);
+}
+
+int
+irongate_print(void *aux, const char *pnp)
+{
+ struct pcibus_attach_args *pba = aux;
+
+ /* Only PCIs can attach to Irongates; easy. */
+ if (pnp != NULL)
+ printf("%s at %s", pba->pba_busname, pnp);
+ printf(" bus %d", pba->pba_bus);
+ return (UNCONF);
+}
+
+#if 0
+int
+irongate_bus_get_window(int type, int window,
+ struct alpha_bus_space_translation *abst)
+{
+ struct irongate_config *icp = &irongate_configuration;
+ bus_space_tag_t st;
+ int error;
+
+ switch (type) {
+ case ALPHA_BUS_TYPE_PCI_IO:
+ st = &icp->ic_iot;
+ break;
+
+ case ALPHA_BUS_TYPE_PCI_MEM:
+ st = &icp->ic_memt;
+ break;
+
+ default:
+ panic("irongate_bus_get_window");
+ }
+
+ error = alpha_bus_space_get_window(st, window, abst);
+ if (error)
+ return (error);
+
+ abst->abst_sys_start = IRONGATE_PHYSADDR(abst->abst_sys_start);
+ abst->abst_sys_end = IRONGATE_PHYSADDR(abst->abst_sys_end);
+
+ return (0);
+}
+#endif \ No newline at end of file
diff --git a/sys/arch/alpha/pci/irongate_bus_io.c b/sys/arch/alpha/pci/irongate_bus_io.c
new file mode 100644
index 00000000000..76d6c5f2d0c
--- /dev/null
+++ b/sys/arch/alpha/pci/irongate_bus_io.c
@@ -0,0 +1,66 @@
+/* $NetBSD: irongate_bus_io.c,v 1.4 2000/06/29 08:58:47 mrg Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/syslog.h>
+#include <sys/device.h>
+
+#include <vm/vm.h>
+#include <uvm/uvm_extern.h>
+
+#include <machine/bus.h>
+
+#include <alpha/pci/irongatereg.h>
+#include <alpha/pci/irongatevar.h>
+
+#define CHIP irongate
+
+#define CHIP_EX_MALLOC_SAFE(v) (((struct irongate_config *)(v))->ic_mallocsafe)
+#define CHIP_IO_EXTENT(v) (((struct irongate_config *)(v))->ic_io_ex)
+
+#define CHIP_IO_SYS_START(v) IRONGATE_IO_BASE
+
+/*
+ * AMD 751 core logic appears on EV6. We require at least EV56
+ * support for the assembler to emit BWX opcodes.
+ */
+__asm(".arch ev6");
+
+#include <alpha/pci/pci_bwx_bus_io_chipdep.c>
diff --git a/sys/arch/alpha/pci/irongate_bus_mem.c b/sys/arch/alpha/pci/irongate_bus_mem.c
new file mode 100644
index 00000000000..aaaab4410a9
--- /dev/null
+++ b/sys/arch/alpha/pci/irongate_bus_mem.c
@@ -0,0 +1,92 @@
+/* $NetBSD: irongate_bus_mem.c,v 1.6 2000/11/29 06:29:10 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/syslog.h>
+#include <sys/device.h>
+
+#include <vm/vm.h>
+#include <uvm/uvm_extern.h>
+
+#include <machine/bus.h>
+
+#include <alpha/pci/irongatereg.h>
+#include <alpha/pci/irongatevar.h>
+
+#define CHIP irongate
+
+#define CHIP_EX_MALLOC_SAFE(v) (((struct irongate_config *)(v))->ic_mallocsafe)
+#define CHIP_MEM_EXTENT(v) (((struct irongate_config *)(v))->ic_mem_ex)
+
+#define CHIP_MEM_SYS_START(v) IRONGATE_MEM_BASE
+
+/*
+ * AMD 751 core logic appears on EV6. We require at least EV56
+ * support for the assembler to emit BWX opcodes.
+ */
+__asm(".arch ev6");
+
+#include <alpha/pci/pci_bwx_bus_mem_chipdep.c>
+
+#include <sys/kcore.h>
+
+extern phys_ram_seg_t mem_clusters[];
+extern int mem_cluster_cnt;
+
+void
+irongate_bus_mem_init2(bus_space_tag_t t, void *v)
+{
+ int i, error;
+
+ /*
+ * Since the AMD 751 doesn't have DMA windows, we need to
+ * allocate RAM out of the extent map.
+ */
+ for (i = 0; i < mem_cluster_cnt; i++) {
+ error = extent_alloc_region(CHIP_MEM_EXTENT(v),
+ mem_clusters[i].start, mem_clusters[i].size,
+ EX_NOWAIT | (CHIP_EX_MALLOC_SAFE(v) ? EX_MALLOCOK : 0));
+ if (error) {
+ printf("WARNING: unable reserve RAM at 0x%lx - 0x%lx\n",
+ mem_clusters[i].start,
+ mem_clusters[i].start + (mem_clusters[i].size - 1));
+ }
+ }
+}
diff --git a/sys/arch/alpha/pci/irongate_dma.c b/sys/arch/alpha/pci/irongate_dma.c
new file mode 100644
index 00000000000..104d752c4b0
--- /dev/null
+++ b/sys/arch/alpha/pci/irongate_dma.c
@@ -0,0 +1,172 @@
+/* $NetBSD: irongate_dma.c,v 1.3 2000/06/29 08:58:47 mrg Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * DMA support for the AMD 751 (``Irongate'') core logic chipset.
+ *
+ * The AMD 751 is really unlike all of the other Alpha PCI core logic
+ * chipsets. Instead, it looks like a normal PC chipset (not surprising,
+ * since it is used for Athlon processors).
+ *
+ * Because of this, it lacks all of the SGMAP hardware normally present
+ * on an Alpha system, and there are no DMA windows. Instead, a memory
+ * bus address is a PCI DMA address, and ISA DMA above 16M has to be
+ * bounced (this is not unlike the Jensen, actually).
+ */
+
+/*
+ * XXX - We should define this before including bus.h, but since other stuff
+ * pulls in bus.h we must do this here.
+ */
+#define _ALPHA_BUS_DMA_PRIVATE
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+
+#include <vm/vm.h>
+#include <uvm/uvm_extern.h>
+
+#include <machine/bus.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+
+#include <alpha/pci/irongatereg.h>
+#include <alpha/pci/irongatevar.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+
+bus_dma_tag_t irongate_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
+
+void
+irongate_dma_init(struct irongate_config *icp)
+{
+ bus_dma_tag_t t;
+
+ /*
+ * Initialize the DMA tag used for PCI DMA.
+ */
+ t = &icp->ic_dmat_pci;
+ t->_cookie = icp;
+ t->_wbase = 0;
+ t->_wsize = 0x100000000UL;
+ t->_next_window = NULL;
+ t->_boundary = 0;
+ t->_sgmap = NULL;
+ t->_get_tag = irongate_dma_get_tag;
+ t->_dmamap_create = _bus_dmamap_create;
+ t->_dmamap_destroy = _bus_dmamap_destroy;
+ t->_dmamap_load = _bus_dmamap_load_direct;
+ t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
+ t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
+ t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
+ t->_dmamap_unload = _bus_dmamap_unload;
+ t->_dmamap_sync = _bus_dmamap_sync;
+
+ t->_dmamem_alloc = _bus_dmamem_alloc;
+ t->_dmamem_free = _bus_dmamem_free;
+ t->_dmamem_map = _bus_dmamem_map;
+ t->_dmamem_unmap = _bus_dmamem_unmap;
+ t->_dmamem_mmap = _bus_dmamem_mmap;
+
+#if 0
+ /*
+ * Initialize the DMA tag used for ISA DMA.
+ */
+ t = &icp->ic_dmat_isa;
+ t->_cookie = icp;
+ t->_wbase = 0;
+ t->_wsize = 0x1000000;
+ t->_next_window = NULL;
+ t->_boundary = 0;
+ t->_sgmap = NULL;
+ t->_get_tag = irongate_dma_get_tag;
+ t->_dmamap_create = isadma_bounce_dmamap_create;
+ t->_dmamap_destroy = isadma_bounce_dmamap_destroy;
+ t->_dmamap_load = isadma_bounce_dmamap_load;
+ t->_dmamap_load_mbuf = isadma_bounce_dmamap_load_mbuf;
+ t->_dmamap_load_uio = isadma_bounce_dmamap_load_uio;
+ t->_dmamap_load_raw = isadma_bounce_dmamap_load_raw;
+ t->_dmamap_unload = isadma_bounce_dmamap_unload;
+ t->_dmamap_sync = isadma_bounce_dmamap_sync;
+
+ t->_dmamem_alloc = isadma_bounce_dmamem_alloc;
+ t->_dmamem_free = _bus_dmamem_free;
+ t->_dmamem_map = _bus_dmamem_map;
+ t->_dmamem_unmap = _bus_dmamem_unmap;
+ t->_dmamem_mmap = _bus_dmamem_mmap;
+#endif
+ /* XXX XXX BEGIN XXX XXX */
+ { /* XXX */
+ extern paddr_t alpha_XXX_dmamap_or; /* XXX */
+ alpha_XXX_dmamap_or = 0; /* XXX */
+ } /* XXX */
+ /* XXX XXX END XXX XXX */
+}
+
+/*
+ * Return the bus dma tag to be used for the specified bus type.
+ * INTERNAL USE ONLY!
+ */
+bus_dma_tag_t
+irongate_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype)
+{
+ struct irongate_config *icp = t->_cookie;
+
+ switch (bustype) {
+ case ALPHA_BUS_PCI:
+ case ALPHA_BUS_EISA:
+ /*
+ * Busses capable of 32-bit DMA get the PCI DMA tag.
+ */
+ return (&icp->ic_dmat_pci);
+
+ case ALPHA_BUS_ISA:
+ /*
+ * Lame 24-bit busses have to bounce.
+ */
+ return (&icp->ic_dmat_isa);
+
+ default:
+ panic("irongate_dma_get_tag: shouldn't be here, really...");
+ }
+}
diff --git a/sys/arch/alpha/pci/irongate_pci.c b/sys/arch/alpha/pci/irongate_pci.c
new file mode 100644
index 00000000000..d02bec02432
--- /dev/null
+++ b/sys/arch/alpha/pci/irongate_pci.c
@@ -0,0 +1,169 @@
+/* $NetBSD: irongate_pci.c,v 1.2 2000/06/29 08:58:47 mrg Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * PCI Configuration Space support for the AMD 751 (``Irongate'') core logic
+ * chipset.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <vm/vm.h>
+#include <uvm/uvm_extern.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <alpha/pci/irongatereg.h>
+#include <alpha/pci/irongatevar.h>
+
+void irongate_attach_hook __P((struct device *, struct device *,
+ struct pcibus_attach_args *));
+int irongate_bus_maxdevs __P((void *, int));
+pcitag_t irongate_make_tag __P((void *, int, int, int));
+void irongate_decompose_tag __P((void *, pcitag_t, int *, int *,
+ int *));
+pcireg_t irongate_conf_read __P((void *, pcitag_t, int));
+void irongate_conf_write __P((void *, pcitag_t, int, pcireg_t));
+
+/* AMD 751 systems are always single-processor, so this is easy. */
+#define PCI_CONF_LOCK(s) (s) = splhigh()
+#define PCI_CONF_UNLOCK(s) splx((s))
+
+#define PCI_CONF_ADDR (IRONGATE_IO_BASE|IRONGATE_CONFADDR)
+#define PCI_CONF_DATA (IRONGATE_IO_BASE|IRONGATE_CONFDATA)
+
+#define REGVAL(r) (*(__volatile u_int32_t *)ALPHA_PHYS_TO_K0SEG(r))
+
+void
+irongate_pci_init(pci_chipset_tag_t pc, void *v)
+{
+
+ pc->pc_conf_v = v;
+ pc->pc_attach_hook = irongate_attach_hook;
+ pc->pc_bus_maxdevs = irongate_bus_maxdevs;
+ pc->pc_make_tag = irongate_make_tag;
+ pc->pc_decompose_tag = irongate_decompose_tag;
+ pc->pc_conf_read = irongate_conf_read;
+ pc->pc_conf_write = irongate_conf_write;
+}
+
+void
+irongate_attach_hook(struct device *parent, struct device *self,
+ struct pcibus_attach_args *pba)
+{
+}
+
+int
+irongate_bus_maxdevs(void *ipv, int busno)
+{
+
+ return 32;
+}
+
+pcitag_t
+irongate_make_tag(void *ipv, int b, int d, int f)
+{
+
+ return (b << 16) | (d << 11) | (f << 8);
+}
+
+void
+irongate_decompose_tag(void *ipv, pcitag_t tag, int *bp, int *dp, int *fp)
+{
+
+ if (bp != NULL)
+ *bp = (tag >> 16) & 0xff;
+ if (dp != NULL)
+ *dp = (tag >> 11) & 0x1f;
+ if (fp != NULL)
+ *fp = (tag >> 8) & 0x7;
+}
+
+pcireg_t
+irongate_conf_read(void *ipv, pcitag_t tag, int offset)
+{
+ int d;
+
+ /*
+ * The AMD 751 appears in PCI configuration space, but
+ * that is ... counter-intuitive to the way we normally
+ * attach PCI-Host bridges on the Alpha. So, filter out
+ * the AMD 751 device here. We provide a private entry
+ * point for getting at it from machdep code.
+ */
+ irongate_decompose_tag(ipv, tag, NULL, &d, NULL);
+ if (d == IRONGATE_PCIHOST_DEV)
+ return ((pcireg_t) -1);
+
+ return (irongate_conf_read0(ipv, tag, offset));
+}
+
+pcireg_t
+irongate_conf_read0(void *ipv, pcitag_t tag, int offset)
+{
+ pcireg_t data;
+ int s;
+
+ PCI_CONF_LOCK(s);
+ REGVAL(PCI_CONF_ADDR) = (CONFADDR_ENABLE | tag | (offset & 0xff));
+ alpha_mb();
+ data = REGVAL(PCI_CONF_DATA);
+ REGVAL(PCI_CONF_ADDR) = 0;
+ alpha_mb();
+ PCI_CONF_UNLOCK(s);
+
+ return (data);
+}
+
+void
+irongate_conf_write(void *ipv, pcitag_t tag, int offset, pcireg_t data)
+{
+ int s;
+
+ PCI_CONF_LOCK(s);
+ REGVAL(PCI_CONF_ADDR) = (CONFADDR_ENABLE | tag | (offset & 0xff));
+ alpha_mb();
+ REGVAL(PCI_CONF_DATA) = data;
+ alpha_mb();
+ REGVAL(PCI_CONF_ADDR) = 0;
+ alpha_mb();
+ PCI_CONF_UNLOCK(s);
+}
diff --git a/sys/arch/alpha/pci/irongatereg.h b/sys/arch/alpha/pci/irongatereg.h
new file mode 100644
index 00000000000..58602bc46ce
--- /dev/null
+++ b/sys/arch/alpha/pci/irongatereg.h
@@ -0,0 +1,96 @@
+/* $NetBSD: irongatereg.h,v 1.2 2000/06/26 02:42:10 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Register definitions for the AMD 751 (``Irongate'') core logic
+ * chipset.
+ */
+
+/*
+ * Address map.
+ *
+ * This from the Tsunami address map:
+ * EV6 has a new superpage which can pass through 44 address bits. (Umm, a
+ * superduperpage?) But, the firmware doesn't turn it on, so we use the old
+ * one and let the HW sign extend va/pa<40> to get us the pa<43> that makes
+ * the needed I/O space access. This is just as well; it means we don't have
+ * to worry about which GENERIC code might get called on other CPU models.
+ *
+ * E.g., we want this: 0x0801##fc00##0000
+ * We use this: 0x0101##fc00##0000
+ * ...mix in the old SP: 0xffff##fc00##0000##0000
+ * ...after PA sign ext: 0xffff##ff01##fc00##0000
+ * (PA<42:41> ignored)
+ *
+ * PCI memory and RAM: 0000.0000.0000
+ * IACK 0001.f800.0000
+ * PCI I/O: 0001.fc00.0000
+ * AMD 751 (also in PCI config space): 0001.fe00.0000
+ */
+
+/*
+ * This hack allows us to map the I/O address space without using
+ * the KSEG sign extension hack.
+ */
+#define IRONGATE_PHYSADDR(x) \
+ (((x) & ~0x0100##0000##0000) | 0x0800##0000##0000)
+
+#define IRONGATE_KSEG_BIAS 0x0100##0000##0000UL
+
+#define IRONGATE_MEM_BASE (IRONGATE_KSEG_BIAS | 0x0000##0000##0000UL)
+#define IRONGATE_IACK_BASE (IRONGATE_KSEG_BIAS | 0x0001##f800##0000UL)
+#define IRONGATE_IO_BASE (IRONGATE_KSEG_BIAS | 0x0001##fc00##0000UL)
+#define IRONGATE_SELF_BASE (IRONGATE_KSEG_BIAS | 0x0001##fe00##0000UL)
+
+/*
+ * PCI configuration register access using done by using
+ * ``configuration mode 1'' (in PC lingo), using the I/O
+ * space addresses described in the PCI Local Bus Specification
+ * Revision 2.2.
+ */
+#define IRONGATE_CONFADDR 0x0cf8
+#define IRONGATE_CONFDATA 0x0cfc
+
+#define CONFADDR_ENABLE 0x80000000U
+
+/*
+ * The AMD 751 PCI-Host bridge is located at device 0, and the
+ * AGP controller (seen as a PCI-PCI bridge) is at device 1.
+ */
+#define IRONGATE_PCIHOST_DEV 0
+#define IRONGATE_PCIAGP_DEV 1
diff --git a/sys/arch/alpha/pci/irongatevar.h b/sys/arch/alpha/pci/irongatevar.h
new file mode 100644
index 00000000000..378d47a08d3
--- /dev/null
+++ b/sys/arch/alpha/pci/irongatevar.h
@@ -0,0 +1,78 @@
+/* $NetBSD: irongatevar.h,v 1.3 2000/11/29 06:29:10 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <dev/isa/isavar.h>
+#include <dev/pci/pcivar.h>
+
+/*
+ * AMD 751 chipset's configuration.
+ *
+ * All of the information that the chipset-specific functions need to
+ * do their dirty work (and more!).
+ */
+struct irongate_config {
+ int ic_initted;
+
+ bus_space_tag_t ic_iot, ic_memt;
+ struct alpha_pci_chipset ic_pc;
+
+ struct alpha_bus_dma_tag ic_dmat_pci;
+ struct alpha_bus_dma_tag ic_dmat_isa;
+
+ u_int32_t ic_rev;
+
+ struct extent *ic_io_ex, *ic_mem_ex;
+ int ic_mallocsafe;
+};
+
+struct irongate_softc {
+ struct device sc_dev;
+
+ struct irongate_config *sc_icp;
+};
+
+void irongate_init(struct irongate_config *, int);
+void irongate_pci_init(pci_chipset_tag_t, void *);
+void irongate_dma_init(struct irongate_config *);
+
+bus_space_tag_t irongate_bus_io_init(void *);
+bus_space_tag_t irongate_bus_mem_init(void *);
+
+void irongate_bus_mem_init2(bus_space_tag_t, void *);
+
+pcireg_t irongate_conf_read0(void *, pcitag_t, int);
diff --git a/sys/arch/alpha/pci/pci_up1000.c b/sys/arch/alpha/pci/pci_up1000.c
new file mode 100644
index 00000000000..54804f3a1e6
--- /dev/null
+++ b/sys/arch/alpha/pci/pci_up1000.c
@@ -0,0 +1,218 @@
+/* $NetBSD: pci_up1000.c,v 1.6 2000/12/28 22:59:07 sommerfeld Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+
+#include <vm/vm.h>
+#include <uvm/uvm_extern.h>
+
+#include <machine/autoconf.h>
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/isa/isavar.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pciidereg.h>
+#include <dev/pci/pciidevar.h>
+
+#include <alpha/pci/irongatevar.h>
+
+#include <alpha/pci/pci_up1000.h>
+#include <alpha/pci/siovar.h>
+#include <alpha/pci/sioreg.h>
+
+#include "sio.h"
+
+int api_up1000_intr_map(void *, pcitag_t, int, int, pci_intr_handle_t *);
+const char *api_up1000_intr_string(void *, pci_intr_handle_t);
+const struct evcnt *api_up1000_intr_evcnt(void *, pci_intr_handle_t);
+void *api_up1000_intr_establish(void *, pci_intr_handle_t,
+ int, int (*func)(void *), void *, char *);
+void api_up1000_intr_disestablish(void *, void *);
+
+void *api_up1000_pciide_compat_intr_establish(void *, struct device *,
+ struct pci_attach_args *, int, int (*)(void *), void *);
+
+void
+pci_up1000_pickintr(struct irongate_config *icp)
+{
+ bus_space_tag_t iot = icp->ic_iot;
+ pci_chipset_tag_t pc = &icp->ic_pc;
+
+ pc->pc_intr_v = icp;
+ pc->pc_intr_map = api_up1000_intr_map;
+ pc->pc_intr_string = api_up1000_intr_string;
+#if 0
+ pc->pc_intr_evcnt = api_up1000_intr_evcnt;
+#endif
+ pc->pc_intr_establish = api_up1000_intr_establish;
+ pc->pc_intr_disestablish = api_up1000_intr_disestablish;
+
+ pc->pc_pciide_compat_intr_establish =
+ api_up1000_pciide_compat_intr_establish;
+
+#if NSIO
+ sio_intr_setup(pc, iot);
+ set_iointr(&sio_iointr);
+#else
+ panic("pci_up1000_pickintr: no I/O interrupt handler (no sio)");
+#endif
+}
+
+int
+api_up1000_intr_map(void *icv, pcitag_t bustag, int buspin, int line, pci_intr_handle_t *ihp)
+{
+ struct irongate_config *icc = icv;
+ pci_chipset_tag_t pc = &icc->ic_pc;
+ int bus, device, function;
+
+ if (buspin == 0) {
+ /* No IRQ used. */
+ return 1;
+ }
+ if (buspin > 4) {
+ printf("api_up1000_intr_map: bad interrupt pin %d\n",
+ buspin);
+ return 1;
+ }
+
+ alpha_pci_decompose_tag(pc, bustag, &bus, &device, &function);
+
+ /*
+ * The console places the interrupt mapping in the "line" value.
+ * A value of (char)-1 indicates there is no mapping.
+ */
+ if (line == 0xff) {
+ printf("api_up1000_intr_map: no mapping for %d/%d/%d\n",
+ bus, device, function);
+ return (1);
+ }
+
+ /* XXX Check for 0? */
+ if (line > 15) {
+ printf("api_up1000_intr_map: ISA IRQ too large (%d)\n",
+ line);
+ return (1);
+ }
+ if (line == 2) {
+ printf("api_up1000_intr_map: changed IRQ 2 to IRQ 9\n");
+ line = 9;
+ }
+
+ *ihp = line;
+ return (0);
+}
+
+const char *
+api_up1000_intr_string(void *icv, pci_intr_handle_t ih)
+{
+#if 0
+ struct irongate_config *icp = icv;
+#endif
+
+ return sio_intr_string(NULL /*XXX*/, ih);
+}
+
+#if 0
+const struct evcnt *
+api_up1000_intr_evcnt(void *icv, pci_intr_handle_t ih)
+{
+#if 0
+ struct irongate_config *icp = icv;
+#endif
+
+ return sio_intr_evcnt(NULL /*XXX*/, ih);
+}
+#endif
+
+void *
+api_up1000_intr_establish(void *icv, pci_intr_handle_t ih, int level,
+ int (*func)(void *), void *arg, char *name)
+{
+#if 0
+ struct irongate_config *icp = icv;
+#endif
+
+ return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func,
+ arg, name);
+}
+
+void
+api_up1000_intr_disestablish(void *icv, void *cookie)
+{
+#if 0
+ struct irongate_config *icp = icv;
+#endif
+
+ sio_intr_disestablish(NULL /*XXX*/, cookie);
+}
+
+void *
+api_up1000_pciide_compat_intr_establish(void *icv, struct device *dev,
+ struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg)
+{
+ pci_chipset_tag_t pc = pa->pa_pc;
+ void *cookie = NULL;
+ int bus, irq;
+
+ alpha_pci_decompose_tag(pc, pa->pa_tag, &bus, NULL, NULL);
+
+ /*
+ * If this isn't PCI bus #0, all bets are off.
+ */
+ if (bus != 0)
+ return (NULL);
+
+ irq = PCIIDE_COMPAT_IRQ(chan);
+#if NSIO
+ cookie = sio_intr_establish(NULL /*XXX*/, irq, IST_EDGE, IPL_BIO,
+ func, arg, "up 1000 irq");
+ if (cookie == NULL)
+ return (NULL);
+ printf("%s: %s channel interrupting at %s\n", dev->dv_xname,
+ PCIIDE_CHANNEL_NAME(chan), sio_intr_string(NULL /*XXX*/, irq));
+#endif
+ return (cookie);
+}
diff --git a/sys/arch/alpha/pci/pci_up1000.h b/sys/arch/alpha/pci/pci_up1000.h
new file mode 100644
index 00000000000..c256a88bf6a
--- /dev/null
+++ b/sys/arch/alpha/pci/pci_up1000.h
@@ -0,0 +1,39 @@
+/* $NetBSD: pci_up1000.h,v 1.1 2000/06/01 20:30:31 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+void pci_up1000_pickintr __P((struct irongate_config *));