dmaengine: stm32-dma: add device_pause/device_resume support
authorAmelie Delaunay <amelie.delaunay@foss.st.com>
Thu, 5 May 2022 11:56:11 +0000 (13:56 +0200)
committerVinod Koul <vkoul@kernel.org>
Thu, 19 May 2022 18:13:41 +0000 (23:43 +0530)
commit099a9a94be0e1c7fa45410deb2bff640320c3819
tree61da8aaa1b8c3a7c6d0326e768bc5f568253ef91
parentbaa1424314f8e4bb5b266aaf9cc7fb7a9e65901b
dmaengine: stm32-dma: add device_pause/device_resume support

At any time, a DMA transfer can be suspended to be restarted later before
the end of the DMA transfer.

In order to restart from the point where the transfer was stopped,
DMA_SxNDTR has to be read after disabling the channel by clearing the EN
bit in DMA_SxCR register, to know the number of data items already
collected.
Peripheral and/or memory addresses have to be updated in order to adjust
the address pointers.
SxNDTR register has to be updated with the remaining number of data items
to be transferred (the value read when the channel was disabled).
Then the channel can be re-enabled to resume the transfer from the point
it was suspended.
If the channel was configured in circular or double-buffer mode, the
circular or double-buffer mode must be disabled before re-enabling the
channel to be able to reconfigure SxNDTR register and re-activate circular
or double-buffer mode on next Transfer Complete interrupt where channel
will be disabled by HW. This is due to the fact that on resume, re-writing
SxNDTR register value updates internal HW auto-reload data counter, and
then it truncates all next transfers after a pause/resume sequence.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20220505115611.38845-5-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/stm32-dma.c