• Amelie Delaunay's avatar
    dmaengine: stm32-dma: add device_pause/device_resume support · 099a9a94
    Amelie Delaunay authored
    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: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
    Link: https://lore.kernel.org/r/20220505115611.38845-5-amelie.delaunay@foss.st.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
    099a9a94
stm32-dma.c 49.6 KB