Module Name: src
Committed By: rkujawa
Date: Mon Sep 19 19:15:29 UTC 2011
Modified Files:
src/sys/arch/amiga/conf: DRACO GENERIC GENERIC.in INSTALL files.amiga
src/sys/arch/amiga/include: pci_machdep.h
src/sys/arch/amiga/pci: mppb.c p5pb.c p5pbreg.h
Added Files:
src/sys/arch/amiga/pci: pci_machdep.c
Log Message:
Minor changes to Amiga PCI MD code:
- Add bus enumeration and resource assignment (PCI_NETBSD_CONFIGURE) to mppb(4)
- no more need to run AmigaOS to configure the bus.
- Add PCI configuration address register to p5pb(4).
- Add PCI I/O space support to p5pb(4).
- Move common code from p5pb(4) and mppb(4) to new pci_machdep.c file.
- Fix style.
To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/arch/amiga/conf/DRACO
cvs rdiff -u -r1.271 -r1.272 src/sys/arch/amiga/conf/GENERIC
cvs rdiff -u -r1.83 -r1.84 src/sys/arch/amiga/conf/GENERIC.in
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/amiga/conf/INSTALL
cvs rdiff -u -r1.147 -r1.148 src/sys/arch/amiga/conf/files.amiga
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/include/pci_machdep.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amiga/pci/mppb.c \
src/sys/arch/amiga/pci/p5pb.c src/sys/arch/amiga/pci/p5pbreg.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/amiga/pci/pci_machdep.c
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/DRACO
diff -u src/sys/arch/amiga/conf/DRACO:1.141 src/sys/arch/amiga/conf/DRACO:1.142
--- src/sys/arch/amiga/conf/DRACO:1.141 Sat Sep 17 16:55:34 2011
+++ src/sys/arch/amiga/conf/DRACO Mon Sep 19 19:15:28 2011
@@ -1,9 +1,9 @@
-# $NetBSD: DRACO,v 1.141 2011/09/17 16:55:34 rkujawa Exp $
+# $NetBSD: DRACO,v 1.142 2011/09/19 19:15:28 rkujawa Exp $
#
# This file was automatically created.
# Changes will be lost when make is run in this directory.
#
-# Created from: # NetBSD: GENERIC.in,v 1.82 2011/08/04 17:48:51 rkujawa Exp $
+# Created from: # NetBSD: GENERIC.in,v 1.83 2011/09/17 16:55:34 rkujawa Exp $
#
##
# GENERIC machine description file
@@ -29,7 +29,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.141 $"
+#ident "GENERIC-$Revision: 1.142 $"
maxusers 8
Index: src/sys/arch/amiga/conf/GENERIC
diff -u src/sys/arch/amiga/conf/GENERIC:1.271 src/sys/arch/amiga/conf/GENERIC:1.272
--- src/sys/arch/amiga/conf/GENERIC:1.271 Sat Sep 17 16:55:34 2011
+++ src/sys/arch/amiga/conf/GENERIC Mon Sep 19 19:15:28 2011
@@ -1,9 +1,9 @@
-# $NetBSD: GENERIC,v 1.271 2011/09/17 16:55:34 rkujawa Exp $
+# $NetBSD: GENERIC,v 1.272 2011/09/19 19:15:28 rkujawa Exp $
#
# This file was automatically created.
# Changes will be lost when make is run in this directory.
#
-# Created from: # NetBSD: GENERIC.in,v 1.82 2011/08/04 17:48:51 rkujawa Exp $
+# Created from: # NetBSD: GENERIC.in,v 1.83 2011/09/17 16:55:34 rkujawa Exp $
#
##
# GENERIC machine description file
@@ -29,7 +29,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.271 $"
+#ident "GENERIC-$Revision: 1.272 $"
maxusers 8
@@ -466,6 +466,8 @@
# PCI bus support
options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
+options PCI_NETBSD_CONFIGURE
+
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
mppb* at zbus0 # Matay Prometheus Zorro-PCI bridge
Index: src/sys/arch/amiga/conf/GENERIC.in
diff -u src/sys/arch/amiga/conf/GENERIC.in:1.83 src/sys/arch/amiga/conf/GENERIC.in:1.84
--- src/sys/arch/amiga/conf/GENERIC.in:1.83 Sat Sep 17 16:55:34 2011
+++ src/sys/arch/amiga/conf/GENERIC.in Mon Sep 19 19:15:29 2011
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.in,v 1.83 2011/09/17 16:55:34 rkujawa Exp $
+# $NetBSD: GENERIC.in,v 1.84 2011/09/19 19:15:29 rkujawa Exp $
#
##
# GENERIC machine description file
@@ -57,7 +57,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.83 $"
+#ident "GENERIC-$Revision: 1.84 $"
m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl
makeoptions COPTS="-Os"
@@ -573,6 +573,8 @@
# PCI bus support
options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
+options PCI_NETBSD_CONFIGURE
+
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
mppb* at zbus0 # Matay Prometheus Zorro-PCI bridge
Index: src/sys/arch/amiga/conf/INSTALL
diff -u src/sys/arch/amiga/conf/INSTALL:1.93 src/sys/arch/amiga/conf/INSTALL:1.94
--- src/sys/arch/amiga/conf/INSTALL:1.93 Sat Sep 17 16:55:34 2011
+++ src/sys/arch/amiga/conf/INSTALL Mon Sep 19 19:15:29 2011
@@ -1,9 +1,9 @@
-# $NetBSD: INSTALL,v 1.93 2011/09/17 16:55:34 rkujawa Exp $
+# $NetBSD: INSTALL,v 1.94 2011/09/19 19:15:29 rkujawa Exp $
#
# This file was automatically created.
# Changes will be lost when make is run in this directory.
#
-# Created from: # NetBSD: GENERIC.in,v 1.82 2011/08/04 17:48:51 rkujawa Exp $
+# Created from: # NetBSD: GENERIC.in,v 1.83 2011/09/17 16:55:34 rkujawa Exp $
#
##
# GENERIC machine description file
@@ -29,7 +29,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.93 $"
+#ident "GENERIC-$Revision: 1.94 $"
makeoptions COPTS="-Os"
@@ -410,6 +410,8 @@
# PCI bus support
options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
+options PCI_NETBSD_CONFIGURE
+
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
mppb* at zbus0 # Matay Prometheus Zorro-PCI bridge
Index: src/sys/arch/amiga/conf/files.amiga
diff -u src/sys/arch/amiga/conf/files.amiga:1.147 src/sys/arch/amiga/conf/files.amiga:1.148
--- src/sys/arch/amiga/conf/files.amiga:1.147 Sat Sep 17 16:55:34 2011
+++ src/sys/arch/amiga/conf/files.amiga Mon Sep 19 19:15:29 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.amiga,v 1.147 2011/09/17 16:55:34 rkujawa Exp $
+# $NetBSD: files.amiga,v 1.148 2011/09/19 19:15:29 rkujawa Exp $
# maxpartitions must be first item in files.${ARCH}.newconf
maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL!
@@ -496,6 +496,7 @@
# PCI bus
file arch/amiga/pci/p5pb.c pci
file arch/amiga/pci/mppb.c pci
+file arch/amiga/pci/pci_machdep.c pci
device p5pb: pcibus
attach p5pb at zbus
Index: src/sys/arch/amiga/include/pci_machdep.h
diff -u src/sys/arch/amiga/include/pci_machdep.h:1.2 src/sys/arch/amiga/include/pci_machdep.h:1.3
--- src/sys/arch/amiga/include/pci_machdep.h:1.2 Sat Sep 17 16:55:34 2011
+++ src/sys/arch/amiga/include/pci_machdep.h Mon Sep 19 19:15:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.2 2011/09/17 16:55:34 rkujawa Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.3 2011/09/19 19:15:29 rkujawa Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -79,8 +79,13 @@
void (*pc_conf_interrupt)(pci_chipset_tag_t, int, int, int,
int, int *);
- bus_space_tag_t pci_conf_iot;
- bus_space_handle_t pci_conf_ioh;
+ /* PCI configuration address register */
+ bus_space_tag_t pci_conf_addresst;
+ bus_space_handle_t pci_conf_addressh;
+
+ /* PCI configuration data register */
+ bus_space_tag_t pci_conf_datat;
+ bus_space_handle_t pci_conf_datah;
};
@@ -109,5 +114,24 @@
(*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
#define pci_intr_disestablish(c, iv) \
(*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
+#define pci_conf_interrupt(c, b, d, f, s, i) \
+ (*(c)->pc_conf_interrupt)((c), (b), (d), (f), (s), (i))
+#define pci_conf_hook(c, b, d, f, i) \
+ (*(c)->pc_conf_hook)((c), (b), (d), (f), (i))
#endif
+
+pcitag_t amiga_pci_make_tag(pci_chipset_tag_t pc, int bus, int device,
+ int function);
+void amiga_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag,
+ int *bp, int *dp, int *fp);
+void * amiga_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t
+ ih, int level, int (*ih_fun)(void *), void *ih_arg);
+void amiga_pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie);
+const char * amiga_pci_intr_string(pci_chipset_tag_t pc,
+ pci_intr_handle_t ih);
+int amiga_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev,
+ int func, pcireg_t id);
+void amiga_pci_conf_interrupt(pci_chipset_tag_t pc, int bus,
+ int dev, int func, int swiz, int *iline);
+
Index: src/sys/arch/amiga/pci/mppb.c
diff -u src/sys/arch/amiga/pci/mppb.c:1.1 src/sys/arch/amiga/pci/mppb.c:1.2
--- src/sys/arch/amiga/pci/mppb.c:1.1 Sat Sep 17 16:55:34 2011
+++ src/sys/arch/amiga/pci/mppb.c Mon Sep 19 19:15:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: mppb.c,v 1.1 2011/09/17 16:55:34 rkujawa Exp $ */
+/* $NetBSD: mppb.c,v 1.2 2011/09/19 19:15:29 rkujawa Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -73,22 +73,14 @@
pcireg_t mppb_pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
void mppb_pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
int mppb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno);
-int mppb_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev,
- int func, pcireg_t id);
void mppb_pci_attach_hook (struct device *parent,
struct device *self, struct pcibus_attach_args *pba);
pcitag_t mppb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device,
int function);
void mppb_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag,
int *bp, int *dp, int *fp);
-
-void * mppb_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t
- ih, int level, int (*ih_fun)(void *), void *ih_arg);
-void mppb_pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie);
int mppb_pci_intr_map(const struct pci_attach_args *pa,
pci_intr_handle_t *ihp);
-const char * mppb_pci_intr_string(pci_chipset_tag_t pc,
- pci_intr_handle_t ih);
const struct evcnt * mppb_pci_intr_evcnt(pci_chipset_tag_t pc,
pci_intr_handle_t ih);
@@ -124,6 +116,7 @@
struct pcibus_attach_args pba;
struct zbus_args *zap;
pci_chipset_tag_t pc;
+ struct extent *ioext, *memext;
zap = aux;
sc = device_private(self);
@@ -150,28 +143,40 @@
(zap->pa) + MPPB_IO_BASE, sc->pci_io_area.base);
#endif
- sc->apc.pci_conf_iot = &(sc->pci_conf_area);
+ sc->apc.pci_conf_datat = &(sc->pci_conf_area);
- if (bus_space_map(sc->apc.pci_conf_iot, 0, MPPB_CONF_SIZE, 0,
- &sc->apc.pci_conf_ioh))
+ if (bus_space_map(sc->apc.pci_conf_datat, 0, MPPB_CONF_SIZE, 0,
+ &sc->apc.pci_conf_datah))
aprint_error_dev(self,
"couldn't map PCI configuration data space\n");
/* Initialize the PCI chipset tag. */
sc->apc.pc_conf_v = (void*) pc;
sc->apc.pc_bus_maxdevs = mppb_pci_bus_maxdevs;
- sc->apc.pc_make_tag = mppb_pci_make_tag;
- sc->apc.pc_decompose_tag = mppb_pci_decompose_tag;
+ sc->apc.pc_make_tag = amiga_pci_make_tag;
+ sc->apc.pc_decompose_tag = amiga_pci_decompose_tag;
sc->apc.pc_conf_read = mppb_pci_conf_read;
sc->apc.pc_conf_write = mppb_pci_conf_write;
sc->apc.pc_attach_hook = mppb_pci_attach_hook;
sc->apc.pc_intr_map = mppb_pci_intr_map;
- sc->apc.pc_intr_string = mppb_pci_intr_string;
- sc->apc.pc_intr_establish = mppb_pci_intr_establish;
- sc->apc.pc_intr_disestablish = mppb_pci_intr_disestablish;
- /* XXX: pc_conf_interrupt */
-
+ 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;
+
+ ioext = extent_create("mppbio", MPPB_IO_BASE,
+ MPPB_IO_BASE + MPPB_IO_SIZE, M_DEVBUF, NULL, 0, EX_NOWAIT);
+ memext = extent_create("mppbmem", MPPB_MEM_BASE,
+ MPPB_MEM_BASE + MPPB_MEM_SIZE, M_DEVBUF, NULL, 0, EX_NOWAIT);
+
+ pci_configure_bus(pc, ioext, memext, NULL, 0, CACHELINE_SIZE);
+
+ extent_destroy(ioext);
+ extent_destroy(memext);
+
pba.pba_iot = &(sc->pci_io_area);
pba.pba_memt = &(sc->pci_mem_area);
pba.pba_dmat = NULL;
@@ -192,12 +197,12 @@
pci_decompose_tag(pc, tag, &bus, &dev, &func);
- data = bus_space_read_4(pc->pci_conf_iot, pc->pci_conf_ioh,
+ data = bus_space_read_4(pc->pci_conf_datat, pc->pci_conf_datah,
(MPPB_CONF_STRIDE*dev) + reg);
#ifdef MPPB_DEBUG
aprint_normal("mppb conf read va: %lx, bus: %d, dev: %d, "
"func: %d, reg: %d -r-> data %x\n",
- pc->pci_conf_ioh, bus, dev, func, reg, data);
+ pc->pci_conf_datah, bus, dev, func, reg, data);
#endif
return data;
}
@@ -209,12 +214,12 @@
pci_decompose_tag(pc, tag, &bus, &dev, &func);
- bus_space_write_4(pc->pci_conf_iot, pc->pci_conf_ioh,
+ bus_space_write_4(pc->pci_conf_datat, pc->pci_conf_datah,
(MPPB_CONF_STRIDE*dev) + reg, val);
#ifdef MPPB_DEBUG
aprint_normal("mppb conf write va: %lx, bus: %d, dev: %d, "
"func: %d, reg: %d -w-> data %x\n",
- pc->pci_conf_ioh, bus, dev, func, reg, val);
+ pc->pci_conf_datah, bus, dev, func, reg, val);
#endif
}
@@ -225,53 +230,12 @@
return 4; /* Prometheus has 4 slots */
}
-pcitag_t
-mppb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
-{
- return (bus << 16) | (device << 11) | (function << 8);
-}
-
-void
-mppb_pci_decompose_tag(pci_chipset_tag_t pc, 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) & 0x07;
-}
-
void
mppb_pci_attach_hook(struct device *parent, struct device *self,
struct pcibus_attach_args *pba)
{
}
-void *
-mppb_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
- int (*ih_fun)(void *), void *ih_arg)
-{
- struct isr* pci_isr;
- pci_isr = kmem_zalloc(sizeof(struct isr), KM_SLEEP);
-
- /* TODO: check for bogus handle */
-
- pci_isr->isr_intr = ih_fun;
- pci_isr->isr_arg = ih_arg;
- pci_isr->isr_ipl = MPPB_INT;
- add_isr(pci_isr);
- return pci_isr;
-}
-
-void
-mppb_pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
-{
- remove_isr(cookie);
- kmem_free(cookie, sizeof(struct isr));
-}
-
int
mppb_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{
@@ -281,15 +245,6 @@
return 0;
}
-const char *
-mppb_pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih)
-{
- static char str[10];
-
- sprintf(str, "INT%d", (int) ih);
- return str;
-}
-
const struct evcnt *
mppb_pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih)
{
Index: src/sys/arch/amiga/pci/p5pb.c
diff -u src/sys/arch/amiga/pci/p5pb.c:1.1 src/sys/arch/amiga/pci/p5pb.c:1.2
--- src/sys/arch/amiga/pci/p5pb.c:1.1 Thu Aug 4 17:48:51 2011
+++ src/sys/arch/amiga/pci/p5pb.c Mon Sep 19 19:15:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: p5pb.c,v 1.1 2011/08/04 17:48:51 rkujawa Exp $ */
+/* $NetBSD: p5pb.c,v 1.2 2011/09/19 19:15:29 rkujawa Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -67,6 +67,7 @@
device_t sc_dev;
struct bus_space_tag pci_conf_area;
struct bus_space_tag pci_mem_area;
+ struct bus_space_tag pci_io_area;
struct amiga_pci_chipset apc;
};
@@ -76,15 +77,20 @@
pcireg_t p5pb_pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
void p5pb_pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
int p5pb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno);
-int p5pb_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev, int func, pcireg_t id);
-void p5pb_pci_attach_hook (struct device *parent, struct device *self, struct pcibus_attach_args *pba);
-pcitag_t p5pb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function);
-void p5pb_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp, int *dp, int *fp);
+int p5pb_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev,
+ int func, pcireg_t id);
+void p5pb_pci_attach_hook (struct device *parent,
+ struct device *self, struct pcibus_attach_args *pba);
+pcitag_t p5pb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device,
+ int function);
+void p5pb_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag,
+ int *bp, int *dp, int *fp);
+int p5pb_pci_intr_map(const struct pci_attach_args *pa,
+ pci_intr_handle_t *ihp);
CFATTACH_DECL_NEW(p5pb, sizeof(struct p5pb_softc),
p5pb_match, p5pb_attach, NULL, NULL);
-
static int p5pb_present = 0;
static int
@@ -142,38 +148,54 @@
(void *) P5BUS_PCI_CONF_BASE, P5BUS_PCI_CONF_SIZE);
sc->pci_conf_area.absm = &amiga_bus_stride_1;
+ sc->pci_io_area.base = (bus_addr_t) zbusmap(
+ (void *) P5BUS_PCI_IO_BASE, P5BUS_PCI_IO_SIZE);
+ sc->pci_io_area.absm = &amiga_bus_stride_1swap_abs;
+
sc->pci_mem_area.base = (bus_addr_t) zbusmap(
(void *) P5BUS_PCI_MEM_BASE, P5BUS_PCI_MEM_SIZE);
sc->pci_mem_area.absm = &amiga_bus_stride_1swap_abs;
#ifdef P5PB_DEBUG
- aprint_normal("p5pb mapped %x -> %x, %x -> %x\n",
+ aprint_normal("p5pb mapped %x -> %x, %x -> %x\n, %x -> %x\n",
P5BUS_PCI_CONF_BASE, sc->pci_conf_area.base,
+ P5BUS_PCI_IO_BASE, sc->pci_conf_area.base,
P5BUS_PCI_MEM_BASE, sc->pci_mem_area.base );
#endif
- sc->apc.pci_conf_iot = &(sc->pci_conf_area);
+ sc->apc.pci_conf_datat = &(sc->pci_conf_area);
+ sc->apc.pci_conf_addresst = &(sc->pci_conf_area);
- if (bus_space_map(sc->apc.pci_conf_iot, OFF_PCI_CONF_DATA,
- 256, 0, &sc->apc.pci_conf_ioh))
+ if (bus_space_map(sc->apc.pci_conf_addresst, OFF_PCI_CONF_ADDR,
+ 256, 0, &sc->apc.pci_conf_addressh))
aprint_error_dev(self,
- "couldn't map PCI configuration data space\n");
-
+ "couldn't map PCI configuration address register\n");
+
+ if (bus_space_map(sc->apc.pci_conf_datat, OFF_PCI_CONF_DATA,
+ 256, 0, &sc->apc.pci_conf_datah))
+ aprint_error_dev(self,
+ "couldn't map PCI configuration data register\n");
+
/* Initialize the PCI chipset tag. */
sc->apc.pc_conf_v = (void*) pc;
sc->apc.pc_bus_maxdevs = p5pb_pci_bus_maxdevs;
- sc->apc.pc_make_tag = p5pb_pci_make_tag;
- sc->apc.pc_decompose_tag = p5pb_pci_decompose_tag;
+ sc->apc.pc_make_tag = amiga_pci_make_tag;
+ sc->apc.pc_decompose_tag = amiga_pci_decompose_tag;
sc->apc.pc_conf_read = p5pb_pci_conf_read;
sc->apc.pc_conf_write = p5pb_pci_conf_write;
sc->apc.pc_attach_hook = p5pb_pci_attach_hook;
-
- pba.pba_iot = NULL;
+
+ sc->apc.pc_intr_map = p5pb_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;
+
+ pba.pba_iot = &(sc->pci_io_area);
pba.pba_memt = &(sc->pci_mem_area);
pba.pba_dmat = NULL;
pba.pba_dmat64 = NULL;
pba.pba_pc = pc;
- pba.pba_flags = PCI_FLAGS_MEM_OKAY;
+ pba.pba_flags = PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY;
pba.pba_bus = 0;
pba.pba_bridgetag = NULL;
@@ -217,13 +239,13 @@
uint32_t bus, dev, func;
pci_decompose_tag(pc, tag, &bus, &dev, &func);
-
- data = bus_space_read_4(pc->pci_conf_iot, pc->pci_conf_ioh,
+
+ data = bus_space_read_4(pc->pci_conf_datat, pc->pci_conf_datah,
(func<<5) + reg);
#ifdef P5PB_DEBUG
aprint_normal("p5pb conf read va: %lx, bus: %d, dev: %d, "
"func: %d, reg: %d -r-> data %x\n",
- pc->pci_conf_ioh, bus, dev, func, reg, data);
+ pc->pci_conf_datah, bus, dev, func, reg, data);
#endif
return data;
}
@@ -235,12 +257,12 @@
pci_decompose_tag(pc, tag, &bus, &dev, &func);
- bus_space_write_4(pc->pci_conf_iot, pc->pci_conf_ioh,
+ bus_space_write_4(pc->pci_conf_datat, pc->pci_conf_datah,
(func << 5) + reg, val);
#ifdef P5PB_DEBUG
aprint_normal("p5pb conf write va: %lx, bus: %d, dev: %d, "
"func: %d, reg: %d -w-> data %x\n",
- pc->pci_conf_ioh, bus, dev, func, reg, val);
+ pc->pci_conf_datah, bus, dev, func, reg, val);
#endif
}
@@ -248,8 +270,7 @@
int
p5pb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
{
-
- /* Allow only one device. Obvious in case of CVPPC/BVPPC. */
+ /* G-Rex has max 5 slots. CVPPC/BVPPC has only 1. */
return 1;
}
@@ -279,3 +300,12 @@
{
}
+int
+p5pb_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
+{
+ /* TODO: add sanity checking */
+
+ *ihp = 2;
+ return 0;
+}
+
Index: src/sys/arch/amiga/pci/p5pbreg.h
diff -u src/sys/arch/amiga/pci/p5pbreg.h:1.1 src/sys/arch/amiga/pci/p5pbreg.h:1.2
--- src/sys/arch/amiga/pci/p5pbreg.h:1.1 Thu Aug 4 17:48:51 2011
+++ src/sys/arch/amiga/pci/p5pbreg.h Mon Sep 19 19:15:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: p5pbreg.h,v 1.1 2011/08/04 17:48:51 rkujawa Exp $ */
+/* $NetBSD: p5pbreg.h,v 1.2 2011/09/19 19:15:29 rkujawa Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -32,9 +32,9 @@
/*
* Reverse engineered Phase5 PCI bridge memory map (firmware 44.71):
*
- * 0xFFFA0000 - (unknown)
+ * 0xFFFA0000 - PCI register space, 64KB
* 0xFFFC0000 - PCI configuration mechanism #1 data, 128KB
- * 0xFFFE0000 - PCI configuration mechanism #1 address, 4KB
+ * 0xFFFE0000 - (unknown, maybe PCI configuration mechanism #1 address, 4KB)
*
* 0xE0000000 - Permedia RAM on CVPPC/BVPPC (1st aperture), 8MB
* 0xE0800000 - Permedia RAM on CVPPC/BVPPC (2nd aperture), 8MB
@@ -44,18 +44,22 @@
*
* The bridge is probably capable of DMA and interrupts, but this would
* need further reverse engineering, and is not really needed to drive
- * the Permedia 2 chip.
+ * the Permedia 2 chip on CVPPC/BVPPC cards.
*/
#ifndef _AMIGA_P5PBREG_H_
-#define P5BUS_PCI_CONF_BASE 0xFFFA0000
-#define P5BUS_PCI_CONF_SIZE 0x00041000
+#define P5BUS_PCI_CONF_BASE 0xFFFC0000
+#define P5BUS_PCI_CONF_SIZE 0x00021000
+/* XXX: This is OK for CVPPC/BVPPC only! */
#define P5BUS_PCI_MEM_BASE 0xE0000000
#define P5BUS_PCI_MEM_SIZE 0x01010000 /* actually 0x01020000 */
-#define OFF_PCI_CONF_DATA 0x00020000
-#define OFF_PCI_CONF_ADDR 0x00040000
+#define P5BUS_PCI_IO_BASE 0xFFFA0000
+#define P5BUS_PCI_IO_SIZE 0x0000FFFF
+
+#define OFF_PCI_CONF_DATA 0x00000000
+#define OFF_PCI_CONF_ADDR 0x00020000
#define P5BUS_CONF_ENDIAN 0x0000 /* PCI_CONF_ADDR + offset */
#define P5BUS_CONF_ENDIAN_BIG 0x02 /* to switch into BE mode */
Added files:
Index: src/sys/arch/amiga/pci/pci_machdep.c
diff -u /dev/null src/sys/arch/amiga/pci/pci_machdep.c:1.1
--- /dev/null Mon Sep 19 19:15:30 2011
+++ src/sys/arch/amiga/pci/pci_machdep.c Mon Sep 19 19:15:29 2011
@@ -0,0 +1,120 @@
+/* $NetBSD: pci_machdep.c,v 1.1 2011/09/19 19:15:29 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2011 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.
+ */
+
+/* Amiga-specific PCI MD stuff. */
+
+#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/mppbreg.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+#include <dev/pci/pciconf.h>
+
+pcitag_t
+amiga_pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
+{
+ return (bus << 16) | (device << 11) | (function << 8);
+}
+
+void
+amiga_pci_decompose_tag(pci_chipset_tag_t pc, 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) & 0x07;
+}
+
+void *
+amiga_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
+ int (*ih_fun)(void *), void *ih_arg)
+{
+ struct isr* pci_isr;
+ pci_isr = kmem_zalloc(sizeof(struct isr), KM_SLEEP);
+
+ /* TODO: check for bogus handle */
+
+ pci_isr->isr_intr = ih_fun;
+ pci_isr->isr_arg = ih_arg;
+ pci_isr->isr_ipl = 2; /* XXX: true for all current drivers */
+ add_isr(pci_isr);
+ return pci_isr;
+}
+
+void
+amiga_pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
+{
+ remove_isr(cookie);
+ kmem_free(cookie, sizeof(struct isr));
+}
+
+const char *
+amiga_pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih)
+{
+ static char str[10];
+
+ sprintf(str, "INT%d", (int) ih);
+ return str;
+}
+
+int
+amiga_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev, int func,
+ pcireg_t id)
+{
+ return PCI_CONF_DEFAULT;
+}
+
+void
+amiga_pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int func,
+ int swiz, int *iline)
+{
+}
+