How to enable SPI port on the jetson tx1 with R28.1?

I enabled SPI port successfully in tx1 with R24.2.1, using the method in

http://elinux.org/Jetson/TX1_SPI

It say that,

Firstly ,in tx1,

$ sudo cat /sys/kernel/debug/tegra_gpio

Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
A: 0:0 24 00 00 24 00 00 000000
B: 0:1 0f 00 00 00 00 00 000000
C: 0:2 1f 00 00 00 00 00 000000

To properly map the GPIO pins to SPI, the following segment must be added to the Device Tree:

  •    gpio: gpio@6000d000 {
    
  •            gpio_default: default {
    
  •                   gpio-to-sfio = <16 17 18 19 20>;
    
  •           };
    

After update DTB file with the above segment, flash the tx1. You will find,

$ sudo cat /sys/kernel/debug/tegra_gpio

Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
A: 0:0 24 00 00 24 00 00 000000
B: 0:1 0f 00 00 00 00 00 000000
C: 0:2 00 00 00 00 00 00 000000

The “1f” became “00”. The SPI ports can now be used from the kernel.

But in the R28.1, it does not work!!!

The “1f” is still “1f”.

Now how can I enable the SPI port?

@zhili

Add code like below

gpio@6000d000 {
                function-gpios {
                        gpio-hog;
                        function;
                        gpios = <TEGRA_GPIO(BB, 4) 0 TEGRA_GPIO(BB, 4) 1>;
                };
                :::
       };

Hi ShaneCCC,
it does not work still.
The gpio part of my DTS file, extracted from DTB file ,like below,

gpio@6000d000 {
compatible = “nvidia,tegra210-gpio”, “nvidia,tegra124-gpio”, “nvidia,tegra30-gpio”;
reg = <0x0 0x6000d000 0x0 0x1000>;
interrupts = <0x0 0x20 0x4 0x0 0x21 0x4 0x0 0x22 0x4 0x0 0x23 0x4 0x0 0x37 0x4 0x0 0x57 0x4 0x0 0x59 0x4 0x0 0x7d 0x4>;
#gpio-cells = <0x2>;
gpio-controller;
#interrupt-cells = <0x2>;
interrupt-controller;
gpio-ranges = <0x5f 0x0 0x0 0xf6>;
status = “okay”;
linux,phandle = <0x7b>;
phandle = <0x7b>;

            wlan-default-input {
                    gpio-hog;
                    input;
                    gpios = <0x3a 0x0 0x41 0x0>;
                    label = "wlan-default-input-h2", "wlan-default-input-i1";
            };

            wlan-default-output-high {
                    gpio-hog;
                    output-high;
                    gpios = <0x38 0x0 0x40 0x0>;
                    label = "wlan-default-output-high-h0", "wlan-default-output-high-i0";
            };

            camera-control-output-low {
                    gpio-hog;
                    output-low;
                    gpios = <0x94 0x0 0x97 0x0 0x95 0x0 0x98 0x0>;
                    label = "cam0-rst", "cam0-pwdn", "cam1-rst", "cam1-pwdn";
            };

            e2614-rt5658-audio {
                    gpio-hog;
                    function;
                    gpios = <0x8 0x0 0x9 0x0 0xa 0x0 0xb 0x0 0xd8 0x0 0xdb 0x0>;
                    label = "I2S0_LRCLK", "I2S0_SDIN", "I2S0_SDOUT", "I2S0_CLK", "AUDIO_MCLK", "AUD_RST";
                    status = "disabled";
                    linux,phandle = <0x12c>;
                    phandle = <0x12c>;
            };

            function-gpios {
                    gpio-hog;
                    function;
                    gpios = <0xdc 0x0 0xdc 0x1>;
            };

            default {
                    gpio-to-sfio = <0x10 0x11 0x12 0x13 0x14>;
            };
    };

Use flash.sh to update DTB partition,and the /sys/kernel/debug/tegra_gpio

0:0 24 00 00 24 00 00 000000
0:1 0f 00 00 0f 00 00 000000
0:2 1f 00 00 18 00 00 000000
0:3 00 00 00 00 00 00 000000
1:0 70 00 00 60 00 00 000000
1:1 00 00 00 00 00 00 000000
1:2 00 00 00 00 00 00 000000
1:3 ff 1b 03 40 00 00 002024
2:0 0f 0d 01 02 00 00 000000
2:1 00 00 00 00 00 00 000000
2:2 f0 20 00 80 00 00 000000
2:3 02 00 00 02 00 00 000000
3:0 00 00 00 00 00 00 000000
3:1 00 00 00 00 00 00 000000
3:2 00 00 00 00 00 00 000000
3:3 00 00 00 00 00 00 000000
4:0 00 00 00 00 00 00 000000
4:1 00 00 00 00 00 00 000000
4:2 f0 f0 00 00 00 00 000000
4:3 03 03 00 00 00 00 000000
5:0 0c 00 00 08 00 00 000000
5:1 6e 66 00 08 00 00 000000
5:2 00 00 00 00 00 00 000000
5:3 ff 00 00 ff 00 70 606000
6:0 03 00 00 03 00 01 010100
6:1 1f 08 00 16 00 03 030300
6:2 00 00 00 00 00 00 000000
6:3 0d 04 00 00 00 00 000000
7:0 32 10 00 22 00 02 020200
7:1 00 00 00 00 00 00 000000
7:2 00 00 00 00 00 00 000000
7:3 00 00 00 00 00 00 000000

The “1f” is still “1f”.

Thank you.

Below is sample code, you need replace your pin like below not just copy to use it.
gpios = <0x10 0 0x11 0 0x12 0 0x13 0 0x14 0>;

gpio@6000d000 {
                function-gpios {
                        gpio-hog;
                        function;
                        gpios = <TEGRA_GPIO(BB, 4) 0 TEGRA_GPIO(BB, 4) 1>;
                };
                :::
       };

Thank you, ShaneCCC.

what’s the mean of ‘0’ or ‘1’ in the below code ?

gpios = <TEGRA_GPIO(BB, 4) 0 TEGRA_GPIO(BB, 4) 1>

Is it that ‘0’ mean gpio and ‘1’ mean sfio?

Or ‘0’ mean sfio0 and ‘1’ mean sfio1 ?

@zhili
The sample is not good, below should be easy to understand. Two parameter for a pin the first is pin # second does matter for SFIO define.

gpio@6000d000 {
                function-gpios {
                        gpio-hog;
                        function;
                        gpios = <TEGRA_GPIO(BB, 4) 0 TEGRA_GPIO(BB, 5) 0>;
                };
                :::
       };
gpio: gpio@6000d000{
        compatible = "nvidia, tegra210-gpio", "....."
        reg = <0x0 0x6000d000 0x0 0x1000>;
        interrupts = < 0 32 0x04
                       0 33 0x04
                       0 34 0x04
                       0 35 0x04
                       0 55 0x04
                       0 87 0x04
                       0 89 0x04
                       0 125 0x04
        #gpio-cells = <2>;
        gpio-controller; 
        #interrupt-cells = <2>;
        interrupt-controller;
        gpio-ranges = <&pinmux 0 0 246>;
        status = "disabled";

        gpio_default: default{
            gpios = <TEGRA_GPIO(C, 0) 0 TEGRA_GPIO(C, 1) 0 TEGRA_GPIO(C, 2) 0 TEGRA_GPIO(C, 3) 0 TEGRA_GPIO(C, 4) 0>;

I’ve also tried:

gpios = <TEGRA_GPIO(C, 0) 1 TEGRA_GPIO(C, 1) 1 TEGRA_GPIO(C, 2) 1 TEGRA_GPIO(C, 3) 1 TEGRA_GPIO(C, 4) 1>;

On both instances (and some slight variations) the /sys/kernel/debug/ $cat tegra_gpio still shows ‘0x1f’ in {Name, Bank, Port} C: 0:2

I have confirmed that the above changes (gpio_default…) is in the DTB on the Target device.

Can you advise what I’m doing wrong?

Thanks,

David.

Solution
http://elinux.org/Jetson/TX1_SPI on L4t 28.81

add the following to

gpio: gpio@6000d000{
      ...
      ...
      status = "disabled"
      ...
      gpio_default: default{
           gpio-hog;
           function;
           gpios = <TEGRA_GPIO(C, 0) 0 TEGRA_GPIO(C, 1) 0 TEGRA_GPIO(C, 2) 0 TEGRA_GPIO(C, 3) TEGRA_GPIO(C,
 4) 0>;
};
...
};

This causes tegra_gpio /sys/kernel/debug $ cat tegra_gpio to show 0x00 in bank C:0 which initially it was 0x1F as described in http://elinux.org/Jetson/TX1_SPI section Configuring GPIO Pinmux for SPI

Hi,david_evans_g,ShaneCCC

I have added the code to my device tree

gpio@6000d000 {
		compatible = "nvidia,tegra210-gpio", "nvidia,tegra124-gpio", "nvidia,tegra30-gpio";
		reg = <0x0 0x6000d000 0x0 0x1000>;
		interrupts = <0x0 0x20 0x4 0x0 0x21 0x4 0x0 0x22 0x4 0x0 0x23 0x4 0x0 0x37 0x4 0x0 0x57 0x4 0x0 0x59 0x4 0x0 0x7d 0x4>;
		#gpio-cells = <0x2>;
		gpio-controller;
		#interrupt-cells = <0x2>;
		interrupt-controller;
		gpio-ranges = <0x5f 0x0 0x0 0xf6>;
		<b>status = "okay";</b>
		linux,phandle = <0x7b>;
		phandle = <0x7b>;

		wlan-default-input {
			gpio-hog;
			input;
			gpios = <0x3a 0x0 0x41 0x0>;
			label = "wlan-default-input-h2", "wlan-default-input-i1";
		};

		wlan-default-output-high {
			gpio-hog;
			output-high;
			gpios = <0x38 0x0 0x40 0x0>;
			label = "wlan-default-output-high-h0", "wlan-default-output-high-i0";
		};

		camera-control-output-low {
			gpio-hog;
			output-low;
			gpios = <0x94 0x0 0x97 0x0>;
			label = "cam0-rst", "cam0-pwdn";
		};

		e2614-rt5658-audio {
			gpio-hog;
			function;
			gpios = <0x8 0x0 0x9 0x0 0xa 0x0 0xb 0x0 0xd8 0x0 0xdb 0x0>;
			label = "I2S0_LRCLK", "I2S0_SDIN", "I2S0_SDOUT", "I2S0_CLK", "AUDIO_MCLK", "AUD_RST";
			status = "disabled";
			linux,phandle = <0xd2>;
			phandle = <0xd2>;
		};

		[b]default {
			gpio-hog;
			function;
			gpios = <0x10 0x0 0x11 0x0 0x12 0x0 0x13 0x14 0x0>;
		};[/b]
	};

but I cat /sys/kernel/debug/tegra_gpio

nvidia@tegra-ubuntu:~$ sudo cat /sys/kernel/debug/tegra_gpio                    
[sudo] password for nvidia:                                                     
0:0 24 00 00 04 00 00 000000                                                    
0:1 0f 00 00 0f 00 00 000000                                                    
0:2 1f 00 00 18 00 00 000000                                                    
0:3 00 00 00 00 00 00 000000                                                    
1:0 70 00 00 60 00 00 000000                                                    
1:1 00 00 00 00 00 00 000000                                                    
1:2 00 00 00 00 00 00 000000                                                    
1:3 ff 1b 0b 40 00 24 002024                                                    
2:0 0f 0d 01 02 00 00 000000                                                    
2:1 00 00 00 00 00 00 000000                                                    
2:2 f0 20 00 d0 00 00 000000                                                    
2:3 02 00 00 02 00 00 000000                                                    
3:0 00 00 00 00 00 00 000000                                                    
3:1 00 00 00 00 00 00 000000                                                    
3:2 00 00 00 00 00 00 000000                                                    
3:3 00 00 00 00 00 00 000000                                                    
4:0 00 00 00 00 00 00 000000                                                    
4:1 00 00 00 00 00 00 000000                                                    
4:2 f0 f0 80 00 00 00 000000                                                    
4:3 03 03 00 00 00 00 000000                                                    
5:0 0c 00 00 08 00 00 000000                                                    
5:1 6e 66 00 00 00 00 000000                                                    
5:2 00 00 00 00 00 00 000000                                                    
5:3 ff 00 00 ff 00 70 606000                                                    
6:0 03 00 00 03 00 01 010100                                                    
6:1 1f 08 00 17 00 03 030300                                                    
6:2 00 00 00 00 00 00 000000                                                    
6:3 0d 04 00 00 00 00 000000                                                    
7:0 32 00 00 32 00 02 020200                                                    
7:1 00 00 00 00 00 00 000000                                                    
7:2 00 00 00 00 00 00 000000                                                    
7:3 00 00 00 00 00 00 000000

It still 1f.
How do you solve this problem?Is extra code need to add?

Incase if anyone is following this. This issue was solved here GPIO to SFIO 28.1 - Jetson TX1 - NVIDIA Developer Forums