Module Name: src
Committed By: rkujawa
Date: Wed May 30 18:01:52 UTC 2012
Modified Files:
src/sys/arch/amiga/conf: GENERIC.in files.amiga
Added Files:
src/sys/arch/amiga/pci: emmem.c emmemvar.h empb.c empbreg.h
Log Message:
Add a driver for Elbox Mediator 1200 PCI bridges. This is still a work in
progress, but now it is good enough to drive a NE2000 card. Support for
memory space accesses will be added soon(ish).
To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/arch/amiga/conf/GENERIC.in
cvs rdiff -u -r1.156 -r1.157 src/sys/arch/amiga/conf/files.amiga
cvs rdiff -u -r0 -r1.1 src/sys/arch/amiga/pci/emmem.c \
src/sys/arch/amiga/pci/emmemvar.h src/sys/arch/amiga/pci/empb.c \
src/sys/arch/amiga/pci/empbreg.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amiga/conf/GENERIC.in
diff -u src/sys/arch/amiga/conf/GENERIC.in:1.99 src/sys/arch/amiga/conf/GENERIC.in:1.100
--- src/sys/arch/amiga/conf/GENERIC.in:1.99 Tue May 15 17:35:44 2012
+++ src/sys/arch/amiga/conf/GENERIC.in Wed May 30 18:01:51 2012
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.in,v 1.99 2012/05/15 17:35:44 rkujawa Exp $
+# $NetBSD: GENERIC.in,v 1.100 2012/05/30 18:01:51 rkujawa Exp $
#
##
# GENERIC machine description file
@@ -52,7 +52,7 @@ include "arch/amiga/conf/std.amiga"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.99 $"
+#ident "GENERIC-$Revision: 1.100 $"
m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl
makeoptions COPTS="-Os"
@@ -577,6 +577,10 @@ pci* at p5pb0
mppb* at zbus0 # Matay Prometheus Zorro-PCI bridge
pci* at mppb?
+empb0 at zbus0 # ELBOX Mediator PCI 1200
+emmem0 at zbus0 # ELBOX Mediator PCI memory space
+pci* at empb0
+
#cv3dpb* at zbus0 # CyberVision 64/3D PCI bridge
#genfb* at pci? # generic fb, CVPPC/BVPPC only
Index: src/sys/arch/amiga/conf/files.amiga
diff -u src/sys/arch/amiga/conf/files.amiga:1.156 src/sys/arch/amiga/conf/files.amiga:1.157
--- src/sys/arch/amiga/conf/files.amiga:1.156 Tue May 15 17:35:44 2012
+++ src/sys/arch/amiga/conf/files.amiga Wed May 30 18:01:51 2012
@@ -1,4 +1,4 @@
-# $NetBSD: files.amiga,v 1.156 2012/05/15 17:35:44 rkujawa Exp $
+# $NetBSD: files.amiga,v 1.157 2012/05/30 18:01:51 rkujawa Exp $
# maxpartitions must be first item in files.${ARCH}.newconf
maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL!
@@ -522,6 +522,7 @@ file arch/amiga/dev/bppcsc.c bppcsc nee
# PCI bus
file arch/amiga/pci/p5pb.c pci
file arch/amiga/pci/mppb.c pci
+file arch/amiga/pci/empb.c pci
file arch/amiga/pci/cv3dpb.c pci
file arch/amiga/pci/pci_machdep.c pci
@@ -534,6 +535,13 @@ attach mppb at zbus
device cv3dpb: pcibus
attach cv3dpb at zbus
+device empb: pcibus
+attach empb at zbus
+
+device emmem {}
+attach emmem at zbus
+file arch/amiga/pci/emmem.c emmem
+
include "dev/i2o/files.i2o"
include "dev/pci/files.pci"
Added files:
Index: src/sys/arch/amiga/pci/emmem.c
diff -u /dev/null src/sys/arch/amiga/pci/emmem.c:1.1
--- /dev/null Wed May 30 18:01:52 2012
+++ src/sys/arch/amiga/pci/emmem.c Wed May 30 18:01:51 2012
@@ -0,0 +1,105 @@
+/* $NetBSD: emmem.c,v 1.1 2012/05/30 18:01:51 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Handle (optional) PCI memory space on Elbox Mediator bridges.
+ */
+
+#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 <sys/malloc.h>
+#include <sys/extent.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+
+//#include <m68k/bus_dma.h>
+#include <amiga/dev/zbusvar.h>
+#include <amiga/pci/empbreg.h>
+#include <amiga/pci/emmemvar.h>
+
+static int emmem_match(struct device *, struct cfdata *, void *);
+static void emmem_attach(struct device *, struct device *, void *);
+
+CFATTACH_DECL_NEW(emmem, sizeof(struct emmem_softc),
+ emmem_match, emmem_attach, NULL, NULL);
+
+static int
+emmem_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct zbus_args *zap;
+
+ zap = aux;
+
+ if (zap->manid != ZORRO_MANID_ELBOX)
+ return 0;
+
+ switch (zap->prodid) {
+ case ZORRO_PRODID_MED1K2_MEM:
+ case ZORRO_PRODID_MED1K2SX_MEM:
+ case ZORRO_PRODID_MED1K2LT2_MEM:
+ case ZORRO_PRODID_MED1K2LT4_MEM:
+ case ZORRO_PRODID_MED1K2TX_MEM:
+ return 1;
+ }
+
+ return 0;
+}
+
+static void
+emmem_attach(device_t parent, device_t self, void *aux)
+{
+ struct zbus_args *zap;
+ struct emmem_softc *sc;
+
+ sc = device_private(self);
+ zap = aux;
+
+ sc->sc_dev = self;
+ sc->sc_base = zap->pa;
+ sc->sc_size = zap->size;
+
+ aprint_normal(": ELBOX Mediator PCI memory window, %d kB\n",
+ zap->size / 1024);
+
+ /*
+ * Do nothing here, empb should find the emmem devices
+ * and do the right(tm) thing.
+ */
+
+}
+
Index: src/sys/arch/amiga/pci/emmemvar.h
diff -u /dev/null src/sys/arch/amiga/pci/emmemvar.h:1.1
--- /dev/null Wed May 30 18:01:52 2012
+++ src/sys/arch/amiga/pci/emmemvar.h Wed May 30 18:01:51 2012
@@ -0,0 +1,41 @@
+/* $NetBSD: emmemvar.h,v 1.1 2012/05/30 18:01:51 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * 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.
+ *
+ * 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/device.h>
+
+struct emmem_softc {
+ device_t sc_dev;
+
+ volatile char *sc_base; /* base PA */
+ uint32_t sc_size;
+};
+
Index: src/sys/arch/amiga/pci/empb.c
diff -u /dev/null src/sys/arch/amiga/pci/empb.c:1.1
--- /dev/null Wed May 30 18:01:52 2012
+++ src/sys/arch/amiga/pci/empb.c Wed May 30 18:01:51 2012
@@ -0,0 +1,369 @@
+/* $NetBSD: empb.c,v 1.1 2012/05/30 18:01:51 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/* Elbox Mediator PCI bridge driver. Currently supports Mediator 1200 models.*/
+
+#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 <sys/malloc.h>
+#include <sys/extent.h>
+#include <sys/kmem.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+
+#include <m68k/bus_dma.h>
+#include <amiga/dev/zbusvar.h>
+#include <amiga/pci/empbreg.h>
+#include <amiga/pci/emmemvar.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+#include <dev/pci/pciconf.h>
+
+#include "opt_pci.h"
+
+/* #define EMPB_DEBUG 1 */
+
+#define PCI_CONF_LOCK(s) (s) = splhigh()
+#define PCI_CONF_UNLOCK(s) splx((s))
+
+struct empb_softc {
+ device_t sc_dev;
+
+ struct bus_space_tag setup_area;
+ bus_space_tag_t setup_area_t;
+ bus_space_handle_t setup_area_h;
+
+ struct bus_space_tag pci_confio_area;
+ bus_space_tag_t pci_confio_t;
+ bus_space_handle_t pci_confio_h;
+ uint8_t pci_confio_mode;
+
+ struct bus_space_tag pci_mem_window;
+ uint32_t pci_mem_window_size;
+
+ struct amiga_pci_chipset apc;
+
+};
+
+static int empb_match(struct device *, struct cfdata *, void *);
+static void empb_attach(struct device *, struct device *, void *);
+static void empb_callback(device_t self);
+
+/*static bool empb_find_mem(struct empb_softc *sc);*/
+void empb_switch_bridge(struct empb_softc *sc, uint8_t mode);
+
+pcireg_t empb_pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
+void empb_pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
+int empb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno);
+void empb_pci_attach_hook(struct device *parent,
+ struct device *self, struct pcibus_attach_args *pba);
+pcitag_t empb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device,
+ int function);
+void empb_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag,
+ int *bp, int *dp, int *fp);
+int empb_pci_intr_map(const struct pci_attach_args *pa,
+ pci_intr_handle_t *ihp);
+const struct evcnt * empb_pci_intr_evcnt(pci_chipset_tag_t pc,
+ pci_intr_handle_t ih);
+
+CFATTACH_DECL_NEW(empb, sizeof(struct empb_softc),
+ empb_match, empb_attach, NULL, NULL);
+
+static int
+empb_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct zbus_args *zap;
+
+ zap = aux;
+
+ if (zap->manid != ZORRO_MANID_ELBOX)
+ return 0;
+
+ switch (zap->prodid) {
+ case ZORRO_PRODID_MED1K2:
+ case ZORRO_PRODID_MED1K2SX:
+ case ZORRO_PRODID_MED1K2LT2:
+ case ZORRO_PRODID_MED1K2LT4:
+ case ZORRO_PRODID_MED1K2TX:
+ return 1;
+ }
+
+ return 0;
+}
+
+
+static void
+empb_attach(device_t parent, device_t self, void *aux)
+{
+ struct empb_softc *sc;
+ struct zbus_args *zap;
+
+ volatile char *ba;
+
+ zap = aux;
+ sc = device_private(self);
+ sc->sc_dev = self;
+ ba = zap->va;
+
+ switch (zap->prodid) {
+ case ZORRO_PRODID_MED1K2:
+ aprint_normal(": ELBOX Mediator PCI 1200\n");
+ break;
+ case ZORRO_PRODID_MED1K2SX:
+ aprint_normal(": ELBOX Mediator PCI 1200 SX\n");
+ break;
+ case ZORRO_PRODID_MED1K2LT2:
+ aprint_normal(": ELBOX Mediator PCI 1200 LT2\n");
+ break;
+ case ZORRO_PRODID_MED1K2LT4:
+ aprint_normal(": ELBOX Mediator PCI 1200 LT4\n");
+ break;
+ case ZORRO_PRODID_MED1K2TX:
+ aprint_normal(": ELBOX Mediator PCI 1200 TX\n");
+ break;
+ default:
+ aprint_normal(": ELBOX Mediator PCI (unknown)\n");
+ break;
+ }
+
+ /* Setup bus space mappings. */
+ sc->pci_confio_area.base = (bus_addr_t) ba + EMPB_BRIDGE_OFF;
+ sc->pci_confio_area.absm = &amiga_bus_stride_1swap;
+
+ sc->setup_area.base = (bus_addr_t) ba + EMPB_SETUP_OFF;
+ sc->setup_area.absm = &amiga_bus_stride_1;
+
+ /*
+ * Defer everything until later, we need to wait for possible
+ * emmem attachments.
+ */
+
+ config_defer(self, empb_callback);
+}
+
+static void
+empb_callback(device_t self) {
+
+ struct empb_softc *sc;
+ pci_chipset_tag_t pc;
+ struct pcibus_attach_args pba;
+
+ sc = device_private(self);
+ pc = &sc->apc;
+
+#ifdef EMPB_DEBUG
+ aprint_normal("empb: mapped setup %x->%x, conf/io %x->%x\n",
+ kvtop((void*) sc->setup_area.base), sc->setup_area.base,
+ kvtop((void*) sc->pci_confio_area.base), sc->pci_confio_area.base);
+#endif
+
+ sc->pci_confio_t = &(sc->pci_confio_area);
+
+ if (bus_space_map(sc->pci_confio_t, 0, EMPB_BRIDGE_SIZE, 0,
+ &sc->pci_confio_h))
+ aprint_error_dev(self,
+ "couldn't map PCI configuration & I/O space\n");
+
+ sc->apc.pci_conf_datat = sc->pci_confio_t;
+ sc->apc.pci_conf_datah = sc->pci_confio_h;
+
+ sc->setup_area_t = &(sc->setup_area);
+
+ if (bus_space_map(sc->setup_area_t, 0, EMPB_SETUP_SIZE, 0,
+ &sc->setup_area_h))
+ aprint_error_dev(self,
+ "couldn't map Mediator setup space\n");
+
+ /* Initialize the PCI chipset tag. */
+ sc->apc.pc_conf_v = (void*) pc;
+ sc->apc.pc_bus_maxdevs = empb_pci_bus_maxdevs;
+ sc->apc.pc_make_tag = amiga_pci_make_tag;
+ sc->apc.pc_decompose_tag = amiga_pci_decompose_tag;
+ sc->apc.pc_conf_read = empb_pci_conf_read;
+ sc->apc.pc_conf_write = empb_pci_conf_write;
+ sc->apc.pc_attach_hook = empb_pci_attach_hook;
+
+ sc->apc.pc_intr_map = empb_pci_intr_map;
+ sc->apc.pc_intr_string = amiga_pci_intr_string;
+ sc->apc.pc_intr_establish = amiga_pci_intr_establish;
+ sc->apc.pc_intr_disestablish = amiga_pci_intr_disestablish;
+
+ sc->apc.pc_conf_hook = amiga_pci_conf_hook;
+ sc->apc.pc_conf_interrupt = amiga_pci_conf_interrupt;
+
+ sc->apc.cookie = sc;
+
+ pba.pba_iot = &(sc->pci_confio_area);
+ pba.pba_dmat = NULL;
+ pba.pba_dmat64 = NULL;
+ pba.pba_pc = pc;
+ pba.pba_flags = PCI_FLAGS_IO_OKAY;
+
+ /*if(sc->pci_mem_window_size > 0) {
+ pba.pba_memt = &(sc->pci_mem_window);
+ pba.pba_flags |= PCI_FLAGS_MEM_OKAY;
+ } else */
+ pba.pba_memt = NULL;
+
+ pba.pba_bus = 0;
+ pba.pba_bridgetag = NULL;
+
+ config_found_ia(self, "pcibus", &pba, pcibusprint);
+}
+
+/*
+ * Switch between configuration space and I/O space.
+ */
+void
+empb_switch_bridge(struct empb_softc *sc, uint8_t mode)
+{
+ bus_space_write_1(sc->setup_area_t, sc->setup_area_h,
+ EMPB_SETUP_BRIDGE_OFF, mode);
+}
+
+
+/*
+ * Try to find a (optional) memory window board.
+ */
+/*bool
+empb_find_mem(struct empb_softc *sc)
+{
+ device_t memdev;
+ struct emmem_softc *mem_sc;
+
+ memdev = device_find_by_xname("emmem0");
+
+ if(memdev == NULL)
+ return false;
+
+ mem_sc = device_private(memdev);
+
+ sc->pci_mem_window.base = (bus_addr_t) mem_sc->sc_base;
+ sc->pci_mem_window.absm = &amiga_bus_stride_1;
+
+ sc->pci_mem_window_size = mem_sc->sc_size;
+}*/
+
+pcireg_t
+empb_pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
+{
+ uint32_t data;
+ uint32_t bus, dev, func;
+ struct empb_softc *sc;
+ int s;
+
+ sc = pc->cookie;
+
+ pci_decompose_tag(pc, tag, &bus, &dev, &func);
+
+ PCI_CONF_LOCK(s);
+
+ empb_switch_bridge(sc, BRIDGE_CONF);
+
+ data = bus_space_read_4(pc->pci_conf_datat, pc->pci_conf_datah,
+ EMPB_CONF_DEV_STRIDE*dev + EMPB_CONF_FUNC_STRIDE*func + reg);
+#ifdef EMPB_DEBUG_CONF
+ aprint_normal("empb conf read va: %lx, bus: %d, dev: %d, "
+ "func: %d, reg: %d -r-> data %x\n",
+ pc->pci_conf_datah, bus, dev, func, reg, data);
+#endif /* EMPB_DEBUG_CONF */
+
+ empb_switch_bridge(sc, BRIDGE_IO);
+
+ PCI_CONF_UNLOCK(s);
+
+ return data;
+}
+
+void
+empb_pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t val)
+{
+ uint32_t bus, dev, func;
+ struct empb_softc *sc;
+ int s;
+
+ sc = pc->cookie;
+
+ pci_decompose_tag(pc, tag, &bus, &dev, &func);
+
+ PCI_CONF_LOCK(s);
+
+ empb_switch_bridge(sc, BRIDGE_CONF);
+
+ bus_space_write_4(pc->pci_conf_datat, pc->pci_conf_datah,
+ EMPB_CONF_DEV_STRIDE*dev + EMPB_CONF_FUNC_STRIDE*func + reg, val);
+#ifdef EMPB_DEBUG_CONF
+ aprint_normal("empb conf write va: %lx, bus: %d, dev: %d, "
+ "func: %d, reg: %d -w-> data %x\n",
+ pc->pci_conf_datah, bus, dev, func, reg, val);
+#endif /* EMPB_DEBUG_CONF */
+ empb_switch_bridge(sc, BRIDGE_IO);
+
+ PCI_CONF_UNLOCK(s);
+}
+
+int
+empb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
+{
+ return 6; /* no Mediator with more than 6 slots? */
+}
+
+void
+empb_pci_attach_hook(struct device *parent, struct device *self,
+ struct pcibus_attach_args *pba)
+{
+}
+
+int
+empb_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
+{
+ /* TODO: add sanity checking */
+
+ *ihp = EMPB_INT;
+ return 0;
+}
+
+const struct evcnt *
+empb_pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih)
+{
+ /* TODO: implement */
+ return NULL;
+}
+
Index: src/sys/arch/amiga/pci/empbreg.h
diff -u /dev/null src/sys/arch/amiga/pci/empbreg.h:1.1
--- /dev/null Wed May 30 18:01:52 2012
+++ src/sys/arch/amiga/pci/empbreg.h Wed May 30 18:01:51 2012
@@ -0,0 +1,84 @@
+/* $NetBSD: empbreg.h,v 1.1 2012/05/30 18:01:51 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Elbox Mediator registers. This information was obtained using reverse
+ * engineering methods by Frank Wille and Radoslaw Kujawa (without access to
+ * official documentation).
+ */
+
+#ifndef _AMIGA_EMPBREG_H_
+
+/* Zorro IDs */
+#define ZORRO_MANID_ELBOX 2206
+#define ZORRO_PRODID_MEDZIV 31
+#define ZORRO_PRODID_MED1K2 32
+#define ZORRO_PRODID_MED4K 33
+#define ZORRO_PRODID_MED1K2SX 40
+#define ZORRO_PRODID_MED1K2LT2 48
+#define ZORRO_PRODID_MED1K2LT4 49
+#define ZORRO_PRODID_MED1K2TX 60
+#define ZORRO_PRODID_MED4KMKII 63
+
+#define ZORRO_PRODID_MEDZIV_MEM ZORRO_PRODID_MEDZIV+0x80
+#define ZORRO_PRODID_MED1K2_MEM ZORRO_PRODID_MED1K2+0x80
+#define ZORRO_PRODID_MED4K_MEM ZORRO_PRODID_MED4K+0x80
+#define ZORRO_PRODID_MED1K2SX_MEM ZORRO_PRODID_MED1K2SX+0x80
+#define ZORRO_PRODID_MED1K2LT2_MEM ZORRO_PRODID_MED1K2LT2+0x80
+#define ZORRO_PRODID_MED1K2LT4_MEM ZORRO_PRODID_MED1K2LT4+0x80
+#define ZORRO_PRODID_MED1K2TX_MEM ZORRO_PRODID_MED1K2TX+0x80
+#define ZORRO_PRODID_MED4KMKII_MEM ZORRO_PRODID_MED4KMKII+0x80
+
+/*
+ * Mediator 1200 consists of two boards. First board lives in Z2 I/O
+ * space and is internally divided into two 64kB spaces. Second board, used
+ * as a window into PCI memory space is configured somewhere within 24-bit Fast
+ * RAM space (its size depends on a WINDOW jumper setting).
+ */
+#define EMPB_SETUP_OFF 0x00000000
+#define EMPB_SETUP_SIZE 0xFFFF
+
+#define EMPB_SETUP_WINDOW_OFF 0x2 /* set memory window position */
+#define EMPB_SETUP_BRIDGE_OFF 0x7 /* select between conf or I/O */
+
+#define BRIDGE_CONF 0xA0 /* switch into configuration space */
+#define BRIDGE_IO 0x20 /* switch into I/O space */
+
+#define EMPB_BRIDGE_OFF 0x00010000
+#define EMPB_BRIDGE_SIZE 0xFFFF
+
+#define EMPB_CONF_DEV_STRIDE 0x800 /* offset between PCI devices */
+#define EMPB_CONF_FUNC_STRIDE 0x100 /* XXX: offset between PCI funcs */
+
+/* All PCI interrupt lines are wired to INT2? */
+#define EMPB_INT 2 // XXX: wild guess
+
+#endif /* _AMIGA_EMPBREG_H_ */