How to set gpio for spi?

Thank you for reply, I’m a complete beginner at this stuff
I found the error message in spi-tegra114.c as below photo:
image
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>;
                dma-coherent;
                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

image

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:
image

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

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

image

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

Hi,
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.

Hi,
How to confirm the reset-gpio is required?

Hi,
The driver for the device looks to be:

kernel/drivers/char/tpm/tpm_tis_spi_main.c

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

Hi,
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?

Hi,
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.

Hi,
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
https://forums.developer.nvidia.com/t/tpm-on-spi2-in-uboot/230370

Hi,
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)

Not sure on the details of prod-setting. But leave it as it is.
Also i didn’t apply that patch

1 Like

Hi
@b-sathishkumar Thank you for reply.
@DaneLLL @ShaneCCC @kayccc Should I modify pinmux@2430000 device tree hdr40-pin24 nvidia,enable-input value from <0x01> to <0x00>? Because our board is use CS0 to connect TPM.

Hi,
Yes, please enable it and try. I can see it set to ENABLE in

t23x/concord/kernel-dts/tegra234-p3737-0000-p3701-0000-hdr40.dts

hdr40-pin24 {
        nvidia,pins = "spi1_cs0_pz6";
        nvidia,function = "spi1";
        nvidia,pin-label = "spi1_cs0";
        nvidia,tristate = <TEGRA_PIN_DISABLE>;
        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
};

Somehow it is DISABLE in your screenshot. A bit strange here.

Hi, @DaneLLL
Below photo is my original set in my device tree,above photo is my guess , I think the nvidia,enable input have associate with my device tree slb9670 reg <0x00> set.

This set can make TPM work in below device tree:

But I want set TPM in spi0.0 .but it’s only work on spi0.1(reg<0x01>) can’t work when I set on spi0.0(reg<0x00>)

1 Like

Hi,
Is it possible the device is physically connected to B56 pin instead of E55 pin? And please check if CS0 has signal in the loopback test:

  1. Connect MOSI of SPI1 to MISO
  2. Execute $ sudo modprobe spidev
  3. Download/build this test file:
    https://raw.githubusercontent.com/torvalds/linux/v4.9/tools/spi/spidev_test.c
  4. Run the command and check if the result is expected:
$ sudo ./spidev_test -D /dev/spidev0.0 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  | ......@.......................
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  | ......@.......................

or

$ sudo ./spidev_test -D /dev/spidev0.0 -v -p "HelloWorld123456789abcdef"
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 48 65 6C 6C 6F 57 6F 72 6C 64 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 __ __ __ __ __ __ __  | HelloWorld123456789abcdef
RX | 48 65 6C 6C 6F 57 6F 72 6C 64 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 __ __ __ __ __ __ __  | HelloWorld123456789abcdef
  1. Check signal of CS0 port while doing step 4.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.