Spidev of Jetson nano-emmc core board cannot be used

Just find below link for the r32.3.1 for reference. For r32.4.3 may need time to check.

For r32.4.3 emmc version:

  1. Apply the kernel patch for GPIO to build the Image and replace it.
commit 7035ec4c1c3de0535f8491c1ca96814325bd8fc4
Author: snchen <snchen@nvidia.com>
Date:   Fri Sep 6 15:56:47 2019 +0800

    gpio: tegra: fix failed to set the to SFIO

    Can't set the GPIO pin to SFIO by device tree.

    bug 200549751

    Change-Id: Idd331a594cb82b3a5ea4fc47c2784490ff99629f
    Signed-off-by: snchen <snchen@nvidia.com>

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index e101044..09dd6e4 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -217,6 +217,11 @@ static void tegra_gpio_enable(struct tegra_gpio_info *tgi, int gpio)
        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 int tegra_gpio_request(struct gpio_chip *chip, unsigned offset)

 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)

  1. Add below to the device tree.
               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>;
  1. modify the pinmux in device tree like "spi1_miso_pc1 " …
2 Likes

To help others debug SPI0 withe the eMMC module, Let me summarize the process:
For r32.4.3 emmc version

  1. Modify the following files according to the contents of the patch package, tegra210-porg-gpio-p3448-0002-b00.dtsi tegra210-porg-pinmux-p3448-0002-b00.dtsi tegra210-porg-p3448-common.dtsi
    https://github.com/gtjoseph/jetson-nano-support/blob/master/spi/l4t-sources-kernel-hardware-nvidia-platform-t210-porg-spidev0-0.patch

  2. Apply the kernel patch for GPIO to build the Image and replace it.

commit 7035ec4c1c3de0535f8491c1ca96814325bd8fc4
Author: snchen snchen@nvidia.com
Date: Fri Sep 6 15:56:47 2019 +0800

gpio: tegra: fix failed to set the to SFIO

Can't set the GPIO pin to SFIO by device tree.

bug 200549751

Change-Id: Idd331a594cb82b3a5ea4fc47c2784490ff99629f
Signed-off-by: snchen <snchen@nvidia.com>

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index e101044…09dd6e4 100644
— a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -217,6 +217,11 @@ static void tegra_gpio_enable(struct tegra_gpio_info *tgi, int gpio)
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 int tegra_gpio_request(struct gpio_chip *chip, unsigned offset)

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)

3)Flash the kernel and dtb again.

2 Likes

81/5000
For r32.4.3 EMMC version, I modified kernel GPIO and device tree, but did not modify Uboot and still did not work. Could you please tell me how to use THE SPI function of R32.4.3 EMMC version

EMMC version just need configure by the jetson-io.py that should be working without modified the uboot.

Blockquote

Hi, @guoyj @354236533 have you make spi work on r32.4.3 emmc version?
I just follow above steps to enable spi1, but the spi1 sck pin23 keeps high.
Thanks

Hi, @ShaneCCC

I just follow above steps to change kernel and device tree, but the spi1 still not work.

The pin23 spi1 sck does not give periodical waveform and keeps high.

tegra_gpio shows

C: 0:2 08 08 08 08 00 00 000000

it's ok

and 

cat /proc/device-tree/pinmux@700008d4/common/spi1_sck_pc2/nvidia\,function

it shows spi1

it should be ok too!

The i use devmem2 read 0x70003058, 0xe045 read back. 
The register still keeps  at value 10 ("rsvd1"  not "spi1"),
But sd card nano read back 0xe044, that value represent the register is changed to spi1.

Can device tree change this pin-function correctly on emmc nano? Is there anything i missed?
		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>;
 
Using  devmem2  can enable spi1 and spi2 by comparing the reg value with sd card version module.

But modifying device tree is more straight, we just hope enable spi through device tree.

Can you give more suggestion?

Thanks

Hi, I am also trying to use the SPI on r32.4.3 eMMC jetson nano. Applying the patch and modifying the device tree were not enough and I did not manage to make it works. @ShaneCCC, jetson-io.py does not seem to work on eMMC version (it just open quickly and close).

Maybe someone knows how devmem2 can be used to enable spi1 and spi2?

hi @elieva.pignat

enable spi1

sudo ./devmem2 0x70003050 h 0xe044
sudo ./devmem2 0x70003054 h 0xe044
sudo ./devmem2 0x70003058 h 0xe044
sudo ./devmem2 0x7000305c h 0xe048
suod ./devmem2 0x70003060 h 0xe048

you should also apply the gpio kernel patch
and
add something like below maybe unnecessary (i just added it)

     spi@7000d400 { /* SPI 1 to 40 pin header */
              status = "okay";
  •          num-cs = <1>;
    
  •   cs-gpios = <&gpio TEGRA_GPIO(C, 3) GPIO_ACTIVE_LOW>;
    
  •   spi0_0 {
    
  •   	#address-cells = <0x1>;
    
  •   	#size-cells = <0x0>;
    
  •   	compatible = "spidev";
    
  •   	status = "okay";
    
  •   	reg = <0>;
    
  •   	spi-max-frequency = <65000000>;
    
  •   	controller-data {
    
  •   		nvidia,cs-setup-clk-count = <0x1e>;
    
  •   		nvidia,cs-hold-clk-count = <0x1e>;
    
  •   		nvidia,rx-clk-tap-delay = <0x1f>;
    
  •   		nvidia,tx-clk-tap-delay = <0x0>;
    
  •   	};
    
  •   };
    
    };

hi @elieva.pignat

enable spi2

I just test spi2 sck pin13, and get waveform from the pin .

sudo ./devmem2 0x6000d004 h 0x0000
sudo ./devmem2 0x70003064 h 0x6044
sudo ./devmem2 0x70003068 h 0x6044
sudo ./devmem2 0x7000306c h 0x6044
sudo ./devmem2 0x70003070 h 0x6048
suod ./devmem2 0x70003074 h 0x6048

1 Like

Thanks @anhuimain !
I tested for spi2 with your command and it works!! I tested on a custom board where the spi is directly connected to the devices (and not through the 40-pin headers).