diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-04-25 08:32:59 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-04-25 08:32:59 +0000 |
commit | 6dd937cd75d7a1bf8aae558553f69d3a08954fd0 (patch) | |
tree | 6bd36c56b0c70453d9c1bd35911377d0532354eb | |
parent | 98f3b2fdc5192e6e6b4af41d3fb5498b66a1ba51 (diff) |
put a two second timeout on the chip init after the firmware is loaded
-rw-r--r-- | sys/dev/pci/if_tht.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/sys/dev/pci/if_tht.c b/sys/dev/pci/if_tht.c index 36c6d3f124a..a92b24023b0 100644 --- a/sys/dev/pci/if_tht.c +++ b/sys/dev/pci/if_tht.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tht.c,v 1.68 2007/04/25 08:10:27 dlg Exp $ */ +/* $OpenBSD: if_tht.c,v 1.69 2007/04/25 08:32:58 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -572,6 +572,7 @@ void tht_fifo_post(struct tht_softc *, void tht_read_lladdr(struct tht_softc *); int tht_sw_reset(struct tht_softc *); int tht_fw_load(struct tht_softc *); +void tht_fw_tick(void *arg); void tht_link_state(struct tht_softc *); /* interface operations */ @@ -1546,6 +1547,8 @@ tht_sw_reset(struct tht_softc *sc) int tht_fw_load(struct tht_softc *sc) { + struct timeout ticker; + volatile int ok = 1; u_int8_t *fw, *buf; size_t fwlen, wrlen; int error = 1; @@ -1572,12 +1575,20 @@ tht_fw_load(struct tht_softc *sc) buf += wrlen; } - while (tht_read(sc, THT_REG_INIT_STATUS)) { + timeout_set(&ticker, tht_fw_tick, &ticker); + timeout_add(&ticker, 2*hz); + while (ok) { + if (tht_read(sc, THT_REG_INIT_STATUS) != 0) { + error = 0; + break; + } + if (tsleep(sc, PCATCH, "thtinit", 1) == EINTR) goto err; } + timeout_del(&ticker); - error = 0; + tht_write(sc, THT_REG_INIT_SEMAPHORE, 0x1); err: free(fw, M_DEVBUF); @@ -1585,6 +1596,14 @@ err: } void +tht_fw_tick(void *arg) +{ + volatile int *ok = arg; + + *ok = 0; +} + +void tht_link_state(struct tht_softc *sc) { struct ifnet *ifp = &sc->sc_ac.ac_if; |