SPI on TX1

Hey I am trying to enable SPI on my TX1 with l4t 28.2. There are many threads for 28.1, however this does not seem to work for me. I compiled the kernel with SPI enabled and changed my device tree according to https://elinux.org/Jetson/TX1_SPI However, I can not see the GPIO switching or spidev under

ls /dev

. Is there anything else I can try or did anybody solve the problem yet?

Check below topic to use gpio-hog instead of gpio-to-sfio and you need CONFIG_SPI_SPIDEV=y in kernel config to enable the /dev/spidevxx things.

https://devtalk.nvidia.com/default/topic/1023607

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) 0 TEGRA_GPIO(C, 4) 0>;
		};

So I changed CONFIG_SPI_SPIDEV=y. I think the problem is still the device-tree. It gives me an issue when I try to compile with

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 = <0x5a 0x0 0x0 0xf6>;
		status = "okay";
		linux,phandle = <0x78>;
		phandle = <0x78>;

		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 0x42 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 0x24 0x0 0x25 0x0>;
			label = "I2S0_LRCLK", "I2S0_SDIN", "I2S0_SDOUT", "I2S0_CLK", "AUDIO_MCLK", "AUD_RST", "DMIC3_CLK", "DMIC3_DAT";
			status = "disabled";
			linux,phandle = <0x13d>;
			phandle = <0x13d>;
		};
		
		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) 0 TEGRA_GPIO(C, 4) 0>;
		};
	};

when I compile using

sudo dtc -I dts -O dtb -o ~/Downloads/Linux_for_tegra/kernel/dtb/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb ~/Desktop/extracted.dts

I get

Error: /home/lhr/Desktop/extracted.dts:3073.17-18 syntax error
FATAL ERROR: Unable to parse input tree

I believe the error occurs in

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>;

because I can compile without this line.

Is there any mistake in this line or is there another tool other than device-tree-compiler I should use?

Add this
#include <dt-bindings/gpio/tegra-gpio.h>

So I added the following line to my dtb

/include/ "/home/lhr/Desktop/Jetson/Linux_for_Tegra/rootfs/usr/src/linux-headers-4.4.38-tegra/include/dt-bindings/gpio/tegra-gpio.h";

where I replaced

/home/lhr/Desktop/Jetson/Linux_for_Tegra/rootfs/usr/src/linux-headers-4.4.38-tegra/include/dt-bindings/gpio/tegra-gpio.h

with any of these

~/Desktop$ locate tegra-gpio.h
/home/lhr/Desktop/Jetson/Linux_for_Tegra/rootfs/usr/src/linux-headers-4.4.38-tegra/include/dt-bindings/gpio/tegra-gpio.h
/home/lhr/Desktop/Jetson/install/linux_kernel/hardware/nvidia/soc/tegra/kernel-include/dt-bindings/gpio/tegra-gpio.h
/home/lhr/Desktop/Jetson/install/linux_kernel/kernel/kernel-4.4/include/dt-bindings/gpio/tegra-gpio.h
/usr/src/linux-headers-4.15.0-20/include/dt-bindings/gpio/tegra-gpio.h
/usr/src/linux-headers-4.15.0-22/include/dt-bindings/gpio/tegra-gpio.h

I am still getting

~/Desktop$ dtc -I dts -O dtb -o kernel/dtb/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb /home/lhr/Desktop/extracted.dts
Error: /home/lhr/Desktop/Jetson/Linux_for_Tegra/rootfs/usr/src/linux-headers-4.4.38-tegra/include/dt-bindings/gpio/tegra-gpio.h:11.1-8 syntax error
FATAL ERROR: Unable to parse input tree

Is there anything that I am missing or do I have to compile it at a different location. I am trying to do this offline and want to flash the dts on the jetson after it is compiled.

If you are not compile the DTB in kernel source tree and tools. You need to change those macro to a real value. Check the “tegra-gpio.h” for the define to figure out the value.

TEGRA_GPIO(C, 0)

Ok so maybe I am doing a mistake with the .dtb. The .dts is compiling but my

sudo cat /sys/kernel/debug/tegra_gpio

will not switch the mode of 0:2. I am trying to compile it off board and flash it onto the jetson. I am starting to believe that the jetson is not using my file, so I was thinking of changing it on the jetson. I could convert it to a dts, make the changes and compile it back to a dtb. However my question is what device tree file is used by the jetson. I have several device tree files on the jetson.

nvidia@tegra-ubuntu:~$ ls /boot/
_ddot_  extlinux  tegra210-jetson-cv-base-p2597-2180-a00.dtb           tegra210-jetson-cv-p2597-2180-imx274-hdmi.dtb  tegra210-jetson-tx1-p2597-2180-a01-android-devkit.dtb
dtb     Image     tegra210-jetson-cv-p2597-2180-a00-auo-1080p-edp.dtb  tegra210-jetson-e-base-p2595-0000-a00.dtb      tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb
efi     initrd    tegra210-jetson-cv-p2597-2180-a00.dtb                tegra210-jetson-e-p2595-0000-a00-00.dtb        tegra210-jetson-tx1-p2597-2180-a02-devkit-24x7.dtb

and during boot it shows

nvidia@tegra-ubuntu:~$ dmesg | grep dts
[    0.032379] DTS File Name: ../arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t210/jetson/kernel-dts/tegra210-jetson-tx1-p2597-2180-a01-devkit.dts
[    0.183848] DTS File Name: ../arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t210/jetson/kernel-dts/tegra210-jetson-tx1-p2597-2180-a01-devkit.dts
[    0.217277] tegra-pmc 7000e400.pmc: scratch reg offset dts data not present

So I does that mean the jetson is using /boot/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb? If that would be the case I would just do it on the jetson instead of off board.