Skip to content

Commit 38078f0

Browse files
ADESTMatorgue
authored andcommitted
dmaengine: stm32-dma: add alternate REQ/ACK protocol management
STM32 USART/UART is not managing correctly the default DMA REQ/ACK protocol leading to possibly lock the DMA stream. Default protocol consists in maintaining ACK signal up to the removal of REQuest and the transfer completion. In case of alternative REQ/ACK protocol, ACK de-assertion does not wait the removal of the REQuest, but only the transfer completion. This patch retrieve the need of the alternative protocol through the device tree, and sets the protocol accordingly. Change-Id: I2c9fd6f33f3ad9a600449cbf02b9f29c88384618 Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/186668 Reviewed-by: CITOOLS <smet-aci-reviews@lists.codex.cro.st.com> Reviewed-by: Fabien DESSENNE <fabien.dessenne@st.com>
1 parent 3895884 commit 38078f0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/dma/stm32-dma.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#define STM32_DMA_SCR_PSIZE_GET(n) ((n & STM32_DMA_SCR_PSIZE_MASK) >> 11)
6363
#define STM32_DMA_SCR_DIR_MASK GENMASK(7, 6)
6464
#define STM32_DMA_SCR_DIR(n) ((n & 0x3) << 6)
65+
#define STM32_DMA_SCR_TRBUFF BIT(20) /* Bufferable transfer for USART/UART */
6566
#define STM32_DMA_SCR_CT BIT(19) /* Target in double buffer */
6667
#define STM32_DMA_SCR_DBM BIT(18) /* Double Buffer Mode */
6768
#define STM32_DMA_SCR_PINCOS BIT(15) /* Peripheral inc offset size */
@@ -143,6 +144,9 @@
143144
#define STM32_DMA_DIRECT_MODE_MASK BIT(2)
144145
#define STM32_DMA_DIRECT_MODE_GET(n) (((n) & STM32_DMA_DIRECT_MODE_MASK) \
145146
>> 2)
147+
#define STM32_DMA_ALT_ACK_MODE_MASK BIT(4)
148+
#define STM32_DMA_ALT_ACK_MODE_GET(n) (((n) & STM32_DMA_ALT_ACK_MODE_MASK) \
149+
>> 4)
146150
#define STM32_DMA_MDMA_CHAIN_FTR_MASK BIT(31)
147151
#define STM32_DMA_MDMA_CHAIN_FTR_GET(n) (((n) & STM32_DMA_MDMA_CHAIN_FTR_MASK) \
148152
>> 31)
@@ -1943,6 +1947,8 @@ static void stm32_dma_set_config(struct stm32_dma_chan *chan,
19431947
STM32_DMA_SRAM_GRANULARITY;
19441948
if (STM32_DMA_DIRECT_MODE_GET(cfg->features))
19451949
chan->threshold = STM32_DMA_FIFO_THRESHOLD_NONE;
1950+
if (STM32_DMA_ALT_ACK_MODE_GET(cfg->features))
1951+
chan->chan_reg.dma_scr |= STM32_DMA_SCR_TRBUFF;
19461952
}
19471953

19481954
static struct dma_chan *stm32_dma_of_xlate(struct of_phandle_args *dma_spec,

0 commit comments

Comments
 (0)