Getting other 2 SPIs of TX2 working

Hello,

For our custom carrier board, we are using all three SPIs (spi@3210000, spi@3240000 and spi@260000). I was able to test spi@3240000 (exposed at J21) with the steps mentions in Jetson/TX2 SPI (Jetson/TX2 SPI - eLinux.org). I tried making the same dtb changes (adding spi@0…) under other two SPI entries, but was not able to get them working with /dev/spidev0.0. (I was trying the dtb modification of one SPI at a time, not all of them together without any change in the spi@0 entry).

Additionally, I read that the AON SPI SCR LCK bit is set at boot. I tried changing the default setting by updating the minimal_scr.cfg and mobile_scr.cfg under boot loader folder and reflashed uboot (using the flash utility). But the register values doesn’t seem to change.

How can I make the other 2 SPIs working using the spidev driver? Any inputs welcome.

For the spi@3210000 have a check below pin. Find reg tools to read the address 0x2430000 … to confirm it set as SPI1

<i>0243d000</i>: PADCTL_UART_GPIO_WAN8_0                                 = 0x00000458 //
          E_SCHMT                                                 = 0x00000000 // [12:12] DISABLE [DISABLE=0,ENABLE=1]
          E_OD                                                    = 0x00000000 // [11:11] DISABLE [DISABLE=0,ENABLE=1]
          GPIO_SF_SEL                                             = 0x00000001 // [10:10] HSIO [GPIO=0,HSIO=1]
          E_LPDR                                                  = 0x00000000 // [08:08] DISABLE [DISABLE=0,ENABLE=1]
          E_INPUT                                                 = 0x00000001 // [06:06] ENABLE [DISABLE=0,ENABLE=1]
          TRISTATE                                                = 0x00000001 // [04:04] TRISTATE [PASSTHROUGH=0,TRISTATE=1]
          PUPD                                                    = 0x00000002 // [03:02] PULL_UP [NONE=0,PULL_DOWN=1,PULL_UP=2,RSVD=3]
          PM                                                      = 0x00000000 // [01:00] RSVD0 [RSVD0=0,RSVD1=1,RSVD3=3,SPI1=2]


<i>0243d008</i>: PADCTL_UART_GPIO_WAN7_0                                 = 0x00000454 //
          E_SCHMT                                                 = 0x00000000 // [12:12] DISABLE [DISABLE=0,ENABLE=1]
          E_OD                                                    = 0x00000000 // [11:11] DISABLE [DISABLE=0,ENABLE=1]
          GPIO_SF_SEL                                             = 0x00000001 // [10:10] HSIO [GPIO=0,HSIO=1]
          E_LPDR                                                  = 0x00000000 // [08:08] DISABLE [DISABLE=0,ENABLE=1]
          E_INPUT                                                 = 0x00000001 // [06:06] ENABLE [DISABLE=0,ENABLE=1]
          TRISTATE                                                = 0x00000001 // [04:04] TRISTATE [PASSTHROUGH=0,TRISTATE=1]
          PUPD                                                    = 0x00000001 // [03:02] PULL_DOWN [NONE=0,PULL_DOWN=1,PULL_UP=2,RSVD=3]
          PM                                                      = 0x00000000 // [01:00] RSVD0 [RSVD0=0,RSVD1=1,RSVD3=3,SPI1=2]


<i>0243d010</i>: PADCTL_UART_GPIO_WAN6_0                                 = 0x00000454 //
          E_SCHMT                                                 = 0x00000000 // [12:12] DISABLE [DISABLE=0,ENABLE=1]
          E_OD                                                    = 0x00000000 // [11:11] DISABLE [DISABLE=0,ENABLE=1]
          GPIO_SF_SEL                                             = 0x00000001 // [10:10] HSIO [GPIO=0,HSIO=1]
          E_LPDR                                                  = 0x00000000 // [08:08] DISABLE [DISABLE=0,ENABLE=1]
          E_INPUT                                                 = 0x00000001 // [06:06] ENABLE [DISABLE=0,ENABLE=1]
          TRISTATE                                                = 0x00000001 // [04:04] TRISTATE [PASSTHROUGH=0,TRISTATE=1]
          PUPD                                                    = 0x00000001 // [03:02] PULL_DOWN [NONE=0,PULL_DOWN=1,PULL_UP=2,RSVD=3]
          PM                                                      = 0x00000000 // [01:00] RSVD0 [RSVD0=0,RSVD1=1,RSVD3=3,SPI1=2]


<i>0243d018</i>: PADCTL_UART_GPIO_WAN5_0                                 = 0x00000454 //
          E_SCHMT                                                 = 0x00000000 // [12:12] DISABLE [DISABLE=0,ENABLE=1]
          E_OD                                                    = 0x00000000 // [11:11] DISABLE [DISABLE=0,ENABLE=1]
          GPIO_SF_SEL                                             = 0x00000001 // [10:10] HSIO [GPIO=0,HSIO=1]
          E_LPDR                                                  = 0x00000000 // [08:08] DISABLE [DISABLE=0,ENABLE=1]
          E_INPUT                                                 = 0x00000001 // [06:06] ENABLE [DISABLE=0,ENABLE=1]
          TRISTATE                                                = 0x00000001 // [04:04] TRISTATE [PASSTHROUGH=0,TRISTATE=1]
          PUPD                                                    = 0x00000001 // [03:02] PULL_DOWN [NONE=0,PULL_DOWN=1,PULL_UP=2,RSVD=3]
          PM                                                      = 0x00000000 // [01:00] RSVD0 [RSVD0=0,RSVD1=1,RSVD3=3,SPI1=2]

Thank you for the response dear ShaneCCC. I will try that and will update you soon.

Dear ShaneCCC,

I managed to get the spi@3210000 working with the spidev0.0 driver using the steps given in Jetson/TX2 SPI (Jetson/TX2 SPI - eLinux.org). I was having trouble before, since I missed a pullup resistor that was supposed to be pulled down in our custom carrier board.

However, as soon as I make the dtb changes, 3 of the GPIOs stops working. These are:

B25 (GPIO6_TOUCH_INT) GPIO3_PAA.07 303
F2 (GPIO19_AUD_RST) GPIO3_PJ.06 398
F7 (GPIO1_CAM1_PWR) GPIO3_PN.02 426

I am not able to export them using sysfs (gives me ‘resource busy’) error. Additionally, while I can export the GPIO 298 (G14 (GPIO9_MOTION_INT, GPIO3_PAA.02), a write to the direction file crashes the entire system.

I am able to reproduce this using a Jetson board. Steps as follows:

  1. Build the latest kernel and make dtb changes to enable spidev as explained here: Jetson/TX2 SPI - eLinux.org

  2. Try exporting the following GPIOs - 303, 398, 426 as shown below:

ubuntu@tegra:~$sudo -s

root@tegra:~# echo 303 > /sys/class/gpio/export
bash: echo: write error: Device or resource busy
root@tegra:~# echo 398 > /sys/class/gpio/export
bash: echo: write error: Device or resource busy
root@tegra:~# echo 426 > /sys/class/gpio/export
bash: echo: write error: Device or resource busy
  1. Confirm they are not held by other drivers
root@tegra:~# cat /sys/kernel/debug/gpio
GPIOs 216-223, platform/max77620-gpio, max77620-gpio, can sleep:
 gpio-216 (                    |external-connection:) in  hi    
 gpio-221 (                    |spmic_gpio_input_5  ) in  lo    
 gpio-222 (                    |spmic_gpio_input_6  ) in  hi    

GPIOs 224-239, i2c/0-0077, tca9539, can sleep:
 gpio-227 (                    |en-vdd-sys          ) out lo    
 gpio-228 (                    |lcd-bias-en-rail    ) out hi    
 gpio-233 (                    |en-vdd-cam          ) out lo    
 gpio-234 (                    |en-vdd-cam-1v2      ) out lo    

GPIOs 240-255, i2c/0-0074, tca9539, can sleep:
 gpio-240 (                    |vdd-usb2-5v         ) out lo    
 gpio-241 (                    |en-vdd-ts-1v8       ) out hi    
 gpio-242 (                    |en-vdd-ts-hv-3v3    ) out hi    
 gpio-243 (                    |en-vdd-disp-3v3     ) out lo    
 gpio-244 (                    |vdd-fan             ) out hi    
 gpio-247 (                    |en-mdm-pwr-3v7      ) out lo    
 gpio-249 (                    |en-vdd-disp-1v8     ) out lo    
 gpio-250 (                    |dis-vdd-1v2         ) out hi    
 gpio-252 (                    |vdd-hdmi            ) out hi    
 gpio-253 (                    |en-vdd-cam-hv-2v8   ) out lo    

GPIOs 256-447, platform/2200000.gpio, tegra-gpio:
 gpio-317 (                    |reset_gpio          ) out lo    
 gpio-348 (                    |vdd-usb0-5v         ) out lo    
 gpio-349 (                    |vdd-usb1-5v         ) out lo    
 gpio-356 (                    |eqos_phy_reset      ) out hi    
 gpio-357 (                    |eqos_phy_intr       ) in  hi    
 gpio-360 (                    |wlan_pwr            ) out lo    
 gpio-362 (                    |cam1-pwdn           ) out lo    
 gpio-377 (                    |hdmi2.0_hpd         ) in  hi    
 gpio-380 (                    |wp                  ) in  hi    
 gpio-381 (                    |cd                  ) in  lo    
 gpio-382 (                    |en-vdd-sd           ) out lo    
 gpio-392 (                    |cam_pwdn_gpio       ) out lo    
 gpio-393 (                    |cam1-rst            ) out lo    
 gpio-397 (                    |cam_reset_gpio      ) out lo    
 gpio-415 (                    |external-connection:) in  lo    
 gpio-420 (                    |bt_ext_wake         ) out hi    

GPIOs 448-511, platform/c2f0000.gpio, tegra-gpio-aon:
 gpio-464 (                    |temp_alert          ) in  hi    
 gpio-504 (                    |Power               ) in  hi    
 gpio-505 (                    |Volume Up           ) in  hi    
 gpio-506 (                    |Volume Down         ) in  hi    
 gpio-507 (                    |wifi-wake-ap        ) in  hi    
 gpio-508 (                    |bt_host_wake        ) in  hi    
root@tx2-1:~#
  1. Export GPIO 298
root@tegra:~# echo 298 > /sys/class/gpio/export
root@tegra:~# echo out > /sys/class/gpio/gpio298/direction [This will crash the system]

I am using latest JetPack 3.3

ubuntu@tegra:~$cat /etc/nv_tegra_release 
# R28 (release), REVISION: 2.1, GCID: 11272647, BOARD: t186ref, EABI: aarch64, DATE: Thu May 17 07:29:06 UTC 2018
...
ubuntu@tegra:~$uname -a
Linux tx2-1 4.4.38 #2 SMP PREEMPT Tue Jan 15 11:17:32 +08 2019 aarch64 aarch64 aarch64 GNU/Linux

Can you please try these steps and let me know:
a. Whether you can reproduce
b. If so, how to fix it

We have used these GPIOs in the carrier board for certain functions and with the SPI modification, we are unable to use them. Without the SPI modifications, I am able to use the GPIOs without any issues.

Thanks in advance.

Could you read below address to compare if any different before and after enable the SPI.

GPIO PJ6 
	0x02431010: PADCTL_AUDIO_GPIO_AUD1_0                               
GPIO PAA7
	0x0c303000: PADCTL_AO_HV_CAN_GPIO7_0                               
GPIO PN2
	0x02430030: PADCTL_CAM_GPIO_CAM3_0

Unfortunately, we have not been able to test this yet. We switched to using TX1 for now since it doesn’t seem to have any issues with the GPIOs. I will update here if we ever go down this path again.

Thanks once again for the support dear ShaneCCC.