SPI running on M7

Carrier Board : IVY Plus or Verdin Board
Board : IMX8MP
Linux : verdin-imx8mp-15290475 5.15.129-rt67-6.5.0-devel+git.6f8fd49366db #1 SMP PREEMPT_RT Fri Dec 22 11:15:52 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

I would like to enable the SPI on the M7.
Example code is running on the ECSPI2 base address.0x30830000u

Confirmed with the lInux that known SPI to Linux is
root@verdin-imx8mp-15290475:~# ls /sys/bus/platform/devices | grep -i spi
30820000.spi
30bb0000.spi

But I could not able to find the SPI2 on the schematic and when I send the data, i could not able to check the clock or MOSI line at any pins. thanks

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Verdin iMX8M Plus M7 SPI Configuration

Understanding SPI Resource Allocation

The issue you’re experiencing is related to resource allocation between the Cortex-A53 (Linux) and Cortex-M7 cores. When using SPI on the M7, you need to ensure the SPI interface is properly disabled in Linux and configured for M7 use(1).

Device Tree Configuration Required

To use SPI on the M7 core, you must first disable the corresponding SPI interface in the Linux device tree. Based on the Verdin iMX8M Plus development documentation, you need to modify the device tree to prevent resource conflicts(1).

The device tree configuration requires creating an imx8mp-verdin-rpmsg.dtsi file with proper memory reservations(1):

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
* Copyright 2022 Toradex
*/

#include <dt-bindings/clock/imx8mp-clock.h>
// Enable RPMSG support 

/ {
 reserved-memory {

 #address-cells = <2>;
 #size-cells = <2>;
 ranges;

 /* use linux config instead */
 /delete-node/ linux,cma;

 /* Allocate 16MB DDR RAM memory for cortex M -> check the ram drr linker file for details */
 m7_reserved: m7@0x80000000 {
 no-map;
 reg = <0 0x80000000 0 0x1000000>;
 };

 /* Allocate resource table from Cortex-M7 -> check copyResourceTable inside rsc_table.c for details */
 rsc_table: rsc_table@550ff000 {
 reg = <0 0x550ff000 0 0x1000>;
 no-map;
 };

 /* VDEV0_VRING_BASE 0 comes from FreeRTOS rsc_table.c */
 vdev0vring0: vdev0vring0@55000000 {
 reg = <0 0x55000000 0 0x8000>;
 no-map;
 };

 /* VDEV0_VRING_BASE 1 comes from FreeRTOS rsc_table.c */
 vdev0vring1: vdev0vring1@55008000 {
 reg = <0 0x55008000 0 0x8000>;
 no-map;
 };

 /* Buffers to use with RPMSG */
 vdevbuffer: vdevbuffer@55400000 {
 compatible = "shared-dma-pool";
 reg = <0 0x55400000 0 0x100000>;
 no-map;
 };

 };

 imx8mp-cm7 {
 compatible = "fsl,imx8mp-cm7";
 rsc-da = <0x55000000>;
 clocks = <&clk IMX8MP_CLK_M7_DIV>;
 mbox-names = "tx", "rx", "rxdb";
 mboxes = <&mu 0 1
 &mu 1 1
 &mu 3 1>;
 memory-region = <&vdev0vring0>, <&vdev0vring1>, <&vdevbuffer>, <&rsc_table>, <&m7_reserved>;
 status = "okay";
 };
};

(1)

Pin Configuration for M7

You’ll need to configure the specific pins for SPI use on the M7. The pin configuration must be done using IOMUXC functions in your M7 firmware, similar to the GPIO interrupt example(2):

// Configure SPI pins using IOMUXC functions
IOMUXC_SetPinMux(IOMUXC_[SPI_PIN]_[FUNCTION], 0U);
IOMUXC_SetPinConfig(IOMUXC_[SPI_PIN]_[FUNCTION],
                    IOMUXC_SW_PAD_CTL_PAD_PUE_MASK |
                    IOMUXC_SW_PAD_CTL_PAD_HYS_MASK |
                    IOMUXC_SW_PAD_CTL_PAD_PE_MASK);

(2)

Verdin SPI Pin Mapping

According to the SPI documentation, the Verdin family provides one SPI interface in the “Always Compatible” category(3):

SODIMM Pin Signal Name Description
196 SPI_1_CLK SPI Serial Clock (SCK)
198 SPI_1_MISO SPI Master Input, Slave Output
200 SPI_1_MOSI SPI Master Output, Slave Input
202 SPI_1_CS SPI Chip Select

(3)

Troubleshooting Steps

  1. Disable SPI in Linux: You need to disable the SPI interface in the Linux device tree to prevent conflicts
  2. Configure M7 pins: Use the IOMUXC functions to properly configure the pins for SPI functionality
  3. Check pin mapping: Ensure you’re using the correct SODIMM pins (196, 198, 200, 202) for SPI signals
  4. Verify M7 firmware: Make sure your M7 firmware is properly loaded and running

The key issue is that both Linux and M7 cannot use the same SPI controller simultaneously. You must explicitly disable it in Linux and configure it for M7 use.

Best regards, Toradex AI Assistant.

Hi @ramesh.rajagopal , Ivy is for production purpose and all interfaces are designed as-it-is. ECSPI2_MOSI is available on SOIDMM74/93 and SODIMM 152(only available at SODIMM connector on modules without Wi-Fi). On Ivy, SDOMM 74 is routed to SD1, and SODIMM 93 is routed to I2C_4 buses. SOIDMM 152 is not exported at all. We suggest Verdin Development Board for evaluation, especially M7 development. You may need to test other interfaces from M7 core and they are note accessible on Ivy.

Thanks for your reply,

I managed to get the SPI signals from the SPI1 using the Development board.

Now I am facing new issue, where I want the Clock polarity to Active high, but I could not able to set it even

config->polarity              = kECSPI_PolarityActiveHigh;       /*!< Clock polarity */
config->phase                 = kECSPI_ClockPhaseFirstEdge;      /*!< clock phase */

When I changing the mode, it does not reflect it to the waveform.
Thanks
Ramesh.

Hi @ramesh.rajagopal , can only polarity and phase not be set ? Did you observe bit shifted on SPI1_MOSI signal?

Hi Benjamin,

Sorry for the late reply.

I noted the bit shift, this problem resolved.

Thanks, Ramesh.