DMA 配置
26 Nov 2024
Read time: 2 minute(s)
DMA 包含以下配置内容:
- 内核配置。在 Luban 根目录下执行 make kernel-menuconfig,进入 kernel 的功能配置,按如下选择:
Linux Device Drivers [*] DMA Engine support <*> ArtInChip SoCs DMA support
- DTS 参数配置。
- D211 配置common/d211.dtsi 中的参数配置:
dma: dma-controller@10000000 { compatible = "artinchip,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"; };
- 引用 DMA 通道。使用 DMA 进行数据传输的模块,可以通过 DTS 来配置。以 SPI 为例,要配置 RX、TX 对应的 DMA 端口号(DRQ Port):
spi0: spi@10400000 { compatible = "artinchip,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/d211-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 阶段。
- D211 配置