esp: clear FIFO before issuing ESP command
This ensures that any partially transferred data is removed from the FIFO
before issuing the next ESP command.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
diff --git a/drivers/esp.c b/drivers/esp.c
index 0880ab2..95e969f 100644
--- a/drivers/esp.c
+++ b/drivers/esp.c
@@ -97,6 +97,8 @@
esp->ll->regs[ESP_TCMED] = (cmdlen >> 8) & 0xff;
// Set DMA direction and enable DMA
esp->espdma.regs->cond_reg = DMA_ENABLE;
+ // Clear FIFO
+ esp->ll->regs[ESP_CMD] = ESP_CMD_FLUSH;
// Set ATN, issue command
esp->ll->regs[ESP_CMD] = ESP_CMD_SELA | ESP_CMD_DMA;
// Wait for DMA to complete. Can this fail?