Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: dma: stm32: bdma support for H7 #53184

Merged
merged 8 commits into from
Mar 1, 2023

Conversation

heinwessels
Copy link
Contributor

Implement STM32H7 BDMA driver and integrate into dmamux

Co-authored-by: Jeroen van Dooren jeroen.van.dooren@nobleo.nl
Signed-off-by: Hein Wessels heinwessels93@gmail.com

@heinwessels heinwessels marked this pull request as draft December 19, 2022 09:39
@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding platform: STM32 ST Micro STM32 area: DMA Direct Memory Access labels Dec 19, 2022
@heinwessels heinwessels force-pushed the stm32-bdma branch 5 times, most recently from 90557df to af2d1ba Compare December 19, 2022 11:33
@heinwessels heinwessels marked this pull request as ready for review December 19, 2022 11:33
@heinwessels
Copy link
Contributor Author

This functionality is currently being verified using samples/drivers/adc in combination with #52965, with the following additional changes:

samples/drivers/adc/src/main.c

__in_section(shared_sram4, adc3,
	     dma_ds) static int16_t buffer[ARRAY_SIZE(adc_channels)] __aligned(32);

samples/drivers/adc/nucleo_h743zi.overlay

#include <zephyr/dt-bindings/adc/adc.h>

/ {
	zephyr,user {
		/*
		 * Note: Data in ADC results buffer will not be in the order
		 * that they are defined here, but as channels selection is done
		 * by a bitmask, they will be sorted instead in a way that
		 * lowest channel number result is on lowest buffer address
		 */
		io-channels = <&adc3 1>, <&adc3 2>;
	};
};

&adc3 {
	dmas = < &dmamux2 0 17 0x2C80>;
	dma-names = "dmamux";

	#address-cells = <1>;
	#size-cells = <0>;

	channel@1 {
		reg = <1>;
		zephyr,gain = "ADC_GAIN_1";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <12>;
	};

	channel@2 {
		reg = <2>;
		zephyr,gain = "ADC_GAIN_1";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <12>;
	};
};

&bdma1 {
	status="okay";
};

&dmamux2 {
	status="okay";
};

@heinwessels heinwessels force-pushed the stm32-bdma branch 5 times, most recently from 07bbcdb to 0feabb8 Compare January 2, 2023 08:27
@FRASTM
Copy link
Collaborator

FRASTM commented Jan 4, 2023

Do you also have tests/drivers/dma/loop_transfer and tests/drivers/dma/chan_blen_transfer PASSED with bdma on any stm32h7 board ?

@heinwessels
Copy link
Contributor Author

Do you also have tests/drivers/dma/loop_transfer and tests/drivers/dma/chan_blen_transfer PASSED with bdma on any stm32h7 board ?

@FRASTM not yet, wasn't sure about them. I will add tests to a seperate commit in this PR as well. Thanks!

@heinwessels heinwessels force-pushed the stm32-bdma branch 2 times, most recently from 65576bd to c2633ee Compare January 6, 2023 07:13
@heinwessels
Copy link
Contributor Author

Do you also have tests/drivers/dma/loop_transfer and tests/drivers/dma/chan_blen_transfer PASSED with bdma on any stm32h7 board ?

Tested, and both tests run successfully. However, both already have an DMA test for the nucleo_h743zi for dmamux1, which means I can't add another test for dmamux2. The test only supports one dma. I'm happy to expand the testing to support multiple dma's if I can pack it into this PR (with specific commits of course).

@heinwessels heinwessels force-pushed the stm32-bdma branch 3 times, most recently from 7e1ae7e to d2a31b8 Compare February 27, 2023 14:46
hakehuang
hakehuang previously approved these changes Feb 28, 2023
Copy link
Collaborator

@hakehuang hakehuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all DMA regression tested on NXP FRDM_K64F platfrom. no issues found

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some last comments.
Also, my request about splitting commits impacting dmamux still stands

@@ -16,3 +16,12 @@ SECTION_DATA_PROLOGUE(eth_stm32,(NOLOAD),)
} GROUP_DATA_LINK_IN(LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram3)), LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram3)))

#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram4), okay)
SECTION_PROLOGUE (sram4, ABSOLUTE(DT_REG_ADDR(DT_NODELABEL(sram4))) (NOLOAD),)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When adding the section for the SRAM4 to map BDMA buffers, are the clock and power already present to supply the D3 domain ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean? Adding this linker section will not change the order in SRAM sections or this driver is initialized. And the first time the BDMA knows about SRAM4 is during INIT_LEVEL_APPLICATION, and by then everything is obviously started up as expected.

Implement STM32H7 BDMA driver.

Co-authored-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
@heinwessels heinwessels force-pushed the stm32-bdma branch 3 times, most recently from c4ac5d0 to 7875ce8 Compare February 28, 2023 14:53
Wrap calls to DMA drivers through fops to allow
different dmamuxes to point to different types of
dma with different function calls.

In preperation to add support for BDMA and DMAMUX2.

Co-authored-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
heinwessels and others added 6 commits February 28, 2023 16:24
Extends dmamux driver to support DMAMUX 2,
which supports the BDMA on STM32H7 devices.

Co-authored-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
The dma-requests specified for dmamux is changed to
the correct number of 107. This can be found in the
Reference Manual RM0455 Section 17.1.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
Some devices contain multiple dmas

which requires multiple tests

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
Add DMA unit tests for BDMA driver.

Also requires adding additional kconfig options to allocate
the memory buffers in a specific SRAM section, because
the BDMA only has access to SRAM4.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
Some devices contain multiple dmas

which requires multiple tests

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
Add unit tests for BDMA driver.

Also requires adding additional kconfig options to allocate
the memory buffers in a specific SRAM section, because
the BDMA only has access to SRAM4.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
@carlescufi carlescufi merged commit 6a5a253 into zephyrproject-rtos:main Mar 1, 2023
@heinwessels heinwessels deleted the stm32-bdma branch March 21, 2023 08:07
heinwessels added a commit to fancom/zephyr that referenced this pull request Mar 23, 2023
In zephyrproject-rtos#53184 a linker section for SRAM4 was added because it's
required for use with the STM32H7 BDMA. Now in zephyrproject-rtos#52965 support
was added for the ADC DMA which expects a similar linker section
which is non-cachable, but is limited to use SRAM4 to place it's
buffers. This commit gives the user more flexibility to use any
SRAM region to place buffers to use with ADC DMA.

The region SRAM0 isn't supported because it doesn't have the
"zephyr,memory-region" compatibility required to turn it into
a non-cacheable region, meaning it doesn't fit the mentioned
use case.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: DMA Direct Memory Access platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants