How to set gpio for spi?

I want to enable SPI for my AGX Orin. I reference so many command ,but still can’t enable SPI with my device. So anyone have idea?
Should I edit the pinmux spreadsheet and generate the DT file(like below picture) or just set gpio is fine.

My step to enable the spi:

  1. Use jetson-io to enable header 40 pins for spi1
  2. Edit the dts(i want to put TPM(slb9670) device through spi0)and use dtc tool compile dts to dtb. I set TPM reg as 0x02.
  3. Set extlinux.conf 's FDT
  4. reboot my device

So I should see the device in my /dev/. but I can’t see into my device.
$ modprobe spidev
I use spidev_test tool to test spidev,but dosen’t have RX, I know the reason is pins MOSI and MISO aren’t connected,So should I set gpio or pinmux or both?

First using jetson-io to configure the PINs then connect the MOSI and MISO to run the loopback test to confirm the configure.
If loopback test without problem the problem could be he in TPM chip.

Thank you for reply, how to connect the MOSI and MISO? should I set pinmux or gpio? and how to run the loopback test to confirm the configure? have any tool can help me to test?

Short them from external by wire jump.

Thank you for reply.I use the oscilloscope to test customboard MOSI and MISO pin, both of them aren’t have any singal. so I use the oscilloscope to test Orin MOSI and MISO pin, it’s work. and I compare both of my customboard and orin. I use dmesg | grep spi* command to grep spi info. I found the different is about can not get clock , like below photo:

Best regards

Check the driver which can’t get which clock and check the device tree.

Thank you for reply, I’m a complete beginner at this stuff
I found the error message in spi-tegra114.c as below photo:
Does tspi is a driver? if tspi is a driver how can i solve this problem? Use $ make menuconfig to loading driver?

Best regards

Did you modify the device tree for spi@3210000?
Confirm the clock-names = “spi\0pll_p\0clk_m”

        spi@3210000 {
                iommus = <0x02 0x04>;
                #address-cells = <0x01>;
                clock-names = "spi\0pll_p\0clk_m";
                nvidia,clk-parents = "pll_p\0clk_m";
                resets = <0x04 0x5b>;
                interrupts = <0x00 0x24 0x04>;
                clocks = <0x04 0x87 0x04 0x66 0x04 0x0e>;
                #size-cells = <0x00>;
                spi-max-frequency = <0x3dfd240>;
                dma-names = "rx\0tx";
                compatible = "nvidia,tegra186-spi";
                status = "okay";
                reg = <0x00 0x3210000 0x00 0x10000>;
                phandle = <0x31e>;
                dmas = <0x03 0x0f 0x03 0x0f>;
                reset-names = "spi";

Yes,I modify my device tree as below photo. and my device tree have clock-names


Sorry for the late response, is this still an issue to support? Thanks

I solve the spi-trgea114 can not get clock problem, after I’m set the pinmux and use spidev-test to test my spi, It’s look like correctly:

but now i got a new problem.when I use the TPM slb9670 through the spi@3210000 and my set as below photo:

and the driver about tpm and spi can see when I command the lsmod | grep tpm and lsmod | grep spi :


but I still can’t see the tpm device in my /dev/, should I add the rest-gpios in TPM slb9670 like below photo?

It looks like the SPI of Orin is well set. You may look at driver of the TPM and check if reset-gpio property is required.

How to confirm the reset-gpio is required?

The driver for the device looks to be:


The property reset-gpios is not used in the driver, so it should not be required.

So I don’t need to add the reset-gpios in my device tree, but I still can’t found the /dev/tpm0 in my Orin, did you have any suggest ?

One more question, if I modify the pinmux first then I didn’t to add cs-gpios in my device tree right?

For confirming SPI master is well set up on Orin, please use this binary:
How to set to spi slave mode - #5 by ShaneCCC
And try the command:

sudo ./spidev_test -D /dev/spidev0.0 -s8000000 -g256 -b32 -H -p0 -n1 -zzz -t

If above command can be run successfully, the SPI master should be good, And then please add prints in tpm_tis_spi_main.c to check if the driver is run. May add prints in probe function.

As below photo it’s my spidev0.0 test result ,and my test command is sudo ./spidev_test -v -D /dev/spidev0.0 what’s diff between you and me?
My test result doesn’t mean my SPI master is well set up on Orin?

And I’m add printk in tpm_tis_spi_main.c dmesg show as below photo:

The dmesg show probe failed, so maybe is my device tree setting problem?
And I ref below setting, they use the reset-gpios and cs-gpios to enable their TPM

I got a new problem, I update my JP version from 5.0.2 to 5.1,and then my tpm can found in my /dev/ ,but when I modify my device tree as below photo, It’s can’t found tpm in /dev/

If I modify my device tree as below, I can found tpm in /dev/

The diff is slb9670 set reg <0x00> and reg<0x01>, and I command sudo dmesg | grep tpm

Why? I hope that this is not a too stupid question, but I’m really lost here.
The tpm device only can work when I set slb9670 in reg<0x01>

The number in reg should match the chip select i.e., 0 (for SPI1_CS0_N - pin24) or 1 (for SPI1_CS1_N - pin26) which you have used to connect to the TPM. if the spidev is already active in CS0, then you need to use 1 for CS1

Thank you for reply. I checked out my schematic about my TPM slb9670, I’m sure our board is use CS0 to connect TPM , that’s why I don’t understand we use CS1 can work,but CS0 can’t.

@b-sathishkumar I ref this link(SPI TPM module support fail on jetpack 5.0.2/5.1 on jetson xavier agx - #18 by b-sathishkumar) about your device tree setting.
Can your explain how to use prod-setting? Does this part should I set as your device tree?
Below photo is my device tree:

@b-sathishkumar And one more question, did you apply this patch?
(spi: tegra: handle cs_change in modes sw_based_cs & cs_gpios · Seeed-Studio/seeed-linux-dtoverlays@1a5db1b · GitHub)