4.3.2. 参数配置

4.3.2.1. 内核配置

参考快速入门 - 编译概述 - Kernel配置,进入kernel的功能配置,按如下选择:

Linux
    Device Drivers
        [*] DMA Engine support
            <*>   ZX SoCs DMA support

4.3.2.2. DTS 参数配置

4.3.2.2.1. M4 配置

common/m4.dtsi中的参数配置:

dma: dma-controller@10000000 {
    compatible = "zx,aic-dma-v1.0";
    reg = <0x0 0x10000000 0x0 0x1000>;
    interrupts-extended = <&plic0 32 IRQ_TYPE_LEVEL_HIGH>;
    clocks = <&cmu CLK_DMA>;
    resets = <&rst RESET_DMA>;
    #dma-cells = <1>;
    status = "okay";
};

4.3.2.2.2. 引用DMA通道

使用DMA进行数据传输的模块,可以通过DTS来配置。以SPI为例,要配置RX、TX对应的DMA端口号(DRQ Port):

spi0: spi@10400000 {
    compatible = "zx,aic-spi-v1.0";
    reg = <0x10400000 0x1000>;
    interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
    clocks = <&cmu CLK_SPI0>;
    resets = <&rst RESET_SPI0>;
    dmas = <&dma DMA_SPI0>, <&dma DMA_SPI0>;
    dma-names = "rx", "tx";
    #address-cells = <1>;
    #size-cells = <0>;
    spi-max-frequency = <24000000>;
};

其中端口号 DMA_SPI0 的定义见 U-Boot中代码 include/dt-bindings/dma/m4-dma.h

#define DMA_SRAM   0
#define DMA_DRAM   1
#define DMA_SPI0   10
#define DMA_SPI1   11
#define DMA_I2S0   12
#define DMA_I2S1   13
#define DMA_CODEC  14
#define DMA_UART0  16
#define DMA_UART1  17
#define DMA_UART2  18
#define DMA_UART3  19
#define DMA_UART4  20
#define DMA_UART5  21
#define DMA_UART6  22
#define DMA_UART7  23

备注

DMA端口号的宏定义仅在DTS编译过程中用到,我们的DTS编译过程是放在U-Boot编译中,所以将这些宏定义放在U-Boot。