On IMX8mp linux, how to enable SDMA for UART0 ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

On IMX8mp linux, how to enable SDMA for UART0 ?

830 Views
mahesh_hns
Contributor II

I was trying to enable DMA for UART0 (SDMA) on imx8mp linux 5.4.70.

When I built linux kernel with CONFIG_IMX_SDMA=y, I get this error during boot

 

[[ 0.712424] imx-sdma 30bd0000.dma-controller: Direct firmware load for imx/sdma/sdma-imx7d.bin failed with error -2
[ 0.712437] imx-sdma 30bd0000.dma-controller: Falling back to sysfs fallback for: imx/sdma/sdma-imx7d.bin
[ 0.713761] mxs-dma 33000000.dma-apbh: initialized

The firmware mx/sdma/sdma-imx7d.bin was indeed present at the location mentioned there. I wonder why I still got the error. 

So, how do I enable SDMA for UART0? And if once it is enabled, how do I know that SDMA has been enabled? Any sample logs? Any sysfs entries w.r.t sdma?

 

 

 

 

 

0 Kudos
5 Replies

766 Views
mahesh_hns
Contributor II

Thanks. Is there any other way of checking if DMA is enabled? reading register values through devmem2?

0 Kudos

744 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

yes, if you want to double check if dma is enabled for UART, you may read UARTx_UCRx registers, please refer to the i.MX8MP reference manual page 7341.

Best regards,
Aldo.

0 Kudos

816 Views
mahesh_hns
Contributor II

Some other threads mentioned it was due to the RFS not initialized by the the time the driver comes up, and hence the error. The suggested workaround was to build the driver as a module CONFIG_IMX_SDMA=m and load it early in the sequence. I saw that it was not automatically loading anyway. When I manually loaded the imx-sdma.ko file (kept in /lib/modules/kernel-<>/drivers/dma/) it loaded fine with the message 

[ 2179.476286] imx-sdma 30bd0000.dma-controller: loaded firmware 4.5

Even then I wasn't sure if the UART0 uses DMA at that point (as it is past the UART initialization). Guess I have to force reset UART which forces it to use DMA?

Any cleaner solution? Is it possible to CONFIG_IMX_SDMA=y and compile the firmware also in to the kernel image (with no RFS dependency) ?

0 Kudos

789 Views
mahesh_hns
Contributor II

Update: I pre-compiled the imx-sdma7.bin (from yocto generated RFS) using 

CONFIG_EXTRA_FIRMWARE="sdma-imx7d.bin"
CONFIG_EXTRA_FIRMWARE_DIR="lib/firmware"

And the boot messages have these

[ 0.713318] imx-sdma 30bd0000.dma-controller: loaded firmware 4.5

..........

[ 0.721005] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 0.722796] 30860000.serial: ttymxc0 at MMIO 0x30860000 (irq = 25, base_baud = 1500000) is a IMX
[ 0.723239] 30880000.serial: ttymxc2 at MMIO 0x30880000 (irq = 26, base_baud = 5000000) is a IMX
[ 0.723600] 30890000.serial: ttymxc1 at MMIO 0x30890000 (irq = 27, base_baud = 1500000) is a IMX
[ 1.694646] printk: console [ttymxc1] enabled

It looks like SDMA has firmware has been loaded successfully, but I don't see any other message on that. I am not sure if UART0 (ttymxc0) is using SDMA or not. Is there any way to find that?

The UART1 device tree have the following (entries in imx8mp.dtsi)

uart1 {

dmas = <&sdma1 22 4 0>, <&sdma1 23 4 0>;
dma-names = "rx", "tx";

..

}

How do I verify if the SDMA is enabled for ttymxc0 ? Any sysfs status checks?

0 Kudos

784 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello.

All you have done looks correct, regarding double checking if SDMA is enabled, then you may add some debug logs to the UART driver.

In UART driver, function dma_request_slave_channel() in imx_uart_dma_init() will return true when SDMA firmware is not loaded. You may add some log in UART driver to check when DMA is initialized.

Best regards,
Aldo.

0 Kudos