summaryrefslogtreecommitdiff
path: root/include/dma.h
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2019-08-02 10:19:43 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-13 00:46:05 +0000
commit4609b59404bd6e32c4cdb267658511a46557dab2 (patch)
treefd2182960546330dd7b0d222e49d29be6a4643c1 /include/dma.h
parentd09bc18d46c37070e3309b4f72a33d27134dea45 (diff)
downloadchrome-ec-4609b59404bd6e32c4cdb267658511a46557dab2.tar.gz
dma: separate out DMA enable status from wait_for_bytes
When wait_for_bytes returns 0 when DMA is disabled, we can't differentiate between DMA being disabled and a transfer having completed when it has reached the end of the requested transfer. Separating out into separate functions lets us distinguish the two cases. The reason we didn't hit this in the past is that the requested receive size is generally larger than the actual amount we're sending. Since we know the amount that we're waiting for from the header, we would stop the transfer in software. BRANCH=none BUG=b:132444384 TEST=On DUTs with bloonchipper and dartmonkey: ectool --name=cros_fp testmaxtransfer TEST=make buildall -j Change-Id: I885161a3e04b7a12d597d8dc8691f599990bda8b Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1734010 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'include/dma.h')
-rw-r--r--include/dma.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/dma.h b/include/dma.h
index a6be40a031..1687b5f899 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -13,6 +13,8 @@
#include "common.h"
#include "registers.h"
+#include <stdbool.h>
+
/* DMA channel options */
struct dma_option {
enum dma_channel channel; /* DMA channel */
@@ -76,12 +78,19 @@ void dma_disable_all(void);
*
* @param chan DMA channel to check, from dma_get_channel()
* @param orig_count Original number of bytes requested on channel
- * @return number of bytes completed on a channel, or 0 if this channel is
- * not enabled
+ * @return number of bytes completed on a channel
*/
int dma_bytes_done(dma_chan_t *chan, int orig_count);
/**
+ * Check if DMA for a given channel is enabled.
+ *
+ * @param chan DMA channel to check, from dma_get_channel()
+ * @return true if DMA is enabled on the channel, false otherwise
+ */
+bool dma_is_enabled(dma_chan_t *chan);
+
+/**
* Start a previously-prepared dma channel
*
* @param chan Channel to start, from dma_get_channel()