summaryrefslogtreecommitdiff
path: root/sys/dev/pci/ahc_pci.c
diff options
context:
space:
mode:
authorSteve Murphree <smurph@cvs.openbsd.org>2000-07-03 22:18:38 +0000
committerSteve Murphree <smurph@cvs.openbsd.org>2000-07-03 22:18:38 +0000
commit85540feb0bbe3a4fbd02849b3db5690456fb7db1 (patch)
treedc9b31478f4c2335f279721a20ede2f6153476a7 /sys/dev/pci/ahc_pci.c
parent36f85d779a2de6d33c48908bf950c32ae88bf615 (diff)
Add support for big endian hardware. Clean up memory vs. io mapping code.
Fix for drives with Tag quirks.
Diffstat (limited to 'sys/dev/pci/ahc_pci.c')
-rw-r--r--sys/dev/pci/ahc_pci.c57
1 files changed, 37 insertions, 20 deletions
diff --git a/sys/dev/pci/ahc_pci.c b/sys/dev/pci/ahc_pci.c
index dd2dd142914..a5778bf0ae1 100644
--- a/sys/dev/pci/ahc_pci.c
+++ b/sys/dev/pci/ahc_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahc_pci.c,v 1.18 2000/05/26 06:49:32 chris Exp $ */
+/* $OpenBSD: ahc_pci.c,v 1.19 2000/07/03 22:18:37 smurph Exp $ */
/* $NetBSD: ahc_pci.c,v 1.9 1996/10/21 22:56:24 thorpej Exp $ */
/*
@@ -56,6 +56,14 @@
#include <dev/ic/aic7xxxvar.h>
#include <dev/ic/smc93cx6var.h>
+/*
+ * XXX memory-mapped is busted on some i386 on-board chips.
+ * for i386, we don't even try it.
+ */
+#ifndef i386
+#define AHC_ALLOW_MEMIO
+#endif
+
/*
* Under normal circumstances, these messages are unnecessary
* and not terribly cosmetic.
@@ -205,11 +213,6 @@ void *aux;
struct ahc_softc *ahc = (void *)self;
bus_space_tag_t iot;
bus_space_handle_t ioh;
-#ifdef AHC_ALLOW_MEMIO
- bus_space_tag_t memt;
- bus_space_handle_t memh;
- int memh_valid;
-#endif
pci_intr_handle_t ih;
pcireg_t command;
const char *intrstr;
@@ -354,23 +357,37 @@ void *aux;
/* TTT */
}
}
-
-#ifdef AHC_ALLOW_MEMIO
- memh_valid = (pci_mapreg_map(pa, AHC_PCI_MEMADDR,
- PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
- &memt, &memh, NULL, NULL) == 0);
-#endif
- ioh_valid = (pci_mapreg_map(pa, AHC_PCI_IOADDR,
- PCI_MAPREG_TYPE_IO, 0, &iot, &ioh, NULL, NULL) == 0);
- if (ioh_valid) {
- /* do nothing */
#ifdef AHC_ALLOW_MEMIO
- } else if (memh_valid) {
- /* do nothing */
+ /*
+ * attempt to use memory mapping on hardware that supports it.
+ * e.g powerpc XXX - smurph
+ *
+ * Note: If this fails, IO mapping is used.
+ */
+ if ((command & PCI_COMMAND_MEM_ENABLE) != 0) {
+ pcireg_t memtype;
+ memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, AHC_PCI_MEMADDR);
+ switch (memtype) {
+ case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
+ case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
+ ioh_valid = (pci_mapreg_map(pa, AHC_PCI_MEMADDR,
+ memtype, 0, &iot, &ioh, NULL, NULL) == 0);
+ break;
+ default:
+ ioh_valid = 0;
+ }
+ }
+
+ if (!ioh_valid) /* try to drop back to IO mapping */
#endif
- } else {
- /* error out */
+ {
+ ioh_valid = (pci_mapreg_map(pa, AHC_PCI_IOADDR,
+ PCI_MAPREG_TYPE_IO, 0, &iot, &ioh, NULL, NULL) == 0);
+ }
+
+ if (!ioh_valid) {
+ /* Game Over. Insert coin... */
printf(": unable to map registers\n");
return;
}