You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by be...@apache.org on 2020/09/15 19:11:16 UTC

[mynewt-core] branch master updated: mcu/dialog: Fix a few bugs in da1469x_dma.c.

This is an automated email from the ASF dual-hosted git repository.

benmccrea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new c35af7d  mcu/dialog: Fix a few bugs in da1469x_dma.c.
     new 4d75fc4  Merge pull request #2375 from JuulLabs/fix-dma-req-mux
c35af7d is described below

commit c35af7da73fbe34c7ba457a1dc8bc2728649445e
Author: Ben McCrea <bm...@juul.com>
AuthorDate: Fri Sep 11 18:36:14 2020 -0700

    mcu/dialog: Fix a few bugs in da1469x_dma.c.
    
    Fixes a few issues that were causing unreliable DMA operation when using channels
    higher than 0 and 1.
    
    In MCU_DMA_GET_MUX, shift the mux config bitfields by cidx*2 instead of cidx*4.
    
    Add code to exclude channels 8 and higher from using DMA_REQ_MUX_REG,
    since the register only applies to channels 0-7.
---
 hw/mcu/dialog/da1469x/src/da1469x_dma.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/src/da1469x_dma.c b/hw/mcu/dialog/da1469x/src/da1469x_dma.c
index ff98682..79277a7 100644
--- a/hw/mcu/dialog/da1469x/src/da1469x_dma.c
+++ b/hw/mcu/dialog/da1469x/src/da1469x_dma.c
@@ -38,7 +38,7 @@
             ((_periph) << ((_cidx) * 2));           \
     } while (0)
 #define MCU_DMA_GET_MUX(_cidx)                      \
-    (DMA->DMA_REQ_MUX_REG >> ((_cidx) * 4) & 0xf)
+    ((DMA->DMA_REQ_MUX_REG >> ((_cidx) * 2)) & 0xf)
 
 struct da1469x_dma_interrupt_cfg {
     da1469x_dma_interrupt_cb cb;
@@ -133,7 +133,12 @@ da1469x_dma_acquire_single(int cidx)
 
     chan = MCU_DMA_CIDX2CHAN(cidx);
 
-    MCU_DMA_SET_MUX(cidx, MCU_DMA_PERIPH_NONE);
+    /*
+     * DMA_REQ_MUX_REG applies only to channels < 8
+     */
+    if (cidx < 8) {
+        MCU_DMA_SET_MUX(cidx, MCU_DMA_PERIPH_NONE);
+    }
 
     chan->DMA_CTRL_REG &= ~DMA_DMA0_CTRL_REG_DREQ_MODE_Msk;
 
@@ -181,8 +186,10 @@ da1469x_dma_release_channel(struct da1469x_dma_regs *chan)
     /*
      * If corresponding pair for this channel is configured for triggering from
      * peripheral, we'll use lower of channel index.
+     *
+     * Only channels 0-7 can use pairs for peripherals.
      */
-    if (MCU_DMA_GET_MUX(cidx) != MCU_DMA_PERIPH_NONE) {
+    if (cidx < 8 && MCU_DMA_GET_MUX(cidx) != MCU_DMA_PERIPH_NONE) {
         cidx &= 0xfe;
         chan = MCU_DMA_CIDX2CHAN(cidx);
 
@@ -201,7 +208,6 @@ da1469x_dma_release_channel(struct da1469x_dma_regs *chan)
     } else {
         chan->DMA_CTRL_REG &= ~DMA_DMA0_CTRL_REG_DMA_ON_Msk;
         g_da1469x_dma_acquired &= ~(1 << cidx);
-
         g_da1469x_dma_isr_set &= ~(1 << cidx);
         DMA->DMA_CLEAR_INT_REG = 1 << cidx;
         memset(&g_da1469x_dma_isr_cfg[cidx], 0,