From a0fe3cc5fec38369f8e2bc4500e542577dad2ceb Mon Sep 17 00:00:00 2001 From: macallan Date: Thu, 10 May 2012 03:16:50 +0000 Subject: [PATCH] use MMIO if available --- sys/dev/pci/trm.c | 22 +++++++++++++++------- sys/dev/pci/trmreg.h | 6 +++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/sys/dev/pci/trm.c b/sys/dev/pci/trm.c index 0915de3d9163..2453d4174c7a 100644 --- a/sys/dev/pci/trm.c +++ b/sys/dev/pci/trm.c @@ -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 -__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 self, void *aux) 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 self, void *aux) /* * 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 --git a/sys/dev/pci/trmreg.h b/sys/dev/pci/trmreg.h index 213a6eeb8668..42e4f8fd1804 100644 --- a/sys/dev/pci/trmreg.h +++ b/sys/dev/pci/trmreg.h @@ -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 + /* ********************************************************************** *