summaryrefslogtreecommitdiffstats
path: root/sys/dev/re
diff options
context:
space:
mode:
authoryongari <yongari@FreeBSD.org>2008-07-02 05:21:09 +0000
committeryongari <yongari@FreeBSD.org>2008-07-02 05:21:09 +0000
commit31d44ce02d9145b4036bf1623d725f9bd0ffdf19 (patch)
treef6c48e2a01124f2673c0f7724344865fe70ad8d4 /sys/dev/re
parent124e2b3fa07e98d7bd26ce68b3fe6f0e59aa1a34 (diff)
downloadFreeBSD-src-31d44ce02d9145b4036bf1623d725f9bd0ffdf19.zip
FreeBSD-src-31d44ce02d9145b4036bf1623d725f9bd0ffdf19.tar.gz
Switch to memory space register mapping over IO space. If that
mapping fails fall back to traditional IO space access.
Diffstat (limited to 'sys/dev/re')
-rw-r--r--sys/dev/re/if_re.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c
index 505b318..ebac447 100644
--- a/sys/dev/re/if_re.c
+++ b/sys/dev/re/if_re.c
@@ -155,11 +155,6 @@ MODULE_DEPEND(re, miibus, 1, 1, 1);
/* "device miibus" required. See GENERIC if you get errors here. */
#include "miibus_if.h"
-/*
- * Default to using PIO access for this driver.
- */
-#define RE_USEIOSPACE
-
/* Tunables. */
static int msi_disable = 1;
TUNABLE_INT("hw.re.msi_disable", &msi_disable);
@@ -272,14 +267,6 @@ static void re_clrwol (struct rl_softc *);
static int re_diag (struct rl_softc *);
#endif
-#ifdef RE_USEIOSPACE
-#define RL_RES SYS_RES_IOPORT
-#define RL_RID RL_PCI_LOIO
-#else
-#define RL_RES SYS_RES_MEMORY
-#define RL_RID RL_PCI_LOMEM
-#endif
-
static device_method_t re_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, re_probe),
@@ -1129,7 +1116,7 @@ re_attach(dev)
struct ifnet *ifp;
struct rl_hwrev *hw_rev;
int hwrev;
- u_int16_t re_did = 0;
+ u_int16_t devid, re_did = 0;
int error = 0, rid, i;
int msic, reg;
uint8_t cfg;
@@ -1146,14 +1133,26 @@ re_attach(dev)
*/
pci_enable_busmaster(dev);
- rid = RL_RID;
- sc->rl_res = bus_alloc_resource_any(dev, RL_RES, &rid,
- RF_ACTIVE);
+ devid = pci_get_device(dev);
+ /* Prefer memory space register mapping over IO space. */
+ sc->rl_res_id = PCIR_BAR(1);
+ sc->rl_res_type = SYS_RES_MEMORY;
+ /* RTL8168/8101E seems to use different BARs. */
+ if (devid == RT_DEVICEID_8168 || devid == RT_DEVICEID_8101E)
+ sc->rl_res_id = PCIR_BAR(2);
+ sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type,
+ &sc->rl_res_id, RF_ACTIVE);
if (sc->rl_res == NULL) {
- device_printf(dev, "couldn't map ports/memory\n");
- error = ENXIO;
- goto fail;
+ sc->rl_res_id = PCIR_BAR(0);
+ sc->rl_res_type = SYS_RES_IOPORT;
+ sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type,
+ &sc->rl_res_id, RF_ACTIVE);
+ if (sc->rl_res == NULL) {
+ device_printf(dev, "couldn't map ports/memory\n");
+ error = ENXIO;
+ goto fail;
+ }
}
sc->rl_btag = rman_get_bustag(sc->rl_res);
@@ -1463,7 +1462,8 @@ re_detach(dev)
pci_release_msi(dev);
}
if (sc->rl_res)
- bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res);
+ bus_release_resource(dev, sc->rl_res_type, sc->rl_res_id,
+ sc->rl_res);
/* Unload and free the RX DMA ring memory and map */
OpenPOWER on IntegriCloud