DMA Driver

DMA Block Diagram

The following figure shows the block diagram of the DMA engine.
Figure 1. Block Diagram
The DMA framework is mainly divided into the following 3 parts, the DMA provider, the DMA consumer and the DMA core. The following list provides some examples from the DMA consumer's perspective:
  • ALSA Player: Advanced Linux Sound Architecture (ALSA) provides audio and MIDI functionality to the Linux operating system. The ALSA player communicates with the DMA core via the ALSA driver.
  • SPI Dev Test: The SPI development test application communicates with the DMA core via the SPI driver.
  • Other Applications. The other applications communicate with the DMA core via their associated driver programs.

From the DMA provider's perspective, the DMA Core provides public interfaces for the DMA consumers to access the hardware DMA channel.

DMA Device Tree Source Code

The following code block shows the device tree source code of the DMA controller.
     dma: dma-controller@16050000 {
compatible = "starfive,jh7110-dma", "snps,axi-dma-1.01a";
reg = <0x0 0x16050000 0x0 0x10000>;
clocks = <&clkgen JH7110_DMA1P_CLK_AXI>,
        <&clkgen JH7110_DMA1P_CLK_AHB>; 
clock-names = "core-clk", "cfgr-clk";
resets = <&rstgen RSTN_U0_DW_DMA1P_AXI>,
          <&rstgen RSTN_U0_DW_DMA1P_AHB>; 
reset-names = "rst-axi", "rst-ahb";
interrupts = <73>; 
dma-cells = <2>; 
dma-channels = <4>; 
snps,dma-masters = <1>; 
snps,data-width = <3>; 
snps,num-hs-if = <56>; 
snps,block-size = <65536 65536 65536 65536>;
snps,priority = <0 1 2 3>; 
snps,axi-max-burst-len = <16>; 
status = "disabled"; 
};
The following table describes the DT parameters:
Table 1. DMA DT Parameters
Parameter Description
compatible Compatibility information, used to associate the driver and its target device
reg Register base address "0x16050000" and range "0x10000".
clocks The clocks used by the DMA module
clock-names The names of the clocks used by the DMA module
resets The reset signals used by the DMA module
reset_names The names of the reset signals
interrupts Hardware interrupt ID
dma-cells The field is used to configure DMA cells via DTS configuration.
dma-channels The supported DMA channels
dma-masters The supported AXI master interfaces.
data-width The field is used to configure data bus width (Unit: Byte). The default value is 3.
num-hs-if The total count of hardware handshakes, maximum 56 handshakes
priority The priorities of the 4 channels mentioned in the dma-channels field.
axi-max-burst-len The maximum data length allowed in one single transmission
status

The work status of the DMA module. To enable the module, set this bit to okay. To disable the module, set this bit to disabled.

Source Code Structure

The following code block shows the source code tree structure of the DMA engine.
-- drivers
-- dma
-- dw-axi-dmac
   |-- Makefile
   |-- dw-axi-dmac-platform.c
   |-- dw-axi-dmac.h
-- dw-axi-dmac-starfive
   |-- Makefile
   |-- dw-axi-dmac-starfive-misc.c
   |-- starfive_dmaengine_memcpy.c