SPI slave mode(imx8mp)

Hi,

Our Setup:

Our Master device sends continuous data to Slave (imx8mp)
Our objective is to make imx8mp as SPI full duplex slave mode and try to read the continuous data coming from master

In order to do this , we need to configure the SPI parameter settings following below

  1. Mode: Full duplex slave
  2. Data first: MSB first
  3. Data bits : 8
  4. Clock polarity: Low
  5. Clock phase : Low

How can we do that?

Regards

Hi @Sudharshan,

Thanks for writing to Toradex community.

By default SPI is configured to operate in master mode. To get this in slave mode, you will need to configure spi bus in for slave mode using device tree modification.
Depending on what pins you are using you can modify spi node. Below is example for escspi1 node which is Verdin SPI_1

&ecspi1 {
    status = "okay";
    spi-slave;
    
    spidev: spidev@0 {
        compatible = "spidev";
        reg = <0>;
        spi-max-frequency = <1000000>;
        spi-cpha;
        spi-cpol;
    };
};

Additionally please do share complete OS details so that we can provide specific details.

Also check similar post below

Let me know if you have any queries.
Best Regards
Ritesh Kumar

Hi @ritesh.tx ,

FYI we on
torizon@verdin-imx8mp-14753765:~$ cat /etc/os-release
ID=torizon
NAME=“TorizonCore”
VERSION=“6.4.0+build.5 (kirkstone)”
VERSION_ID=6.4.0-build.5
PRETTY_NAME=“TorizonCore 6.4.0+build.5 (kirkstone)”
DISTRO_CODENAME=“kirkstone”
BUILD_ID=“5”
ANSI_COLOR=“1;34”
VARIANT=“Docker”
We are using pins 196, 198, 200, 202.
I’ll look into thread provided by you. Meanwhile,
Can you guide us to the page which talks about device tree modification. Is there a step-by-step guide for that on toradex documentation?
Also, a naive question but, is it possible to modify device tree without re-building complete kernel or OS?

Thanks and Regards

Hi @Sudharshan,

Certainly we can help you with documentation.
Please check below link

Above link will give all the information related to device tree and device tree overlay.

Exact steps on how to apply device tree with Torizon OS are as below:

Best Regards
Ritesh Kumar

Hi Ritesh,

What is the procedure to modify the pin configurations from ALT0 mode to ALT3 mode for pin 53 and 55?

I also tried to clone
$ git clone -b toradex_5.15-2.2.x-imx git://git.toradex.com/linux-toradex.git linux
$ git clone -b toradex_5.15-2.2.x-imx git://git.toradex.com/device-tree-overlays.git device-trees
for modifying and applying device tree overlay, but it seems this is not the correct path to repo. Can you provide the correct path and the branch.

Regards
Sudarshan

Hi @Sudharshan,

X1_53 is default used as I2C2_SDA and X1_55 is used for I2C2_SCL, by ALT3 I believe you wanted to use ECSPI1.

You need to first modify pinctrl for i2c2 and then implement pinctrl for spi.
Next use that pinctrl in spi node and same time disable i2c node also.

You can check this link for details to understand about iomux.
Here you can check exact pins are destination
https://git.toradex.com/cgit/linux-toradex.git/tree/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi?h=toradex_5.15-2.1.x-imx#n1227

Best Regards
Ritesh Kumar

1 Like