From e5545eed6d43a1f4df1bafe80823d023719c0938 Mon Sep 17 00:00:00 2001 From: loos Date: Sat, 14 Feb 2015 18:45:43 +0000 Subject: MFC r276298, r276303: Remove the '#undef DEBUG' that should not be committed. Removes unused and duplicate headers. Bring the wait limit on mailbox write to a more sane value. Fix a off-by-one bug on wait time limit. Remove extra blank line. --- sys/arm/broadcom/bcm2835/bcm2835_mbox.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c index 224a0d5..3372b61 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c @@ -31,25 +31,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -#include +#include #include #include -#include -#include -#include #include -#include -#include -#include -#include #include #include -#include -#include - #include #include "mbox_if.h" @@ -76,7 +67,6 @@ __FBSDID("$FreeBSD$"); mtx_unlock(&(sc)->lock); \ } while(0) -#undef DEBUG #ifdef DEBUG #define dprintf(fmt, args...) printf(fmt, ##args) #else @@ -189,25 +179,21 @@ bcm_mbox_attach(device_t dev) static int bcm_mbox_write(device_t dev, int chan, uint32_t data) { - int limit = 20000; + int limit = 1000; struct bcm_mbox_softc *sc = device_get_softc(dev); dprintf("bcm_mbox_write: chan %d, data %08x\n", chan, data); MBOX_LOCK(sc); - - while ((mbox_read_4(sc, REG_STATUS) & STATUS_FULL) && limit--) { - DELAY(2); - } - + while ((mbox_read_4(sc, REG_STATUS) & STATUS_FULL) && --limit) + DELAY(5); if (limit == 0) { printf("bcm_mbox_write: STATUS_FULL stuck"); MBOX_UNLOCK(sc); return (EAGAIN); } - mbox_write_4(sc, REG_WRITE, MBOX_MSG(chan, data)); - MBOX_UNLOCK(sc); + return (0); } @@ -255,4 +241,3 @@ static driver_t bcm_mbox_driver = { static devclass_t bcm_mbox_devclass; DRIVER_MODULE(mbox, simplebus, bcm_mbox_driver, bcm_mbox_devclass, 0, 0); - -- cgit v1.1