NANO EMMC SPI signal seen on the scope is abnormal

any help?

@qgq1991
Could you share your modification here to review.

Thanks

gpio-tegra.c (21.8 KB)
spi-tegra114.c (59.2 KB)
tegra210-porg-gpio-p3448-0002-b00.dtsi (2.3 KB)
tegra210-porg-p3448-common.dtsi (21.8 KB)

diff -u ./kernel/kernel-4.9/drivers/spi/spi-tegra114.c.bak ./kernel/kernel-4.9/drivers/spi/spi-tegra114.c

$ diff -u ./hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi.bak ./hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi
--- ./hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi.bak	2021-11-05 14:32:19.880802429 +0800
+++ ./hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi	2021-11-05 14:35:37.000000000 +0800
@@ -196,7 +196,8 @@
 	hdr40_spi1: spi@7000d400 { /* SPI 1 to 40 pin header */
 		status = "okay";
 		spi@0 {
-			compatible = "tegra-spidev";
+            status = "okay";
+			compatible = "spidev";
 			reg = <0x0>;
 			spi-max-frequency = <33000000>;
 			controller-data {
@@ -205,7 +206,8 @@
 			};
 		};
 		spi@1 {
-			compatible = "tegra-spidev";
+            status = "okay";
+			compatible = "spidev";
 			reg = <0x1>;
 			spi-max-frequency = <33000000>;
 			controller-data {
            
$ diff -u ./hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi.bak ./hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi
--- ./hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi.bak	2021-11-29 18:26:33.065072832 +0800
+++ ./hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi	2021-11-05 14:26:21.000000000 +0800
@@ -1,81 +1,90 @@
-/*This dtsi file was generated by T210_P3448_SKU2_pinmux.xlsm Revision: 17 */
-/*
- * Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#include <dt-bindings/gpio/tegra-gpio.h>
-
-/ {
-	gpio: gpio@6000d000 {
-		gpio-init-names = "default";
-		gpio-init-0 = <&gpio_default>;
-
-		gpio_default: default {
-			gpio-input = <
-				TEGRA_GPIO(BB, 0)
-				TEGRA_GPIO(B, 4)
-				TEGRA_GPIO(B, 5)
-				TEGRA_GPIO(B, 6)
-				TEGRA_GPIO(B, 7)
-				TEGRA_GPIO(DD, 0)
-				TEGRA_GPIO(E, 6)
-				TEGRA_GPIO(S, 5)
-				TEGRA_GPIO(A, 5)
-				TEGRA_GPIO(X, 4)
-				TEGRA_GPIO(X, 5)
-				TEGRA_GPIO(X, 6)
-				TEGRA_GPIO(Y, 1)
-				TEGRA_GPIO(Y, 2)
-				TEGRA_GPIO(V, 0)
-				TEGRA_GPIO(V, 1)
-				TEGRA_GPIO(Z, 0)
-				TEGRA_GPIO(Z, 2)
-				TEGRA_GPIO(J, 5)
-				TEGRA_GPIO(J, 6)
-				TEGRA_GPIO(J, 4)
-				TEGRA_GPIO(J, 7)
-				TEGRA_GPIO(G, 2)
-				TEGRA_GPIO(G, 3)
-				TEGRA_GPIO(C, 0)
-				TEGRA_GPIO(C, 1)
-				TEGRA_GPIO(C, 2)
-				TEGRA_GPIO(C, 3)
-				TEGRA_GPIO(C, 4)
-				TEGRA_GPIO(H, 2)
-				TEGRA_GPIO(H, 5)
-				TEGRA_GPIO(H, 6)
-				TEGRA_GPIO(CC, 4)
-				>;
-			gpio-output-low = <
-				TEGRA_GPIO(S, 7)
-				TEGRA_GPIO(T, 0)
-				TEGRA_GPIO(H, 0)
-				TEGRA_GPIO(H, 3)
-				TEGRA_GPIO(H, 4)
-				TEGRA_GPIO(H, 7)
-				TEGRA_GPIO(I, 0)
-				TEGRA_GPIO(I, 2)
-				>;
-			gpio-output-high = <
-				TEGRA_GPIO(A, 6)
-				TEGRA_GPIO(X, 3)
-				TEGRA_GPIO(I, 1)
-				TEGRA_GPIO(CC, 7)
-				>;
-		};
-	};
-};
+/*This dtsi file was generated by T210_P3448_SKU2_pinmux.xlsm Revision: 17 */
+/*
+ * Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include <dt-bindings/gpio/tegra-gpio.h>
+
+/ {
+	gpio: gpio@6000d000 {
+		gpio-init-names = "default";
+		gpio-init-0 = <&gpio_default>;
+
+		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
+            >;
+			gpio-input = <
+				TEGRA_GPIO(BB, 0)
+				TEGRA_GPIO(B, 4)
+				TEGRA_GPIO(B, 5)
+				TEGRA_GPIO(B, 6)
+				TEGRA_GPIO(B, 7)
+				TEGRA_GPIO(DD, 0)
+				TEGRA_GPIO(E, 6)
+				TEGRA_GPIO(S, 5)
+				TEGRA_GPIO(A, 5)
+				TEGRA_GPIO(X, 4)
+				TEGRA_GPIO(X, 5)
+				TEGRA_GPIO(X, 6)
+				TEGRA_GPIO(Y, 1)
+				TEGRA_GPIO(Y, 2)
+				TEGRA_GPIO(V, 0)
+				TEGRA_GPIO(V, 1)
+				TEGRA_GPIO(Z, 0)
+				TEGRA_GPIO(Z, 2)
+				TEGRA_GPIO(J, 5)
+				TEGRA_GPIO(J, 6)
+				TEGRA_GPIO(J, 4)
+				TEGRA_GPIO(J, 7)
+				TEGRA_GPIO(G, 2)
+				TEGRA_GPIO(G, 3)
+				/*TEGRA_GPIO(C, 0)*/
+				/*TEGRA_GPIO(C, 1)*/
+				/*TEGRA_GPIO(C, 2)*/
+				/*TEGRA_GPIO(C, 3)*/
+				/*TEGRA_GPIO(C, 4)*/
+				TEGRA_GPIO(H, 2)
+				TEGRA_GPIO(H, 5)
+				TEGRA_GPIO(H, 6)
+				TEGRA_GPIO(CC, 4)
+				>;
+			gpio-output-low = <
+				TEGRA_GPIO(S, 7)
+				TEGRA_GPIO(T, 0)
+				TEGRA_GPIO(H, 0)
+				TEGRA_GPIO(H, 3)
+				TEGRA_GPIO(H, 4)
+				TEGRA_GPIO(H, 7)
+				TEGRA_GPIO(I, 0)
+				TEGRA_GPIO(I, 2)
+				>;
+			gpio-output-high = <
+				TEGRA_GPIO(A, 6)
+				TEGRA_GPIO(X, 3)
+				TEGRA_GPIO(I, 1)
+				TEGRA_GPIO(CC, 7)
+				>;
+		};
+	};
+};

keygo@keygo-txflash:~/Linux_for_Tegra/source/public$ diff -u ./kernel/kernel-4.9/drivers/gpio/gpio-tegra.c.bak ./kernel/kernel-4.9/drivers/gpio/gpio-tegra.c
--- ./kernel/kernel-4.9/drivers/gpio/gpio-tegra.c.bak	2021-11-05 14:27:15.093797696 +0800
+++ ./kernel/kernel-4.9/drivers/gpio/gpio-tegra.c	2021-11-05 15:53:12.000000000 +0800
@@ -217,6 +217,11 @@
 	tegra_gpio_mask_write(tgi, GPIO_MSK_CNF(tgi, gpio), gpio, 1);
 }
 
+static void tegra_gpio_disable(struct tegra_gpio_info *tgi, int gpio)
+{
+       tegra_gpio_mask_write(tgi, GPIO_MSK_CNF(tgi, gpio), gpio, 0);
+}
+
 static int tegra_gpio_request(struct gpio_chip *chip, unsigned offset)
 {
 	tegra_gpio_save_gpio_state(offset);
@@ -225,8 +230,12 @@
 
 static void tegra_gpio_free(struct gpio_chip *chip, unsigned offset)
 {
+    struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
+    
 	pinctrl_free_gpio(chip->base + offset);
 	tegra_gpio_restore_gpio_state(offset);
+    
+    tegra_gpio_disable(tgi, offset);
 }
 
 static void tegra_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
@@ -796,7 +805,10 @@
 	tegra_gpio_debuginit(tgi);
 
 	register_syscore_ops(&tegra_gpio_syscore_ops);
-
+    // free spi0 pins
+    for (gpio = 16; gpio <= 20; gpio++) {
+        tegra_gpio_free(&tgi->gc, gpio);
+    }
 	return 0;
 }


diff -u ./kernel/kernel-4.9/drivers/spi/spi-tegra114.c.bak ./kernel/kernel-4.9/drivers/spi/spi-tegra114.c
--- ./kernel/kernel-4.9/drivers/spi/spi-tegra114.c.bak	2021-11-29 18:33:44.805837392 +0800
+++ ./kernel/kernel-4.9/drivers/spi/spi-tegra114.c	2021-11-08 12:26:07.000000000 +0800
@@ -1490,10 +1490,11 @@
 		msg->actual_length += xfer->len;
 
 complete_xfer:
-		if (prefer_last_used_cs)
+		// if (prefer_last_used_cs)
 			cmd1 = tspi->command1_reg;
-		else
-			cmd1 = tspi->def_command1_reg;
+		// else
+			// cmd1 = tspi->def_command1_reg;
+        
 		if (ret < 0 || skip) {
 			if (cstate && cstate->cs_gpio_valid)
 				gpio_set_value(spi->cs_gpio, gval);

@ShaneCCC Thanks

Can provide some suggest.Thanks

We’re checkign with internal team to see if further suggetions. Sorry for the late response.

thanks

Please apply below to verify the problem.

diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index 2aadf42..747ce95 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -908,12 +908,8 @@ static void tegra_spi_set_timing1(struct spi_device *spi)
        if (!cdata || tspi->prod_list)
                return;
        set_count = min(cdata->cs_setup_clk_count, 16);
-       if (set_count)
-               set_count--;

        hold_count = min(cdata->cs_hold_clk_count, 16);
-       if (hold_count)
-               hold_count--;

        spi_cs_setup = SPI_SETUP_HOLD(set_count, hold_count);
        spi_cs_timing = SPI_CS_SETUP_HOLD(tspi->spi_cs_timing,

I have try it and it still doesn’t work.
I am not sure that my operation is correct.
Can you provide complete modification steps, including other files that need to be modified, such as .dts files and.c files?
Thanks

Hi, are you testing on SPI0 port of J41 connector? Can you share a photo of your test setting?

Yes. Test on SPI0 port of J41.Sorry I can not take a photo, the nano is not with me after the last testing.
Can you povide the whole modified spi-tegra114.c file and other files please.
I replace the dtb and Image file after building the kernel .Are there some .ko files also need to be repalce before reflash the nano?

Hi, we need to know your testing setup so as to make sure it is not caused by that.




pin directly connected to oscilloscope

Did you get the signal from the loopback test? Short the MOSI with MISO and run the spidev_test to measure the signal.

1 Like

loopback test OK

Suppose it could be device problem if loopback test without problem.

I have tested with another jetson-nano ,its spi signal is bad on oscilloscope.

Please review my steps.

  1. install sdkmanager_1.7.2-9007_amd64.deb
  2. download sdk by sdkmanager
q@q:~/nvidia/nvidia_sdk/JetPack_4.6_Linux_JETSON_NANO_TARGETS/Linux_for_Tegra$ ls
apply_binaries.sh            jetson-nano-devkit-emmc.conf  kernel                   nv_tools                         p3449-0000+p3448-0000-qspi.conf     p3542.conf             source_sync.sh
bootloader                   jetson-nano-emmc.conf         l4t_generate_soc_bup.sh  p2371.conf                       p3449-0000+p3448-0000-qspi-sd.conf  README_Autoflash.txt   tools
build_l4t_bup.sh             jetson-nano-qspi.conf         nvautoflash.sh           p2597-0000+p2180-1000-24x7.conf  p3449-0000+p3448-0002.conf          README_Massflash.txt   TX1_boot-firmware-redundancy.txt
flash.sh                     jetson-nano-qspi-sd.conf      nvmassflashgen.sh        p2597-0000+p2180-1000.conf       p3450.conf                          README_RAPID_BOOT.txt
jetson-nano-2gb-devkit.conf  jetson-tx1.conf               nvsdkmanager_flash.sh    p3448-0000.conf.common           p3542-0000+p3448-0003-qspi.conf     rootfs
jetson-nano-devkit.conf      jetson-tx1-devkit.conf        nv_tegra                 p3448-0000-max-spi.conf          p3542-0000+p3448-0003-qspi-sd.conf  source
  1. flash nano by sdkmanager

n@n:~$ head -n 1 /etc/nv_tegra_release
# R32 (release), REVISION: 6.1, GCID: 27863751, BOARD: t210ref, EABI: aarch64, DATE: Mon Jul 26 19:20:30 UTC 2021
  1. open the Web page
    Jetson Linux R32.6.1 Release Page | NVIDIA Developer
    download L4T Driver Package (BSP) Sources(L4T 32.6.1)
    download GCC 7.3.1 for 64 bit BSP and Kernel(L4T 32.6.1)
q@q:~/nv$ tar -xjf public_sources.tbz2
q@q:~/nv$ cd Linux_for_Tegra/source/public
q@q:~/nv/Linux_for_Tegra/source/public$ tar -xjf kernel_src.tbz2
q@q:~/nv/Linux_for_Tegra/source/public$ cd ~/nv
q@q:~/nv$ tar -xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

5.modify .dts files and .c files

q@q:~/nv$ diff -bu ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-pinmux-p3448-0002-b00.dtsi.bak ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-pinmux-p3448-0002-b00.dtsi
--- ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-pinmux-p3448-0002-b00.dtsi.bak   2022-02-11 13:40:57.100522614 +0800
+++ ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-pinmux-p3448-0002-b00.dtsi       2022-02-11 13:42:55.000000000 +0800
@@ -721,7 +721,7 @@

                        spi1_mosi_pc0 {
                                nvidia,pins = "spi1_mosi_pc0";
-                               nvidia,function = "rsvd1";
+                               nvidia,function = "spi1";
                                nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
@@ -729,7 +729,7 @@

                        spi1_miso_pc1 {
                                nvidia,pins = "spi1_miso_pc1";
-                               nvidia,function = "rsvd1";
+                               nvidia,function = "spi1";
                                nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
@@ -737,7 +737,7 @@

                        spi1_sck_pc2 {
                                nvidia,pins = "spi1_sck_pc2";
-                               nvidia,function = "rsvd1";
+                               nvidia,function = "spi1";
                                nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
@@ -745,7 +745,7 @@

                        spi1_cs0_pc3 {
                                nvidia,pins = "spi1_cs0_pc3";
-                               nvidia,function = "rsvd1";
+                               nvidia,function = "spi1";
                                nvidia,pull = <TEGRA_PIN_PULL_UP>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
@@ -753,7 +753,7 @@

                        spi1_cs1_pc4 {
                                nvidia,pins = "spi1_cs1_pc4";
-                               nvidia,function = "rsvd1";
+                               nvidia,function = "spi1";
                                nvidia,pull = <TEGRA_PIN_PULL_UP>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;

q@q:~/nv$ diff -bu ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi.bak ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi
--- ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi.bak     2022-02-11 13:30:26.133110410 +0800
+++ ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-gpio-p3448-0002-b00.dtsi 2022-02-11 13:31:36.624164309 +0800
@@ -25,6 +25,9 @@
                gpio-init-0 = <&gpio_default>;

                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>;
                        gpio-input = <
                                TEGRA_GPIO(BB, 0)
                                TEGRA_GPIO(B, 4)
@@ -50,11 +53,11 @@
                                TEGRA_GPIO(J, 7)
                                TEGRA_GPIO(G, 2)
                                TEGRA_GPIO(G, 3)
-                               TEGRA_GPIO(C, 0)
-                               TEGRA_GPIO(C, 1)
-                               TEGRA_GPIO(C, 2)
-                               TEGRA_GPIO(C, 3)
-                               TEGRA_GPIO(C, 4)
+                               //TEGRA_GPIO(C, 0)
+                               //TEGRA_GPIO(C, 1)
+                               //TEGRA_GPIO(C, 2)
+                               //TEGRA_GPIO(C, 3)
+                               //TEGRA_GPIO(C, 4)
                                TEGRA_GPIO(H, 2)
                                TEGRA_GPIO(H, 5)
                                TEGRA_GPIO(H, 6)
q@q:~/nv$ diff -bu ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi.bak ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi
--- ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi.bak   2022-02-11 13:47:30.628907051 +0800
+++ ./Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi       2022-02-11 13:51:36.000000000 +0800
@@ -196,7 +196,8 @@
        hdr40_spi1: spi@7000d400 { /* SPI 1 to 40 pin header */
                status = "okay";
                spi@0 {
-                       compatible = "tegra-spidev";
+            status = "okay";
+                       compatible = "spidev";
                        reg = <0x0>;
                        spi-max-frequency = <33000000>;
                        controller-data {
@@ -205,7 +206,8 @@
                        };
                };
                spi@1 {
-                       compatible = "tegra-spidev";
+            status = "okay";
+                       compatible = "spidev";
                        reg = <0x1>;
                        spi-max-frequency = <33000000>;
                        controller-data {

q@q:~/nv$ diff -bu ./Linux_for_Tegra/source/public/kernel/kernel-4.9/drivers/gpio/gpio-tegra.c.bak ./Linux_for_Tegra/source/public/kernel/kernel-4.9/drivers/gpio/gpio-tegra.c
--- ./Linux_for_Tegra/source/public/kernel/kernel-4.9/drivers/gpio/gpio-tegra.c.bak     2022-02-11 13:12:22.426222612 +0800
+++ ./Linux_for_Tegra/source/public/kernel/kernel-4.9/drivers/gpio/gpio-tegra.c 2022-02-11 13:14:54.000000000 +0800
@@ -217,6 +217,11 @@
        tegra_gpio_mask_write(tgi, GPIO_MSK_CNF(tgi, gpio), gpio, 1);
 }

+static void tegra_gpio_disable(struct tegra_gpio_info *tgi, int gpio)
+{
+       tegra_gpio_mask_write(tgi, GPIO_MSK_CNF(tgi, gpio), gpio, 0);
+}
+
 static int tegra_gpio_request(struct gpio_chip *chip, unsigned offset)
 {
        tegra_gpio_save_gpio_state(offset);
@@ -225,8 +230,11 @@

 static void tegra_gpio_free(struct gpio_chip *chip, unsigned offset)
 {
+    struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
+
        pinctrl_free_gpio(chip->base + offset);
        tegra_gpio_restore_gpio_state(offset);
+    tegra_gpio_disable(tgi, offset);
 }

 static void tegra_gpio_set(struct gpio_chip *chip, unsigned offset, int value)

q@q:~/nv$ diff -bu ./Linux_for_Tegra/source/public/kernel/kernel-4.9/drivers/spi/spi-tegra114.c.bak  ./Linux_for_Tegra/source/public/kernel/kernel-4.9/drivers/spi/spi-tegra114.c
--- ./Linux_for_Tegra/source/public/kernel/kernel-4.9/drivers/spi/spi-tegra114.c.bak    2022-02-11 14:35:47.688454417 +0800
+++ ./Linux_for_Tegra/source/public/kernel/kernel-4.9/drivers/spi/spi-tegra114.c        2022-02-11 16:47:44.000000000 +0800
@@ -908,12 +908,12 @@
        if (!cdata || tspi->prod_list)
                return;
        set_count = min(cdata->cs_setup_clk_count, 16);
-       if (set_count)
-               set_count--;
+       // if (set_count)
+               // set_count--;

        hold_count = min(cdata->cs_hold_clk_count, 16);
-       if (hold_count)
-               hold_count--;
+       // if (hold_count)
+               // hold_count--;

        spi_cs_setup = SPI_SETUP_HOLD(set_count, hold_count);
        spi_cs_timing = SPI_CS_SETUP_HOLD(tspi->spi_cs_timing,
@@ -1490,10 +1490,10 @@
                msg->actual_length += xfer->len;

 complete_xfer:
-               if (prefer_last_used_cs)
+               // if (prefer_last_used_cs)
                        cmd1 = tspi->command1_reg;
-               else
-                       cmd1 = tspi->def_command1_reg;
+               // else
+                       // cmd1 = tspi->def_command1_reg;
                if (ret < 0 || skip) {
                        if (cstate && cstate->cs_gpio_valid)
                                gpio_set_value(spi->cs_gpio, gval);

6.edit bulid script

q@q:~/nv/Linux_for_Tegra/source/public/kernel/kernel-4.9$ cat build.sh
#!/bin/sh
echo "build:" `date`
TEGRA_KERNEL_OUT=/home/q/nv/build
export CROSS_COMPILE=/home/q/nv/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export LOCALVERSION=-tegra
make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4
echo "build finish" `date`

7.ready to build

q@q:~/nv$ mkdir build
q@q:~/nv$ sudo apt install build-essential bc

8.build

q@q:~/nv/Linux_for_Tegra/source/public/kernel/kernel-4.9$ ./build.sh

9.replace Image and other dtb files

cp /home/q/nv/build/arch/arm64/boot/Image /home/q/nvidia/nvidia_sdk/JetPack_4.6_Linux_JETSON_NANO_TARGETS/Linux_for_Tegra/kernel/Image
cp /home/q/nv/build/arch/arm64/boot/dts/*.* /home/q/nvidia/nvidia_sdk/JetPack_4.6_Linux_JETSON_NANO_TARGETS/Linux_for_Tegra/kernel/dtb/

10.reflash nano by flash.sh

q@q:~/nvidia/nvidia_sdk/JetPack_4.6_Linux_JETSON_NANO_TARGETS/Linux_for_Tegra$ sudo ./flash.sh jetson-nano-emmc mmcblk0p1

11.edit main.c(test code )
main.c (10.4 KB)
12.build and loopback test

n@n:~$ gcc -o test.out main.c
n@n:~$ sudo ./test.out
spi mode: 0x0 /dev/spidev0.0
bits per word: 8
max speed: 2000000 Hz (2000 KHz)
delay: 0
cs_change:0 pad:0 mode:0
send:10
TX | 60 00 00 20 00 00 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | `.........
RX | 60 00 00 20 00 00 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | `.........

13.loopback test OK
14.However view the signal on oscilloscope,the signal is bad.Because of the SPI CLOCK signal is unnecessary in loopback test ,the loopback test can run successfully

Could you try connect SPI0 and SPI1 to do the device loopback test to check the scope too.

Thanks.

Have reference to below relative topic.

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