Skip to contentSkip to conversation

Add support for STM32 DMA

PATCH Applied M'boumba Cedric Madianga 4 participants 13 messages Oct 16, 2015 – Dec 1, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v4 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 v3:
- Fix regression introduced in v3 during request channel
- Fix regression introduced in v3 for cyclic mode dma transfer
- update interrupt description in DT
- remove half transfer interrupt management as client callback as to be called only for complete transfer

Changes since v2:
- remove interrupt configuration management from DT (Mark)
- 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 (Mark)
- update DMA client message in DT documentation file
- specify the order to be used to set per-channel DMA interrupts in the DT (Mark)
- remove unused enumerations for channel and request ids (Daniel)
- keep as soon as possible 80 lines char for more readability (Vinod)
- replace unsigned int by u32 (Vinod)
- use GFP_NOWAIT instead of GFP_ATOMIC during dma descriptors allocation (Vinod)
- return error if burst is not supported in stm32_dma_get_burst() (Vinod)
- return error if bus_width is not supported in stm32_dma_get_width() (Vinod)
- add FIFO configuration management inside the driver except for threshold
- add interrupt configuration management inside the driver (Mark)
- rework stm32_dma_chan_irq() to handle error interrupt in one way (Vinod)
- rework stm32_dma_set_xfer_param() to be easier to read
- update stm32_dma_tx_status() to always return status from dma_cookie_status() (Vinod)
- disable clk if we don't manage to stop the DMA channel during channel resources allocation (Daniel)
- 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 (Maxime)
- 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 (Maxime)

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                            | 1141 ++++++++++++++++++++
 6 files changed, 1269 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
#1 lore raw

PATCH v4 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
new file mode 100644
index 0000000..70cd13f
@@ -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 in
+  ascending order with respect to the DMA 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
Acked-by on v4 1/4
#2 lore raw

Re: [PATCH v4 1/4] dt-bindings: Document the STM32 DMA bindings

Quoted 6 lines · M'boumba Cedric Madianga

This patch adds documentation of device tree bindings for the STM32 dma controller.

---
 .../devicetree/bindings/dma/stm32-dma.txt          | 82 ++++++++++++++++++++++
Quoted 94 lines
 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 -1
new file mode 100644
index 0000000..70cd13f
@@ -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 in
+  ascending order with respect to the DMA 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";
+       };
--

1.9.1

Applied
#3 lore raw

Re: [PATCH v4 1/4] dt-bindings: Document the STM32 DMA bindings

In reply to M'boumba Cedric Madianga
Quoted 3 lines · M'boumba Cedric Madianga

This patch adds documentation of device tree bindings for the STM32 dma controller.

Applied, thanks

Signature · 1 line
~Vinod
#4 lore raw

PATCH v4 2/4 dmaengine: Add STM32 DMA driver

In reply to M'boumba Cedric Madianga

This patch adds support for the STM32 DMA controller.

---
 drivers/dma/Kconfig     |   12 +
 drivers/dma/Makefile    |    1 +
 drivers/dma/stm32-dma.c | 1141 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1154 insertions(+)
 create mode 100644 drivers/dma/stm32-dma.c
drivers/dma/Kconfig +12 -0
index af81a7a..b1a071b 100644
@@ -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
index ef9c099..2dd0a067 100644
@@ -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 +1141 -0

1,141 lines not on this page · raw message

Signature · 1 line
1.9.1
Applied
#5 lore raw

Re: [PATCH v4 2/4] dmaengine: Add STM32 DMA driver

Quoted 2 lines · M'boumba Cedric Madianga

This patch adds support for the STM32 DMA controller.

Applied, thanks

Signature · 1 line
~Vinod
#6 lore raw

PATCH v4 3/4 ARM: dts: Add STM32 DMA support for STM32F429 MCU

In reply to M'boumba Cedric Madianga

This 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
index d78a481..037eb29 100644
@@ -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
#7 lore raw

Re: [PATCH v4 3/4] ARM: dts: Add STM32 DMA support for STM32F429 MCU

Quoted 1 line · M'boumba Cedric Madianga

This patch adds STM32 DMA bindings for STM32F429.

I need an ACK from ARM folks on this one, and I suspect this might need rebase on 4.4-rc1

Quoted 51 lines
---
 arch/arm/boot/dts/stm32f429.dtsi | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
arch/arm/boot/dts/stm32f429.dtsi +31 -0
index d78a481..037eb29 100644
@@ -174,6 +174,37 @@
 			reg = <0x40023800 0x400>;
 			clocks = <&clk_hse>;
 		};
+
+		dma1: dma-controller@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@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
Signature · 1 line
~Vinod
#8 lore raw

Re: [PATCH v4 3/4] ARM: dts: Add STM32 DMA support for STM32F429 MCU

Hi Vinod,

Quoted 6 lines · Vinod Koul
Quoted 1 line · M'boumba Cedric Madianga

This patch adds STM32 DMA bindings for STM32F429.

I need an ACK from ARM folks on this one, and I suspect this might need rebase on 4.4-rc1

Maxime will take this patch and the other one about defconfig as he is the maintainer of STM32 machine.

I think you don't need to take it into account..

BR,
Cedric

Quoted 8 lines

Review

Quoted 8 lines
---
 arch/arm/boot/dts/stm32f429.dtsi | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
(quoted diff) +0 -0

b/arch/arm/boot/dts/stm32f429.dtsi

Quoted 47 lines
Quoted 42 lines

index d78a481..037eb29 100644

arch/arm/boot/dts/stm32f429.dtsi +31 -1
@@ -174,6 +174,37 @@
                      reg = <0x40023800 0x400>;
                      clocks = <&clk_hse>;
              };
+
+             dma1: dma-controller@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@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;
+             };
      };
 };
 
--
Quoted 2 lines

1.9.1

--
~Vinod

maintainer Applied
#9 lore raw

Re: [PATCH v4 3/4] ARM: dts: Add STM32 DMA support for STM32F429 MCU

In reply to M'boumba Cedric Madianga

2015-10-16 15:59 GMT+02:00 M'boumba Cedric Madianga <[email protected]>:

Quoted 6 lines

This patch adds STM32 DMA bindings for STM32F429.

---
 arch/arm/boot/dts/stm32f429.dtsi | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Applied to STM32 DT branch for v4.5.

Thanks!
Maxime

#10 lore raw

PATCH v4 4/4 ARM: configs: Add STM32 DMA support in STM32 defconfig

In reply to M'boumba Cedric Madianga

This 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
index 4725fab..ec52505 100644
@@ -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
#11 lore raw

Re: [PATCH v4 4/4] ARM: configs: Add STM32 DMA support in STM32 defconfig

Quoted 1 line · M'boumba Cedric Madianga

This patch adds STM32 DMA support in stm32_defconfig file

This seems okay, so went ahead and applied

Signature · 1 line
~Vinod
#12 lore raw
In reply to M'boumba Cedric Madianga

Hi Vinod,

Do you have any further comments or suggestions on this serie ?

BR,
Cedric

2015-10-16 15:59 GMT+02:00 M'boumba Cedric Madianga <[email protected]>:

Quoted 62 lines

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 v3:
- Fix regression introduced in v3 during request channel
- Fix regression introduced in v3 for cyclic mode dma transfer
- update interrupt description in DT
- remove half transfer interrupt management as client callback as to be called only for complete transfer

Changes since v2:
- remove interrupt configuration management from DT (Mark)
- 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 (Mark)
- update DMA client message in DT documentation file
- specify the order to be used to set per-channel DMA interrupts in the DT (Mark)
- remove unused enumerations for channel and request ids (Daniel)
- keep as soon as possible 80 lines char for more readability (Vinod)
- replace unsigned int by u32 (Vinod)
- use GFP_NOWAIT instead of GFP_ATOMIC during dma descriptors allocation (Vinod)
- return error if burst is not supported in stm32_dma_get_burst() (Vinod)
- return error if bus_width is not supported in stm32_dma_get_width() (Vinod)
- add FIFO configuration management inside the driver except for threshold
- add interrupt configuration management inside the driver (Mark)
- rework stm32_dma_chan_irq() to handle error interrupt in one way (Vinod)
- rework stm32_dma_set_xfer_param() to be easier to read
- update stm32_dma_tx_status() to always return status from dma_cookie_status() (Vinod)
- disable clk if we don't manage to stop the DMA channel during channel resources allocation (Daniel)
- 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 (Maxime)
- 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 (Maxime)

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                            | 1141 ++++++++++++++++++++
 6 files changed, 1269 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/stm32-dma.txt
 create mode 100644 drivers/dma/stm32-dma.c

--
1.9.1