How to configure SPI1 as a slave?

Hi teams

I want to configure SPI1 as a slave device in Xavier. The current configuration is shown in the figure below. How should I modify it

Add below for slave mode.

compatible = “nvidia,tegra186-spi-slave”;

hi ShaneCCC
Thanks to your reply
I have modifyed the compatible to “nvidia,tegra186-spi-slave”, bulid and flash the image, but the device node “/dev/spidev0.0” and “/dev/spidev0.1” ware disappeared. Is there anything else that should be modified?

Did you add it to the device tree?

Hi ShaneCCC
It’s my bad, I had replace compatible = “spidev” to compatible = “nvidia,tegra186-spi-slave”, so there is no device node. dose the spidev_test can be test slave mode?

You can configure one SPI control as slave and have loopback connect to another master SPI to test it.

In slave and master mode, what’s the correct value of pinmux, and where is the reference documentation for setting the pinmux? could you tell me, Thanks

When execute spidev_test on slave mode, it tips “Can’t send spi message: Invalid argument”, The error location corresponding to the source code is show in follow figure below.


and dmesg print some fault message
[ 2860.180998] spi-tegra124-slave 3210000.spi: Tx is not supported in mode 0
[ 2860.181231] spi-tegra124-slave 3210000.spi: spi can not start transfer, err -22
[ 2860.181454] spi_master spi0: failed to transfer one message from queue

Is there a problem with the slave mode than i configured ?

Something like below example

connected -> SPI1_MOSI<-->SPI3_MISO, SPI1_CLK<-->SPI3_CLK, SP1_CS0 <--> SPI3_CS0  and SPI1_CS1->SPI3_CS1.

SPI1 has to be configured as Master and SPI3 has to be configured as slave in the dt and pinmux settings have to be updated. 
SPI1 DT:    
spi@3210000 {
        status = "okay";
        compatible = "nvidia,tegra186-spi";
        spi@0 {
            compatible = "spidev";
            reg = <0>;
            spi-max-frequency = <65000000>;
            controller-data {
                nvidia,enable-hw-based-cs;
            };
        };
    };

SPI3 DT
    spi@3230000 {
        status = "okay";
        compatible = "nvidia,tegra186-spi-slave";
        spi@0 {
            compatible = "spidev";
            reg = <0>;
            spi-max-frequency = <65000000>;
            controller-data {
                nvidia,enable-hw-based-cs;
            };
        };
     };

PINMUX settings are listed below for SPI1 and SP13 for loopback. (Note: SPI1 and SP3 have an internal loopback connection for Xavier)

SPI_1 pinmux settings:
PADCTL_UART_SPI1_MISO_0  (0x0243d020) =  0x440;
PADCTL_UART_SPI1_MOSI_0 (0x0243d058) =  0x440;
PADCTL_UART_SPI1_SCK_0 (0x0243d040) =  0x440;
PADCTL_UART_SPI1_CS0_0 (0x0243d010) =  0x448;
PADCTL_UART_SPI1_CS1_0 (0x0243d050) =  0x448;

SPI_3 pinmux settings:
PADCTL_UART_SPI3_MISO_0  (0x0243d008) =  0x440;
PADCTL_UART_SPI3_MOSI_0 (0x0243d060) =  0x440;
PADCTL_UART_SPI3_SCK_0 (0x0243d048) =  0x444;
PADCTL_UART_SPI3_CS0_0 (0x0243d018) =  0x448;
PADCTL_UART_SPI3_CS1_0 (0x0243d028) =  0x448;

Could you share the document “Jetson_AGX_Series_DevKit_Pinmux_Configuration_Template.xlsm” ?
I did’t found the download link, Thanks.

Check with below link.

https://developer.nvidia.com/embedded/dlc/jetson-agx-series-devkit-pinmux-configuration-template

Hi ShaneCCC
Now we use two Xavier communicate through SPI, Xavier A as Master and Xavier B as Slave, The connection line is as follows

When Xavier A and Xavier B execute spidev_test there is no waveform signal on SPI1_SCK、SPI1_CSO、SPI1_MISO、SPI1_MOSI, Xavier A and Xavier B can not receive any data, What’s the problem?

It could be the pinmux setting not correct.
Please have devmem2 to read them to confirm.