| 243 | } |
| 244 | |
| 245 | static int |
| 246 | ti_mbox_write(device_t dev, int chan, uint32_t data) |
| 247 | { |
| 248 | int limit = 500; |
| 249 | struct ti_mbox_softc *sc; |
| 250 | |
| 251 | if (chan < 0 || chan > 7) |
| 252 | return (EINVAL); |
| 253 | sc = device_get_softc(dev); |
| 254 | TI_MBOX_LOCK(sc); |
| 255 | /* XXX implement interrupt method */ |
| 256 | while (ti_mbox_reg_read(sc, TI_MBOX_FIFOSTATUS(chan)) == 1 && |
| 257 | limit--) { |
| 258 | DELAY(10); |
| 259 | } |
| 260 | if (limit == 0) { |
| 261 | device_printf(dev, "FIFOSTAUS%d stuck\n", chan); |
| 262 | TI_MBOX_UNLOCK(sc); |
| 263 | return (EAGAIN); |
| 264 | } |
| 265 | ti_mbox_reg_write(sc, TI_MBOX_MESSAGE(chan), data); |
| 266 | |
| 267 | return (0); |
| 268 | } |
nothing calls this directly
no test coverage detected