Module Name:    src
Committed By:   macallan
Date:           Thu May 10 03:16:50 UTC 2012

Modified Files:
        src/sys/dev/pci: trm.c trmreg.h

Log Message:
use MMIO if available


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/trm.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/trmreg.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/dev/pci/trm.c
diff -u src/sys/dev/pci/trm.c:1.32 src/sys/dev/pci/trm.c:1.33
--- src/sys/dev/pci/trm.c:1.32	Sat Nov 13 13:52:08 2010
+++ src/sys/dev/pci/trm.c	Thu May 10 03:16:50 2012
@@ -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 @@ trm_attach(device_t parent, device_t sel
 	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 @@ trm_attach(device_t parent, device_t sel
 	/*
 	 * 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...

Index: src/sys/dev/pci/trmreg.h
diff -u src/sys/dev/pci/trmreg.h:1.1 src/sys/dev/pci/trmreg.h:1.2
--- src/sys/dev/pci/trmreg.h:1.1	Sat Nov  3 17:01:18 2001
+++ src/sys/dev/pci/trmreg.h	Thu May 10 03:16:50 2012
@@ -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
+
 /*
  **********************************************************************
  *

Reply via email to