Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci use MMIO if available



details:   https://anonhg.NetBSD.org/src/rev/3df54d9d8dc9
branches:  trunk
changeset: 779198:3df54d9d8dc9
user:      macallan <macallan%NetBSD.org@localhost>
date:      Thu May 10 03:16:50 2012 +0000

description:
use MMIO if available

diffstat:

 sys/dev/pci/trm.c    |  22 +++++++++++++++-------
 sys/dev/pci/trmreg.h |   6 +++++-
 2 files changed, 20 insertions(+), 8 deletions(-)

diffs (74 lines):

diff -r 972b0b20f025 -r 3df54d9d8dc9 sys/dev/pci/trm.c
--- a/sys/dev/pci/trm.c Thu May 10 01:25:24 2012 +0000
+++ b/sys/dev/pci/trm.c Thu May 10 03:16:50 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trm.c,v 1.32 2010/11/13 13:52:08 uebayasi Exp $        */
+/*     $NetBSD: trm.c,v 1.33 2012/05/10 03:16:50 macallan Exp $        */
 /*-
  * Copyright (c) 2002 Izumi Tsutsui.  All rights reserved.
  *
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trm.c,v 1.32 2010/11/13 13:52:08 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trm.c,v 1.33 2012/05/10 03:16:50 macallan Exp $");
 
 /* #define TRM_DEBUG */
 #ifdef TRM_DEBUG
@@ -412,11 +412,12 @@
        pci_intr_handle_t ih;
        pcireg_t command;
        const char *intrstr;
+       int fl = 0;
 
        sc->sc_dev = self;
 
        /*
-        * These cards do not allow memory mapped accesses
+        * Some cards do not allow memory mapped accesses
         * pa_pc:  chipset tag
         * pa_tag: pci tag
         */
@@ -430,10 +431,17 @@
        /*
         * mask for get correct base address of pci IO port
         */
-       if (pci_mapreg_map(pa, PCI_MAPREG_START, PCI_MAPREG_TYPE_IO, 0,
-           &iot, &ioh, NULL, NULL)) {
-               aprint_error(": unable to map registers\n");
-               return;
+       if (command & PCI_COMMAND_MEM_ENABLE) {
+               fl = pci_mapreg_map(pa, TRM_BAR_MMIO, PCI_MAPREG_TYPE_MEM, 0, &iot,
+                   &ioh, NULL, NULL);
+       }
+       if (fl != 0) {
+               aprint_verbose_dev(self, "couldn't map MMIO registers, tryion PIO\n");
+               if ((fl = pci_mapreg_map(pa, TRM_BAR_PIO, PCI_MAPREG_TYPE_IO, 0,
+                   &iot, &ioh, NULL, NULL)) != 0) {
+                       aprint_error(": unable to map registers (%d)\n", fl);
+                       return;
+               }
        }
        /*
         * test checksum of eeprom.. & initialize softc...
diff -r 972b0b20f025 -r 3df54d9d8dc9 sys/dev/pci/trmreg.h
--- a/sys/dev/pci/trmreg.h      Thu May 10 01:25:24 2012 +0000
+++ b/sys/dev/pci/trmreg.h      Thu May 10 03:16:50 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trmreg.h,v 1.1 2001/11/03 17:01:18 tsutsui Exp $       */
+/*     $NetBSD: trmreg.h,v 1.2 2012/05/10 03:16:50 macallan Exp $      */
 /*
  * Device Driver for Tekram DC395U/UW/F, DC315/U
  * PCI SCSI Bus Master Host Adapter
@@ -40,6 +40,10 @@
  *   (C)Copyright 1995-1999 Tekram Technology Co., Ltd. All rights reserved.
  */
 
+#define TRM_BAR_PIO    0x10
+/* DC-315 has an MMIO BAR */
+#define TRM_BAR_MMIO   0x14
+
 /*
  **********************************************************************
  *



Home | Main Index | Thread Index | Old Index