Enable DMA support on flexcom - SAMA5D27-SOM1

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

CleberPeter
Location: Brazil
Posts: 16
Joined: Tue May 14, 2019 7:57 pm

Enable DMA support on flexcom - SAMA5D27-SOM1

Fri May 15, 2020 4:56 pm

I'm using a custom board with SAMA5D27-SOM1 and trying enable DMA support for a flexcom_1 in usart mode.

Below is an excerpt from my .dts file, which was created based on: https://www.kernel.org/doc/Documentatio ... usart.txt
and https://www.kernel.org/doc/Documentatio ... lexcom.txt

Code: Select all


#include "at91-sama5d27_som1.dtsi"
#include <dt-bindings/mfd/atmel-flexcom.h>
ahb {
	...
	
	apb {
	
	...
	
		flx1: flexcom@f8038000 {
				atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_USART>;
				status = "okay";

				f_uart2: serial@200 {
					compatible = "atmel,at91sam9260-usart";
					reg = <0x200 0x200>;
					interrupts = <20 IRQ_TYPE_LEVEL_HIGH 7>;
					clocks = <&flx1_clk>;
					clock-names = "usart";
					atmel,use-dma-rx;
					atmel,use-dma-tx;
					dmas = <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(31))>,
				      	       <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(32))>;
					dma-names = "tx", "rx";
					pinctrl-names = "default";
					pinctrl-0 = <&pinctrl_uart2>;
					atmel,fifo-size = <32>;

					status = "okay";
				};
			};
			
			...
			
			pinctrl@fc038000 {
			
				pinctrl_uart2: uart2 {
					pinmux = <PIN_PA23__FLEXCOM1_IO1>,
						 <PIN_PA24__FLEXCOM1_IO0>;
					bias-disable;
				};
			};
			...
		};
	};
};

however when I try to send data through the peripheral the terminal hangs on the command execution for 30s and no data is sent. I activated the debug in the driver atme_serial.c. Below is the execution of the command:

Code: Select all

echo 1 > /dev/ttyS1
[ 1580.920000 ] atmel_usart_serial atmel_usart_serial.1.auto: using dma0cha7 for rx DMA transfers
[ 1580.920000 ] atmel_usart_serial atmel_usart_serial.1.auto: atmel_prepare_rx_dma: mapped 4096@c7dbf000 to 0x27dbf000
[ 1580.920000 ] atmel_usart_serial atmel_usart_serial.1.auto: using dma0cha8 for tx DMA transfers
[ 1580.920000 ] atmel_usart_serial atmel_usart_serial.1.auto: atmel_prepare_tx_dma: mapped 4096@c6731000 to 0x26731000
30 seconds after the execution of the command is ended. 
During the execution of the command the status of the tx pin is high, at any other time it is low.

The choice for AT91_XDMAC_DT_PERID (31) and AT91_XDMAC_DT_PERID (32) is due to the fact that they are originally mapped to the i2s0 peripheral (according to sama5d2.dtsi), however it will not be used in my final application. I also tried to use AT91_XDMAC_DT_PERID (0) and AT91_XDMAC_DT_PERID (1) (i2c0), but I got the same result.

when I do not assign any DMA channels, the peripheral works perfectly.

Does anyone have any idea what might be wrong?
CleberPeter
Location: Brazil
Posts: 16
Joined: Tue May 14, 2019 7:57 pm

Re: Enable DMA support on flexcom - SAMA5D27-SOM1

Fri May 15, 2020 7:24 pm

update.

property removed atmel,fifo-size, same effect.

when i use:

Code: Select all

dmas = <0>, <0>;
i receive:

Code: Select all

echo 1 > /dev/ttyS1
[ 1580.920000 ] atmel_usart_serial atmel_usart_serial.1.auto: RX channel not available, switch to pio
[ 1580.920000 ] atmel_usart_serial atmel_usart_serial.1.auto: TX channel not available, switch to pio
30 seconds after the execution of the command is ended.
but there are dma channels available:

Code: Select all

cat /sys/class/dma/dma0chan8/in_use
0
blue_z
Location: USA
Posts: 2079
Joined: Thu Apr 19, 2007 10:15 pm

Re: Enable DMA support on flexcom - SAMA5D27-SOM1

Sun May 17, 2020 1:31 am

CleberPeter wrote: Below is an excerpt from my .dts file, which was created based on: https://www.kernel.org/doc/Documentatio ... usart.txt and https://www.kernel.org/doc/Documentatio ... lexcom.txt
You neglect to mention which Linux kernel version you are using.
Unless you are using the mainline top-of-tree, then those documentation files may not be accurate for the kernel version you are using.
Stated in the kernel source:

Code: Select all

Device Tree files and Device Tree bindings that apply to AT91 SoCs and boards are
considered as "Unstable". To be completely clear, any at91 binding can change at
any time. So, be sure to use a Device Tree Binary and a Kernel Image generated from
the same source tree.


CleberPeter wrote: when I do not assign any DMA channels, the peripheral works perfectly.
Which implies that all but the DMA properties are correct in your DT.
Therefore the salient documentation to reference is Documentation/devicetree/bindings/dma/atmel-xdma.txt.

CleberPeter wrote: The choice for AT91_XDMAC_DT_PERID (31) and AT91_XDMAC_DT_PERID (32) is due to the fact that they are originally mapped to the i2s0 peripheral (according to sama5d2.dtsi), however it will not be used in my final application. I also tried to use AT91_XDMAC_DT_PERID (0) and AT91_XDMAC_DT_PERID (1) (i2c0), but I got the same result.
Your "choices" seem to indicate that you are confusing the PERIDs, or "peripheral identifiers", with a multiplexing capability similar to PIO pins.
In the SoC datasheet these PERIDs are called DMA channel "interface numbers" which designate a specific instance of a peripheral and a transfer function (either transmit or receive).
The PERID is a hardwired number, and therefore is not configurable or redefinable.
Note that the SoC datasheet also describes a set of peripheral identifiers for the SoC that are unrelated to these PERIDs for DMA channels.

The PERIDs for FLEXCOM1 are 13 (tx) and 14 (rx) according to tables 37-2 and 37-3 of the SAMA5D2 datasheet.

Regards
CleberPeter
Location: Brazil
Posts: 16
Joined: Tue May 14, 2019 7:57 pm

Re: Enable DMA support on flexcom - SAMA5D27-SOM1

Wed May 27, 2020 4:08 pm

Thank you very much for the prompt reply.

Mapping the DMA channels according to the peripheral interface numbers, see tables 37-2 and 37-3 of the SAMA5D2 datasheet revision DS60001476D - 02/2020.

It works perfectly.

Mapping of FLEXCOM1 DMA channels:

Code: Select all

atmel,use-dma-rx;
atmel,use-dma-tx;
dmas = <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(13))>,
      	       <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(14))>;
dma-names = "tx", "rx";

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 4 guests