Add support for STM32 DMA
Subsystems (4)
v3 cover Add support for STM32 DMA
This patchset adds support for the STM32 DMA controller. This controller provides 8 channels dedicated to managing memory access request from one or more peripherals.
Each stream can have up to 8 requests in total.
Changes since v2:
- remove interrupt configuration management from DT
- remove FIFO configuration management from DT except threshold as it is very hard to handle it in the driver due to many possible combinations according to burst and bus width
- update DMA client message in DT documentation file
- specify the order to be used to set per-channel DMA interrupts in the DT
- remove unused enumerations for channel and request ids
- keep as soon as possible 80 lines char for more readability
- replace unsigned int by u32
- return error if burst is not supported in stm32_dma_get_burst()
- return error if bus_width is not supported in stm32_dma_get_width()
- add FIFO configuration management inside the driver except for threshold
- add interrupt configuration management inside the driver
- rework stm32_dma_chan_irq() to handle error interrupt in one way
- rework stm32_dma_set_xfer_param() to be easier to read
- update stm32_dma_tx_status() to always return status from dma_cookie_status()
- disable clk if we don't manage to stop the DMA channel during channel resources allocation
- set driver as built-in as DMA will be required by other built-in driver
Changes since v1:
- remove dmamux boolean as it is not needed
- replace dma by DMA in Kconfig
- add default return value in stm32_dma_get_width()
- add defalut return value in stm32_dma_get_burst()
- use lower case for constant hexadecimal values
M'boumba Cedric Madianga (4):
dt-bindings: Document the STM32 DMA bindings
dmaengine: Add STM32 DMA driver
ARM: dts: Add STM32 DMA support for STM32F429 MCU
ARM: configs: Add STM32 DMA support in STM32 defconfig
.../devicetree/bindings/dma/stm32-dma.txt | 82 ++ arch/arm/boot/dts/stm32f429.dtsi | 31 + arch/arm/configs/stm32_defconfig | 2 + drivers/dma/Kconfig | 12 + drivers/dma/Makefile | 1 + drivers/dma/stm32-dma.c | 1148 ++++++++++++++++++++ 6 files changed, 1276 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/stm32-dma.txt create mode 100644 drivers/dma/stm32-dma.c
Signature · 1 line
1.9.1
PATCH v3 1/4 dt-bindings: Document the STM32 DMA bindings
This patch adds documentation of device tree bindings for the STM32 dma controller.
--- .../devicetree/bindings/dma/stm32-dma.txt | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/stm32-dma.txt
Documentation/devicetree/bindings/dma/stm32-dma.txt new file +82 -0
@@ -0,0 +1,82 @@ +* STMicroelectronics STM32 DMA controller + +The STM32 DMA is a general-purpose direct memory access controller capable of +supporting 8 independent DMA channels. Each channel can have up to 8 requests. + +Required properties: +- compatible: Should be "st,stm32-dma" +- reg: Should contain DMA registers location and length. This should include + all of the per-channel registers. +- interrupts: Should contain all of the per-channel DMA interrupts ordering by + channel index. +- clocks: Should contain the input clock of the DMA instance. +- #dma-cells : Must be <4>. See DMA client paragraph for more details. + +Optional properties: +- resets: Reference to a reset controller asserting the DMA controller +- st,mem2mem: boolean; if defined, it indicates that the controller supports + memory-to-memory transfer + +Example: + + dma2: dma-controller at 40026400 { + compatible = "st,stm32-dma"; + reg = <0x40026400 0x400>; + interrupts = <56>, + <57>, + <58>, + <59>, + <60>, + <68>, + <69>, + <70>; + clocks = <&clk_hclk>; + #dma-cells = <4>; + st,mem2mem; + resets = <&rcc 150>; + }; + +* DMA client + +DMA clients connected to the STM32 DMA controller must use the format +described in the dma.txt file, using a five-cell specifier for each +channel: a phandle plus four integer cells. +The four cells in order are: + +1. The channel id +2. The request line number +3. A 32bit mask specifying the DMA channel configuration which are device + dependent: + -bit 9: Peripheral Increment Address + 0x0: no address increment between transfers + 0x1: increment address between transfers + -bit 10: Memory Increment Address + 0x0: no address increment between transfers + 0x1: increment address between transfers + -bit 15: Peripheral Increment Offset Size + 0x0: offset size is linked to the peripheral bus width + 0x1: offset size is fixed to 4 (32-bit alignment) + -bit 16-17: Priority level + 0x0: low + 0x1: medium + 0x2: high + 0x3: very high +5. A 32bit mask specifying the DMA FIFO threshold configuration which are device + dependent: + -bit 0-1: Fifo threshold + 0x0: 1/4 full FIFO + 0x1: 1/2 full FIFO + 0x2: 3/4 full FIFO + 0x3: full FIFO + +Example: + + usart1: serial at 40011000 { + compatible = "st,stm32-usart", "st,stm32-uart"; + reg = <0x40011000 0x400>; + interrupts = <37>; + clocks = <&clk_pclk2>; + dmas = <&dma2 2 4 0x10400 0x3>, + <&dma2 7 5 0x10200 0x3>; + dma-names = "rx", "tx"; + };
Signature · 1 line
1.9.1
PATCH v3 2/4 dmaengine: Add STM32 DMA driver
In reply to M'boumba Cedric MadiangaThis patch adds support for the STM32 DMA controller.
--- drivers/dma/Kconfig | 12 + drivers/dma/Makefile | 1 + drivers/dma/stm32-dma.c | 1148 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1161 insertions(+) create mode 100644 drivers/dma/stm32-dma.c
drivers/dma/Kconfig +12 -0
@@ -431,6 +431,18 @@ config STE_DMA40 help Support for ST-Ericsson DMA40 controller +config STM32_DMA + bool "STMicroelectronics STM32 DMA support" + depends on ARCH_STM32 + select DMA_ENGINE + select DMA_OF + select DMA_VIRTUAL_CHANNELS + help + Enable support for the on-chip DMA controller on STMicroelectronics + STM32 MCUs. + If you have a board based on such a MCU and wish to use DMA say Y or M + here. + config S3C24XX_DMAC tristate "Samsung S3C24XX DMA support" depends on ARCH_S3C24XX
drivers/dma/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_QCOM_BAM_DMA) += qcom_bam_dma.o obj-$(CONFIG_RENESAS_DMA) += sh/ obj-$(CONFIG_SIRF_DMA) += sirf-dma.o obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o +obj-$(CONFIG_STM32_DMA) += stm32-dma.o obj-$(CONFIG_S3C24XX_DMAC) += s3c24xx-dma.o obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o obj-$(CONFIG_TEGRA20_APB_DMA) += tegra20-apb-dma.o
drivers/dma/stm32-dma.c new file +1148 -0
1,148 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 3/4 ARM: dts: Add STM32 DMA support for STM32F429 MCU
In reply to M'boumba Cedric MadiangaThis patch adds STM32 DMA bindings for STM32F429.
--- arch/arm/boot/dts/stm32f429.dtsi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
arch/arm/boot/dts/stm32f429.dtsi +31 -0
@@ -174,6 +174,37 @@ reg = <0x40023800 0x400>; clocks = <&clk_hse>; }; + + dma1: dma-controller at 40026000 { + compatible = "st,stm32-dma"; + reg = <0x40026000 0x400>; + interrupts = <11>, + <12>, + <13>, + <14>, + <15>, + <16>, + <17>, + <47>; + clocks = <&rcc 0 21>; + #dma-cells = <4>; + }; + + dma2: dma-controller at 40026400 { + compatible = "st,stm32-dma"; + reg = <0x40026400 0x400>; + interrupts = <56>, + <57>, + <58>, + <59>, + <60>, + <68>, + <69>, + <70>; + clocks = <&rcc 0 22>; + #dma-cells = <4>; + st,mem2mem; + }; }; };
Signature · 1 line
1.9.1
PATCH v3 4/4 ARM: configs: Add STM32 DMA support in STM32 defconfig
In reply to M'boumba Cedric MadiangaThis patch adds STM32 DMA support in stm32_defconfig file
--- arch/arm/configs/stm32_defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/configs/stm32_defconfig +2 -0
@@ -54,6 +54,8 @@ CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y +CONFIG_DMADEVICES=y +CONFIG_STM32_DMA=y # CONFIG_FILE_LOCKING is not set # CONFIG_DNOTIFY is not set # CONFIG_INOTIFY_USER is not set
Signature · 1 line
1.9.1