summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2007-08-15 00:13:51 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2007-08-15 00:13:51 +0000
commitf1b48719e421b0120906b3dbfbfcf5189eccda2c (patch)
tree03b9c88791baace9613b96a941af4a58eda9f304 /sys/dev
parent5e8a6507dd6eab229c36870778df4123321ab930 (diff)
code to wait on registers in the main and crb spaces.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_nxe.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/sys/dev/pci/if_nxe.c b/sys/dev/pci/if_nxe.c
index cbdb6d78dd8..211b11c469b 100644
--- a/sys/dev/pci/if_nxe.c
+++ b/sys/dev/pci/if_nxe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nxe.c,v 1.8 2007/08/15 00:07:06 dlg Exp $ */
+/* $OpenBSD: if_nxe.c,v 1.9 2007/08/15 00:13:50 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -253,11 +253,16 @@ struct cfdriver nxe_cd = {
/* low level hardware access goo */
u_int32_t nxe_read(struct nxe_softc *, bus_size_t);
void nxe_write(struct nxe_softc *, bus_size_t, u_int32_t);
+int nxe_wait(struct nxe_softc *, bus_size_t, u_int32_t,
+ u_int32_t, u_int);
int nxe_crb_set(struct nxe_softc *, int);
u_int32_t nxe_crb_read(struct nxe_softc *, bus_size_t);
void nxe_crb_write(struct nxe_softc *, bus_size_t,
u_int32_t);
+int nxe_crb_wait(struct nxe_softc *, bus_size_t,
+ u_int32_t, u_int32_t, u_int);
+
/* misc bits */
#define DEVNAME(_sc) ((_sc)->sc_dev.dv_xname)
@@ -354,6 +359,22 @@ nxe_write(struct nxe_softc *sc, bus_size_t r, u_int32_t v)
}
int
+nxe_wait(struct nxe_softc *sc, bus_size_t r, u_int32_t m, u_int32_t v,
+ u_int timeout)
+{
+ while ((nxe_read(sc, r) & m) != v) {
+ if (timeout == 0)
+ return (0);
+
+ delay(1000);
+ timeout--;
+ }
+
+ return (1);
+}
+
+
+int
nxe_crb_set(struct nxe_softc *sc, int window)
{
int oldwindow = sc->sc_window;
@@ -383,3 +404,19 @@ nxe_crb_write(struct nxe_softc *sc, bus_size_t r, u_int32_t v)
bus_space_barrier(sc->sc_memt, sc->sc_crbh, r, 4,
BUS_SPACE_BARRIER_WRITE);
}
+
+int
+nxe_crb_wait(struct nxe_softc *sc, bus_size_t r, u_int32_t m, u_int32_t v,
+ u_int timeout)
+{
+ while ((nxe_crb_read(sc, r) & m) != v) {
+ if (timeout == 0)
+ return (0);
+
+ delay(1000);
+ timeout--;
+ }
+
+ return (1);
+}
+