diff options
-rw-r--r-- | sys/dev/ic/mfi.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c index a3e78c36644..33d25e56c51 100644 --- a/sys/dev/ic/mfi.c +++ b/sys/dev/ic/mfi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfi.c,v 1.2 2006/04/06 22:44:24 marco Exp $ */ +/* $OpenBSD: mfi.c,v 1.3 2006/04/07 16:11:21 marco Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -40,6 +40,8 @@ #include <dev/biovar.h> #endif +#define MFI_DEBUG + struct cfdriver mfi_cd = { NULL, "mfi", DV_DULL }; @@ -61,26 +63,33 @@ int mfi_transition_firmware(struct mfi_softc *); int mfi_transition_firmware(struct mfi_softc *sc) { -#if 0 int32_t fw_state, cur_state; int max_wait, i; - /* fw_state = MFI_READ4(sc, MFI_OMSG0) & MFI_STATE_MASK; */ +#ifdef MFI_DEBUG + printf("%s: mfi_transition_mfi\n", DEVNAME(sc)); +#endif /* MFI_DEBUG */ + + fw_state = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MFI_OMSG0) & + MFI_STATE_MASK; while (fw_state != MFI_STATE_READY) { #ifdef MFI_DEBUG - printf("Waiting for firmware to become ready\n"); + printf("%s: waiting for firmware to become ready\n", + DEVNAME(sc)); #endif /* MFI_DEBUG */ cur_state = fw_state; switch (fw_state) { case MFI_STATE_FAULT: - device_printf(sc->mfi_dev, "Firmware fault\n"); + printf("%s: firmware fault\n", DEVNAME(sc)); return (ENXIO); case MFI_STATE_WAIT_HANDSHAKE: - MFI_WRITE4(sc, MFI_IDB, MFI_INIT_CLEAR_HANDSHAKE); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + MFI_IDB, MFI_INIT_CLEAR_HANDSHAKE); max_wait = 2; break; case MFI_STATE_OPERATIONAL: - MFI_WRITE4(sc, MFI_IDB, MFI_INIT_READY); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + MFI_IDB, MFI_INIT_READY); max_wait = 10; break; case MFI_STATE_UNDEFINED: @@ -93,24 +102,25 @@ mfi_transition_firmware(struct mfi_softc *sc) max_wait = 20; break; default: - device_printf(sc->mfi_dev,"Unknown firmware state %d\n", - fw_state); + printf("%s: unknown firmware state %d\n", + DEVNAME(sc), fw_state); return (ENXIO); } for (i = 0; i < (max_wait * 10); i++) { - fw_state = MFI_READ4(sc, MFI_OMSG0) & MFI_STATE_MASK; + fw_state = bus_space_read_4(sc->sc_iot, sc->sc_ioh, + MFI_OMSG0) & MFI_STATE_MASK; if (fw_state == cur_state) DELAY(100000); else break; } if (fw_state == cur_state) { - device_printf(sc->mfi_dev, "firmware stuck in state " - "%#x\n", fw_state); + printf("%s: firmware stuck in state %#x\n", fw_state, + DEVNAME(sc)); return (ENXIO); } } -#endif + return (0); } |