Orin NX 16GB spi pinmux not work

I am using Orin NX 16GB with a custom board, R35.3.1 , I modify this dtsi to config spi1 pinmux:

bootloader/t186ref/BCT/tegra234-mb1-bct-pinmux-p3767-hdmi-a03.dtsi

my spi1 pinnux is

spi1_sck_pz3 {
        nvidia,pins = "spi1_sck_pz3";
        nvidia,function = "spi1";
        nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
        nvidia,tristate = <TEGRA_PIN_ENABLE>;
        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
        nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
        nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};

spi1_miso_pz4 {
        nvidia,pins = "spi1_miso_pz4";
        nvidia,function = "spi1";
        nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
        nvidia,tristate = <TEGRA_PIN_ENABLE>;
        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
        nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
        nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};

spi1_mosi_pz5 {
        nvidia,pins = "spi1_mosi_pz5";
        nvidia,function = "spi1";
        nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
        nvidia,tristate = <TEGRA_PIN_ENABLE>;
        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
        nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
        nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_cs0_pz6 {
        nvidia,pins = "spi1_cs0_pz6";
        nvidia,function = "spi1";
        nvidia,pull = <TEGRA_PIN_PULL_UP>;
        nvidia,tristate = <TEGRA_PIN_ENABLE>;
        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
        nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
        nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};

spi1_cs1_pz7 {
        nvidia,pins = "spi1_cs1_pz7";
        nvidia,function = "spi1";
        nvidia,pull = <TEGRA_PIN_PULL_UP>;
        nvidia,tristate = <TEGRA_PIN_ENABLE>;
        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
        nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
        nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};

here is my p3509-a02+p3767-0000.conf

DEFAULT_EMC_FUSE="0";
PINMUX_CONFIG="tegra234-mb1-bct-pinmux-p3767-hdmi-a03.dtsi";
PMC_CONFIG="tegra234-mb1-bct-padvoltage-p3767-hdmi-a03.dtsi";
BPFDTB_FILE="tegra234-bpmp-3767-0000-a02-3509-a02.dtb";
DTB_FILE="tegra234-p3767-0000-p3509-a02.dtb";
TBCDTB_FILE="${DTB_FILE}";
EMMC_CFG="flash_t234_qspi.xml";

when flashed the system, I check the spi function not worked, the pinmux setting not worked

root@w:~# cat /sys/kernel/debug/pinctrl/pinctrl-handles 
Requested pin control handlers their pinmux maps:
device: c360000.pmc current state: default
  state: default
    type: CONFIGS_PIN controller c360000.pmc pin sdmmc1-hv (56)config 00000080
    type: CONFIGS_PIN controller c360000.pmc pin sdmmc3-hv (60)config 00000080
device: 3400000.sdhci current state: sdmmc-3v3
  state: sdmmc-3v3
    type: CONFIGS_PIN controller c360000.pmc pin sdmmc1-hv (56)config 00000112
  state: sdmmc-1v8
    type: CONFIGS_PIN controller c360000.pmc pin sdmmc1-hv (56)config 00000012
  state: sdmmc-sdexp-enable
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat0_pj2 (98)config enable-input=0
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat1_pj3 (97)config enable-input=0
    type: MUX_GROUP controller 2430000.pinmux group: sdmmc1_dat2_pj4 (96) function: rsvd1 (56)
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat2_pj4 (96)config enable-input=0
    type: MUX_GROUP controller 2430000.pinmux group: sdmmc1_dat3_pj5 (95) function: rsvd1 (56)
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat3_pj5 (95)config enable-input=0
  state: sdmmc-sdexp-disable
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat0_pj2 (98)config enable-input=1
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat1_pj3 (97)config enable-input=1
    type: MUX_GROUP controller 2430000.pinmux group: sdmmc1_dat2_pj4 (96) function: sdmmc1 (31)
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat2_pj4 (96)config enable-input=1
    type: MUX_GROUP controller 2430000.pinmux group: sdmmc1_dat3_pj5 (95) function: sdmmc1 (31)
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat3_pj5 (95)config enable-input=1
root@w:~# 


root@w:~# dmesg | grep spi
[   11.251281] spi-tegra114 3210000.spi: Adding to iommu group 1
[   11.273474] spi-tegra114 3230000.spi: Adding to iommu group 1
root@w:~# 


BTW, when I set pinmux by command , spi1 fuction works well,

devmem2 0x0243d008 w 0x00000400 # spi1_cs0
devmem2 0x0243d018 w 0x00000450 # spi1_miso
devmem2 0x0243d028 w 0x00000400 # spi1_sck
devmem2 0x0243d038 w 0x00000400 # spi1_cs1
devmem2 0x0243d040 w 0x00000400 # spi1_mosi

please help me to solve this. thanks

1 Like

Hi WakkeWang,

Have you tried to use pinmux spreadsheet to modify pinmux to enable SPI?
Jetson AGX Orin Platform Adaptation and Bring-Up — Changing the Pinmux

I follow the step of spreedsheet, and use the following dtsi producted also failed, the spi1 not worked.
tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi (3.7 KB)
tegra234-mb1-bct-pinmux-p3767-hdmi-a03.dtsi (65.8 KB)

and here is the flash log
flash_orin_nx_log.txt (389.0 KB)

root@w:~# cat /sys/kernel/debug/pinctrl/pinctrl-handles 
Requested pin control handlers their pinmux maps:
device: c360000.pmc current state: default
  state: default
    type: CONFIGS_PIN controller c360000.pmc pin sdmmc1-hv (56)config 00000080
    type: CONFIGS_PIN controller c360000.pmc pin sdmmc3-hv (60)config 00000080
device: 3400000.sdhci current state: sdmmc-3v3
  state: sdmmc-3v3
    type: CONFIGS_PIN controller c360000.pmc pin sdmmc1-hv (56)config 00000112
  state: sdmmc-1v8
    type: CONFIGS_PIN controller c360000.pmc pin sdmmc1-hv (56)config 00000012
  state: sdmmc-sdexp-enable
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat0_pj2 (98)config enable-input=0
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat1_pj3 (97)config enable-input=0
    type: MUX_GROUP controller 2430000.pinmux group: sdmmc1_dat2_pj4 (96) function: rsvd1 (56)
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat2_pj4 (96)config enable-input=0
    type: MUX_GROUP controller 2430000.pinmux group: sdmmc1_dat3_pj5 (95) function: rsvd1 (56)
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat3_pj5 (95)config enable-input=0
  state: sdmmc-sdexp-disable
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat0_pj2 (98)config enable-input=1
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat1_pj3 (97)config enable-input=1
    type: MUX_GROUP controller 2430000.pinmux group: sdmmc1_dat2_pj4 (96) function: sdmmc1 (31)
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat2_pj4 (96)config enable-input=1
    type: MUX_GROUP controller 2430000.pinmux group: sdmmc1_dat3_pj5 (95) function: sdmmc1 (31)
    type: CONFIGS_GROUP controller 2430000.pinmux group sdmmc1_dat3_pj5 (95)config enable-input=1

Hi WakkeWang,

Could you help to refer to the following thread for verifying SPI loopback test?
How to set gpio for spi? - #27 by DaneLLL

  1. Connect MOSI of SPI1 to MISO
  2. then spi_test
root@w:~# ./spidev_test -D/dev/spidev0.0 -n100 -g8,3968 -u2000,8000
/dev/spidev0.0: TEST FAILED !!!!! (status:-1)
root@w:~# 
root@w:~# 
root@w:~# ./spidev_test -D/dev/spidev0.1 -n100 -g8,3968 -u2000,8000
/dev/spidev0.1: TEST FAILED !!!!! (status:-1)
root@w:~# 

But when I modify the pinmux by hand, it works

root@w:~# cat  spi_pinmux.sh 
#!/bin/sh -e

devmem2 0x0243d008 w 0x00000400 # spi1_cs0
devmem2 0x0243d018 w 0x00000450 # spi1_miso
devmem2 0x0243d028 w 0x00000400 # spi1_sck
devmem2 0x0243d038 w 0x00000400 # spi1_cs1
devmem2 0x0243d040 w 0x00000400 # spi1_mosi

exit 0
root@w:~# 
root@w:~# 
root@w:~# sh spi_pinmux.sh 
/dev/mem opened.
Memory mapped at address 0xffffbd7d9000.
Value at address 0x243D008 (0xffffbd7d9008): 0x400
Written 0x400; readback 0x400
/dev/mem opened.
Memory mapped at address 0xffffbb671000.
Value at address 0x243D018 (0xffffbb671018): 0x450
Written 0x450; readback 0x450
/dev/mem opened.
Memory mapped at address 0xffffb9e64000.
Value at address 0x243D028 (0xffffb9e64028): 0x400
Written 0x400; readback 0x400
/dev/mem opened.
Memory mapped at address 0xffff82e01000.
Value at address 0x243D038 (0xffff82e01038): 0x400
Written 0x400; readback 0x400
/dev/mem opened.
Memory mapped at address 0xffffbdb4c000.
Value at address 0x243D040 (0xffffbdb4c040): 0x400
Written 0x400; readback 0x400
root@w:~# 
root@w:~# 
root@w:~# 
root@w:~# 
root@w:~# ./spidev_test -D/dev/spidev0.0 -n100 -g8,3968 -u2000,8000
/dev/spidev0.0: TEST PASSED 
root@w:~# 


From your flash log, do you make sure the modified device tree replace the file in the right path?

copying pinmux_config(/mnt/R35.3.1/orin/Linux_for_Tegra/bootloader/t186ref/BCT/tegra234-mb1-bct-pinmux-p3767-hdmi-a03.dtsi)... done.
...
./mfi_p3509-a02+p3767-0000/bootloader/tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi

Please help to check the register after boot up and see if it is expected.

devmem2 0x0243d008 # spi1_cs0
devmem2 0x0243d018 # spi1_miso
devmem2 0x0243d028 # spi1_sck
devmem2 0x0243d038 # spi1_cs1
devmem2 0x0243d040 # spi1_mosi

the dtsi have already been replaced correctly.

root@yzj-ThinkPad-E460:/mnt/R35.3.1/orin/Linux_for_Tegra# md5sum ./mfi_p3509-a02+p3767-0000/bootloader/tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi bootloader/tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi
6848d30becbb1af63952bcceecd61350  ./mfi_p3509-a02+p3767-0000/bootloader/tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi
6848d30becbb1af63952bcceecd61350  bootloader/tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi


root@yzj-ThinkPad-E460:/mnt/R35.3.1/orin/Linux_for_Tegra# md5sum ./mfi_p3509-a02+p3767-0000/bootloader/tegra234-mb1-bct-pinmux-p3767-hdmi-a03.dtsi bootloader/t186ref/BCT/tegra234-mb1-bct-pinmux-p3767-hdmi-a03.dtsi
83dd5f04ffd188cb56518573f3bdced8  ./mfi_p3509-a02+p3767-0000/bootloader/tegra234-mb1-bct-pinmux-p3767-hdmi-a03.dtsi
83dd5f04ffd188cb56518573f3bdced8  bootloader/t186ref/BCT/tegra234-mb1-bct-pinmux-p3767-hdmi-a03.dtsi


and here is the dump of regs after reboot

rroot@w:~# devmem2 0x0243d008 # spi1_cs0
/dev/mem opened.
Memory mapped at address 0xffff9e1b3000.
Value at address 0x243D008 (0xffff9e1b3008): 0x8
root@w:~# 
root@w:~# 
root@w:~# devmem2 0x0243d018 # spi1_miso
/dev/mem opened.
Memory mapped at address 0xffffaf452000.
Value at address 0x243D018 (0xffffaf452018): 0x54
root@w:~# 
root@w:~# 
root@w:~# devmem2 0x0243d028 # spi1_sck
/dev/mem opened.
Memory mapped at address 0xffff8ef7a000.
Value at address 0x243D028 (0xffff8ef7a028): 0x1008
root@w:~# 
root@w:~# 
root@w:~# 
root@w:~# devmem2 0x0243d038 # spi1_cs1
/dev/mem opened.
Memory mapped at address 0xffffa6c20000.
Value at address 0x243D038 (0xffffa6c20038): 0x8
root@w:~# 
root@w:~# 
root@w:~# devmem2 0x0243d040 # spi1_mosi
/dev/mem opened.
Memory mapped at address 0xffffb63f1000.
Value at address 0x243D040 (0xffffb63f1040): 0x4
root@w:~# 


Hi @KevinFFF , any idea?

Did you do full flash after modifying pinmux?

It seems the register of these pins been modified somewhere at boot up.

Yes I did the full flash which can see by the flashlog.
and here is the dtb I use

 dtc -I fs -O dts -o Orin_Nx_dumped_from_procfs.dts /proc/device-tree

Orin_Nx_dumped_from_procfs.dts (425.0 KB)

Could you help to remove the following lines in Linux_for_Tegra/bootloader/tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi and flash the board to verify?

@@ -46,11 +46,6 @@
                                TEGRA234_MAIN_GPIO(Y, 3)
                                TEGRA234_MAIN_GPIO(Y, 4)
                                TEGRA234_MAIN_GPIO(Z, 1)
-                               TEGRA234_MAIN_GPIO(Z, 3)
-                               TEGRA234_MAIN_GPIO(Z, 4)
-                               TEGRA234_MAIN_GPIO(Z, 5)
-                               TEGRA234_MAIN_GPIO(Z, 6)
-                               TEGRA234_MAIN_GPIO(Z, 7)
                                TEGRA234_MAIN_GPIO(P, 6)
                                TEGRA234_MAIN_GPIO(Q, 5)
                                TEGRA234_MAIN_GPIO(Q, 6)

Hi @KevinFFF , it works, thanks for your positive help

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