Jetpack 5.0.2 cs-gpios in device tree (SPI, Jetson Xavier NX)

I’m porting our device tree changes from Jetpack 4.6 to Jetpack 5.0.2 and stumbled upon not working SPI. We are using custom carrier board with changed pinmux (changed pinmux and device tree changes/additions were fully tested with Jetpack 4.6 without issues).

In JP5.0.2 signal pins MOSI and SCLK seems to be working (checked with logic analyzer), but CS pins are always in high state without change. So it seems, that I have some kind of issue with proper configuration of CS pins.

Also I’m unable to manually export CS pins, so it seems like they are already in use with the driver, but the CS signal is not behaving as expected.

New device tree modification (JP 5.0.2) - not working CS pins:

spi@3230000{ 
		status = "okay";
		compatible = "nvidia,tegra186-spi";
		num-cs = <3>;
		cs-gpios = 	<&tegra_main_gpio TEGRA194_MAIN_GPIO(Y, 3) GPIO_ACTIVE_LOW>,  
                	<&tegra_main_gpio TEGRA194_MAIN_GPIO(Y, 4) GPIO_ACTIVE_LOW>,                
                	<&tegra_main_gpio TEGRA194_MAIN_GPIO(R, 0) GPIO_ACTIVE_LOW>;

		spi@0 {
			compatible = "tegra-spidev";
			reg = <0x0>;
			spi-max-frequency = <50000000>;
			controller-data {
				nvidia,enable-hw-based-cs;
				nvidia,rx-clk-tap-delay = <0x10>;
				nvidia,tx-clk-tap-delay = <0x0>;
			};
		};
		spi@1 {
			compatible = "tegra-spidev";
			reg = <0x1>;
			spi-max-frequency = <50000000>;
			controller-data {
				nvidia,enable-hw-based-cs;
				nvidia,rx-clk-tap-delay = <0x10>;
				nvidia,tx-clk-tap-delay = <0x0>;
			};
		};
		spi@2 { 
			compatible = "tegra-spidev";
			reg = <0x2>;
			spi-max-frequency = <50000000>;
			controller-data {
				nvidia,enable-hw-based-cs;
				nvidia,rx-clk-tap-delay = <0x10>;
				nvidia,tx-clk-tap-delay = <0x0>;
			};
		};
	};

Older device tree modification (JP 4.6) - working without issues:

spi@3230000{ 
		status = "okay";
		compatible = "nvidia,tegra186-spi";
		num-cs = <3>;
		cs-gpios = 	<&tegra_main_gpio TEGRA194_MAIN_GPIO(Y, 3) GPIO_ACTIVE_LOW>,  
                	<&tegra_main_gpio TEGRA194_MAIN_GPIO(Y, 4) GPIO_ACTIVE_LOW>,                
                	<&tegra_main_gpio TEGRA194_MAIN_GPIO(R, 0) GPIO_ACTIVE_LOW>;

		spi@0 { 
			compatible = "spidev";
			reg = <0x0>;
			spi-max-frequency = <50000000>;
			controller-data {
				nvidia,enable-hw-based-cs;
				nvidia,rx-clk-tap-delay = <0x10>;
				nvidia,tx-clk-tap-delay = <0x0>;
			};
		};
		spi@1 { 
			compatible = "spidev";
			reg = <0x1>;
			spi-max-frequency = <50000000>;
			controller-data {
				nvidia,enable-hw-based-cs;
				nvidia,rx-clk-tap-delay = <0x10>;
				nvidia,tx-clk-tap-delay = <0x0>;
			};
		};
		spi@2 {
			compatible = "spidev";
			reg = <0x2>;
			spi-max-frequency = <50000000>;
			controller-data {
				nvidia,enable-hw-based-cs;
				nvidia,rx-clk-tap-delay = <0x10>;
				nvidia,tx-clk-tap-delay = <0x0>;
			};
		};
	};

Are you able to point me in right direction?

Could you dump the GPIO state to check.

sudo su
cat /sys/kernel/debug/gpio

Yes of course.

cat /sys/kernel/debug/gpio → snipped to relevant GPIOs

.
.
.
 gpio-442 (PQ.07               )
 gpio-443 (PR.00               |spi2 CS2            ) out hi ACTIVE LOW
 gpio-444 (PR.01               )
.
. 
.
 gpio-485 (PY.01               )
 gpio-486 (PY.02               )
 gpio-487 (PY.03               |spi2 CS0            ) out hi ACTIVE LOW
 gpio-488 (PY.04               |spi2 CS1            ) out hi ACTIVE LOW
 gpio-489 (PY.05               )
 gpio-490 (PY.06               )
.
.
.

Complete output in debug_gpio.txt.

debug_gpio.txt (7.4 KB)

Could you also dump from r32.x to compare.

Thanks

For JetPack 4.6.

Snipped

.
.
.
 gpio-479 (                    )
 gpio-480 (SPI1_SCK            )
 gpio-481 (SPI1_MISO           )
 gpio-482 (SPI1_MOSI           )
 gpio-483 (SPI1_CS0            |cs_gpio             ) out hi    
 gpio-484 (SPI1_CS1            |cs_gpio             ) out hi    
 gpio-485 (                    )
.
.
.

debug_gpio_jp46.txt (9.3 KB)

Thank you for quick answers.

Could you remove the nvidia,enable-hw-based-cs in device tree to try.

I removed nvidia,enable-hw-based-cs.

Controller-data struct:

			controller-data {
				nvidia,rx-clk-tap-delay = <0x10>;
				nvidia,tx-clk-tap-delay = <0x0>;
			};

SPI is still not working.

Could you check the …/kernel/stable-int/drivers/spi/spi-tegra114.c if the gpiod_set_value() was involved.

I inserted some debug messages into spi-tegra114.c.

	if (spi->cs_gpiod)
	{
		dev_warn(tspi->dev, "Testing gpiod_set_value\n");
		gpiod_set_value(spi->cs_gpiod, 0);
	}

According to output (check via dmesg), it seems like the gpiod_set_value is called.

[    8.009714] tegra-qspi 3270000.spi: Adding to iommu group 2
[    8.010349] spi-tegra114 3210000.spi: Testing tegra_spi_setup
[    8.029428] spi-tegra114 3210000.spi: Testing tegra_spi_setup
[    8.030932] spi-tegra114 3230000.spi: Adding to iommu group 2
[    8.040527] spi-tegra114 3230000.spi: Testing tegra_spi_setup
[    8.051062] spi-tegra114 3230000.spi: Testing gpiod_set_value
[    8.051731] spi-tegra114 3230000.spi: Testing tegra_spi_setup
[    8.052054] spi-tegra114 3230000.spi: Testing gpiod_set_value
[    8.055430] spi-tegra114 3230000.spi: Testing tegra_spi_setup
[    8.065619] spi-tegra114 3230000.spi: Testing gpiod_set_value

Should I check something more exactly?

Sorry for the late response, have you managed to get issue resolved or still need the support? Thanks

The issue is still there. I have not tried solve the issue any further (so my last post was my last step).

Please modify the gpiod_set_value() to gpio_set_value() to try.

gpio_set_value() seems to be not working, call fails.

Error gpio_set_value() dmesg:

[    7.639819] spi-tegra114 3230000.spi: Testing gpio_set_value
[    7.640010] ------------[ cut here ]------------
[    7.640142] invalid GPIO -2077369168
[    7.640177] WARNING: CPU: 0 PID: 334 at drivers/gpio/gpiolib.c:122 gpio_to_desc+0xac/0x100
[    7.640398] Modules linked in: spi_tegra210_qspi(+) spi_tegra114(OE+) binfmt_misc ina3221 pwm_fan nvgpu nvmap ramoops reed_solomon ip_tables x_tables
[    7.640453] CPU: 0 PID: 334 Comm: systemd-udevd Tainted: G        W  OE     5.10.104-tegra #1
[    7.640458] Hardware name: Unknown NVIDIA Jetson Xavier NX Developer Kit/NVIDIA Jetson Xavier NX Developer Kit, BIOS r35.0-716592d-dirty 10/26/2022
[    7.640481] pstate: 40400089 (nZcv daIf +PAN -UAO -TCO BTYPE=--)
[    7.640488] pc : gpio_to_desc+0xac/0x100
[    7.640494] lr : gpio_to_desc+0xac/0x100
[    7.640497] sp : ffff800010f2b6a0
[    7.640502] x29: ffff800010f2b6a0 x28: ffff7f1097581800 
[    7.640514] x27: 00000000ffffffff x26: ffffa86a631eb480 
[    7.640524] x25: 0000000000000026 x24: ffff7f109715f080 
[    7.640533] x23: ffff7f109715f000 x22: ffff7f1097581e90 
[    7.640542] x21: ffffa86aa0a116e8 x20: 00000000842ddcb0 
[    7.640551] x19: 0000000000000000 x18: 0000000000000001 
[    7.640560] x17: 0000000000aaaaaa x16: ffffa86a9f07c570 
[    7.640569] x15: ffff7f1097ab30f0 x14: ffffffffffffffff 
[    7.640578] x13: ffffa86aa09c9de8 x12: ffffa86aa09c9a16 
[    7.640588] x11: 0000000005f5e100 x10: abcc77118461cefd 
[    7.640597] x9 : 0000000000000014 x8 : 30322d204f495047 
[    7.640606] x7 : 2064696c61766e69 x6 : c0000000ffffefff 
[    7.640614] x5 : ffff7f11ffda7958 x4 : ffffa86aa06c7968 
[    7.640623] x3 : 0000000000000001 x2 : ffff7f11ffda7960 
[    7.640632] x1 : b68efe5c8feb7500 x0 : 0000000000000000 
[    7.640641] Call trace:
[    7.640647]  gpio_to_desc+0xac/0x100
[    7.640659]  tegra_spi_setup+0x4b4/0x4e0 [spi_tegra114]
[    7.640666]  spi_setup+0xd0/0x260
[    7.640671]  spi_add_device+0xe8/0x1f0
[    7.640677]  of_register_spi_device+0x230/0x380
[    7.640682]  spi_register_controller+0x5a8/0x800
[    7.640687]  devm_spi_register_controller+0x48/0xa0
[    7.640696]  tegra_spi_probe+0x5bc/0x678 [spi_tegra114]
[    7.640702]  platform_drv_probe+0x58/0xb0
[    7.640709]  really_probe+0xf4/0x3d0
[    7.640714]  driver_probe_device+0x5c/0xc0
[    7.640721]  device_driver_attach+0x74/0x80
[    7.640726]  __driver_attach+0x64/0xe0
[    7.640733]  bus_for_each_dev+0x80/0xd0
[    7.640743]  driver_attach+0x30/0x40
[    7.640749]  bus_add_driver+0x14c/0x1f0
[    7.640755]  driver_register+0x64/0x110
[    7.640760]  __platform_driver_register+0x60/0x70
[    7.640770]  tegra_spi_driver_init+0x28/0x1000 [spi_tegra114]
[    7.640777]  do_one_initcall+0x4c/0x2d0
[    7.640785]  do_init_module+0x4c/0x200
[    7.640790]  load_module+0x1ff8/0x22f0
[    7.640797]  __do_sys_finit_module+0xb4/0xf0
[    7.640803]  __arm64_sys_finit_module+0x28/0x40
[    7.640810]  el0_svc_common.constprop.0+0x7c/0x1c0
[    7.640816]  do_el0_svc+0x34/0xa0
[    7.640823]  el0_svc+0x1c/0x30
[    7.640829]  el0_sync_handler+0xa8/0xb0
[    7.640833]  el0_sync+0x16c/0x180
[    7.640838] ---[ end trace 44b6a697f4e933bb ]---

Currently I don’t have any ideas how to test/fix this issue, if I will come up with something I will report back here. But of course your help will be appreciated.

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