Spi config

  • 1 BSP environment:
    TX2 jetpack 4.6 L4T R32.6.1 kernel 4.9 aarch64
    TX2 (p3310)
  • 2 Problem:
    the project need spi (H15 G16 G15) config. we find that thay are setted as gpio, how to change them?
root@ubuntu-desktop:/home/ubuntu# cat /sys/kernel/debug/gpio
...
 gpio-291 (                    )
 gpio-292 (                    )
 gpio-293 (                    )
 gpio-294 (                    )
 gpio-295 (                    )
 gpio-296 (AO_DMIC_IN_DAT      |gpio_can_stb        ) out hi    
 gpio-297 (AO_DMIC_IN_CLK      |gpio_can_en         ) out hi    
 gpio-298 (GPIO9_MOTION_INT    )
 gpio-299 (                    )
 gpio-300 (                    )
 gpio-301 (                    )
 gpio-302 (                    |gpio_can_stb        ) out hi    
 gpio-303 (                    |gpio_can_en         ) out hi    
 gpio-304 (                    )
 gpio-305 (                    )
 gpio-306 (                    )
 gpio-307 (                    )
 gpio-308 (                    )
 gpio-309 (                    )
 gpio-310 (                    )
 gpio-311 (                    )
 gpio-312 (                    |Power               ) in  hi    
 gpio-313 (                    |Volume Up           ) in  hi    
 gpio-314 (                    |Volume Down         ) in  hi    
 gpio-315 (                    |wifi-wake-ap        ) in  lo    
 gpio-316 (                    |bt_host_wake        ) in  lo    
gpiochip0: GPIOs 320-511, parent: platform/2200000.gpio, tegra-gpio:
 gpio-320 (                    )
 gpio-321 (                    )
 gpio-322 (                    )
 gpio-323 (                    )
 gpio-324 (                    )
 gpio-325 (                    )
 gpio-326 (                    )
 gpio-327 (                    )
 gpio-328 (                    )
 gpio-329 (                    )
 gpio-330 (                    )
 gpio-331 (                    )
 gpio-332 (                    )
 gpio-333 (                    )
 gpio-334 (                    )
 gpio-335 (                    )
 gpio-336 (                    )
 gpio-337 (                    )
 gpio-338 (                    )
 gpio-339 (                    )
 gpio-340 (                    )
 gpio-341 (                    )
 gpio-342 (                    )
 gpio-343 (                    )
 gpio-344 (                    )
 gpio-345 (                    )
 gpio-346 (                    )
 gpio-347 (                    )
 gpio-348 (                    )
 gpio-349 (                    )
 gpio-350 (                    )
 gpio-351 (                    )
 gpio-352 (                    )
 gpio-353 (                    )
 gpio-354 (                    )
 gpio-355 (                    )
 gpio-356 (                    )
 gpio-357 (                    )
 gpio-358 (                    )
 gpio-359 (                    )
 gpio-360 (                    )
 gpio-361 (                    )
 gpio-362 (                    )
 gpio-363 (                    )
 gpio-364 (                    )
 gpio-365 (                    )
 gpio-366 (                    )
 gpio-367 (                    )
 gpio-368 (                    )
 gpio-369 (                    )
 gpio-370 (                    )
 gpio-371 (                    )
 gpio-372 (                    )
 gpio-373 (                    )
 gpio-374 (                    )
 gpio-375 (                    )
 gpio-376 (                    )
 gpio-377 (                    )
 gpio-378 (                    )
 gpio-379 (                    )
 gpio-380 (                    )
 gpio-381 (                    |reset_gpio          ) out lo    
 gpio-382 (                    )
 gpio-383 (                    )
 gpio-384 (                    )
 gpio-385 (                    )
 gpio-386 (                    )
 gpio-387 (                    )
 gpio-388 (GPIO8_ALS_PROX_INT  )
 gpio-389 (GPIO11_AP_WAKE_BT   )
 gpio-390 (                    )
 gpio-391 (                    )
 gpio-392 (I2S0_CLK            )
 gpio-393 (I2S0_SDOUT          )
 gpio-394 (I2S0_SDIN           )
 gpio-395 (I2S0_LRCLK          )
 gpio-396 (AUDIO_MCLK          )
 gpio-397 (GPIO20_AUD_INT      )
 gpio-398 (GPIO1_AUD_RST       |tlv320aic32x4 rstn  ) out hi    
 gpio-399 (                    )
 gpio-400 (                    )
 gpio-401 (                    )
 gpio-402 (                    )
 gpio-403 (                    )
 gpio-404 (                    )
 gpio-405 (                    )
 gpio-406 (                    )
 gpio-407 (                    )
 gpio-408 (                    )
 gpio-409 (                    )
 gpio-410 (                    )
 gpio-411 (                    )
 gpio-412 (                    |vdd-usb0-5v         ) out lo    
 gpio-413 (                    |vdd-usb1-5v         ) out lo    
 gpio-414 (                    )
 gpio-415 (                    )
 gpio-416 (                    )
 gpio-417 (                    )
 gpio-418 (                    )
 gpio-419 (                    )
 gpio-420 (                    |eqos_phy_reset      ) out hi    
 gpio-421 (                    )
 gpio-422 (                    )
 gpio-423 (                    )
 gpio-424 (                    |wlan_pwr            ) out hi    
 gpio-425 (                    )
 gpio-426 (                    )
 gpio-427 (SPI1_CLK            )
 gpio-428 (SPI1_MISO           )
 gpio-429 (SPI1_MOSI           )
 gpio-430 (SPI1_CS0            )
 gpio-431 (                    )
 gpio-432 (                    )
 gpio-433 (                    )
 gpio-434 (                    )
 gpio-435 (                    )
 gpio-436 (                    )
 gpio-437 (                    )
 gpio-438 (                    )
 gpio-439 (                    )
 gpio-440 (                    )
 gpio-441 (                    |hdmi2.0_hpd         ) in  lo    
 gpio-442 (                    )
 gpio-443 (                    )
 gpio-444 (                    |wp                  ) in  hi    
 gpio-445 (                    |cd                  ) in  hi    
 gpio-446 (                    |en-vdd-sd           ) out lo    
 gpio-447 (                    )
 gpio-448 (                    )
 gpio-449 (                    )
 gpio-450 (                    )
 gpio-451 (                    )
 gpio-452 (                    )
 gpio-453 (                    )
 gpio-454 (                    )
 gpio-455 (                    )
 gpio-456 (                    )
 gpio-457 (                    )
 gpio-458 (                    )
 gpio-459 (                    )
 gpio-460 (                    )
 gpio-461 (                    |camera-control-outpu) out hi    
 gpio-462 (                    )
 gpio-463 (                    )
 gpio-464 (                    )
 gpio-465 (                    )
 gpio-466 (UART0_RTS           )
 gpio-467 (UART0_CTS           )
 gpio-468 (                    )
 gpio-469 (                    )
 gpio-470 (                    )
 gpio-471 (                    )
 gpio-472 (                    )
 gpio-473 (                    )
 gpio-474 (                    )
 gpio-475 (                    )
 gpio-476 (                    )
 gpio-477 (                    )
 gpio-478 (                    )
 gpio-479 (                    |external-connection:) in  lo    
 gpio-480 (                    )
 gpio-481 (GPIO16_MDM_WAKE_AP  )
 gpio-482 (                    )
 gpio-483 (                    )
 gpio-484 (                    |bt_ext_wake         ) out hi    
 gpio-485 (                    )
 gpio-486 (                    )
 gpio-487 (                    )
 gpio-488 (                    )
 gpio-489 (                    )
 gpio-490 (                    )
 gpio-491 (                    )
 gpio-492 (                    )
 gpio-493 (                    )
 gpio-494 (                    )
 gpio-495 (                    )
 gpio-496 (                    )
 gpio-497 (                    )
 gpio-498 (                    )
 gpio-499 (                    )

so, could some one help to enable them?
we down load the pinmux excel, but so confused by the name. G16 named spi2_mosi and also named SPI1_DIN. Does the SPI1_DIN mean the above “gpio-429 (SPI1_MOSI )”?
and in the tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg file, there is “spi1” in the comment, are they specify the same pin?
what is the followiing so called “som connector”, “signal name”, and “ic ball name”, what is the difference?


tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg (28.6 KB)

Yes, you can confirm it by this link. NVIDIA Jetson TX2 J21 Header Pinout - JetsonHacks
And try use jetson-io to configure it.

Hi
unfortunately, helpless.
could some one give more details? and response to our questions one by one?
Regards

Have a check this document for the pin map guidance.

http://developer.nvidia.com/embedded/dlc/tx2-series-pin-function-names-guide-note

Hi
the following spreadsheet picture shows a red background, does it mean some error? how to do trouble shooting?

Suppose use for groping does not error.

Hi
we use the spreadsheet and pinmux-dts2cfg.py to create tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg.
should we modify something else? such as some dts files?

Hi

root@ubuntu-HP-288-Pro-G6-Microtower-PC:/home/ubuntu/nvidia/nvidia_sdk/JetPack_4.6_Linux_JETSON_TX2_TARGETS/Linux_for_Tegra/kernel/pinmux/t186# python pinmux-dts2cfg.py --pinmux addr_info.txt gpio_addr_info.txt  por_val.txt \
> --mandatory_pinmux_file mandatory_pinmux.txt tegra18x-0_jetson-tx2-config-template-pinmux.dtsi \
> tegra18x-0_jetson-tx2-config-template-gpio-default.dtsi 1.0 \
>  > ./0.cfg
ERROR: pin dap2_sclk_pc1(0x00000440) field nvidia,enable-input(0x00000040) is not matching, val = 0x01 expected = 0x00
ERROR: pin dap2_fs_pc4(0x00000440) field nvidia,enable-input(0x00000040) is not matching, val = 0x01 expected = 0x00
ERROR: pin dmic1_clk_pm1(0x00004441) field nvidia,enable-input(0x00000040) is not matching, val = 0x01 expected = 0x00
ERROR: pin dmic2_dat_pm2(0x00004441) field nvidia,enable-input(0x00000040) is not matching, val = 0x01 expected = 0x00
ERROR: pin dap4_sclk_pcc0(0x00004440) field nvidia,enable-input(0x00000040) is not matching, val = 0x01 expected = 0x00
ERROR: pin dap4_fs_pcc3(0x00004440) field nvidia,enable-input(0x00000040) is not matching, val = 0x01 expected = 0x00
ERROR: pin sdmmc4_dqs(0x00000444) field nvidia,tristate(0x00000010) is not matching, val = 0x00 expected = 0x01

could you explain this log, and tell us how to modify it?

what’s more, the previous

has configed H15 G15 G16 to spi1, but why it does not work?

pinmux.0x0243d078 = 0x00000409; # gpio_mdm4_py3: spi1, pull-up, tristate-disable, input-disable, lpdr-disable
pinmux.0x0243d0b0 = 0x00000440; # gen7_i2c_scl_pl0: i2c7, tristate-disable, input-enable, io_high_voltage-disable, lpdr-disable
pinmux.0x0243d0b8 = 0x00000440; # gen7_i2c_sda_pl1: i2c7, tristate-disable, input-enable, io_high_voltage-disable, lpdr-disable
pinmux.0x0243d0c8 = 0x00000440; # gen9_i2c_scl_pl2: i2c9, tristate-disable, input-enable, io_high_voltage-disable, lpdr-disable
pinmux.0x0243d0c0 = 0x00000440; # gen9_i2c_sda_pl3: i2c9, tristate-disable, input-enable, io_high_voltage-disable, lpdr-disable
pinmux.0x0243d0e8 = 0x00000410; # gp_pwm6_pl6: gp, tristate-enable, input-disable, lpdr-disable
pinmux.0x0243d0e0 = 0x00000410; # gp_pwm7_pl7: gp, tristate-enable, input-disable, lpdr-disable
pinmux.0x0243d018 = 0x00000402; # gpio_wan5_ph0: spi1, tristate-disable, input-disable, lpdr-disable
pinmux.0x0243d010 = 0x00000456; # gpio_wan6_ph1: spi1, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x0243d008 = 0x00000402; # gpio_wan7_ph2: spi1, tristate-disable, input-disable, lpdr-disable
pinmux.0x0243d000 = 0x0000040a; # gpio_wan8_ph3: spi1, pull-up, tristate-disable, input-disable, lpdr-disable

What do you mean doesn’t work?
Did you verify by loopback test?

Hi
we send data to the sensor, and then use oscilloscope to test the four pins: H14/GPIO_WAN5 H15/GPIO_WAN6 G15/GPIO_WAN7 G16/GPIO_WAN8, but all of them go flat.

And gpio debugfs shows these pins are configed as gpio. but in the tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg file, they are configed as spi1.

pinmux.0x0243d018 = 0x00000402; # gpio_wan5_ph0: spi1, tristate-disable, input-disable, lpdr-disable
pinmux.0x0243d010 = 0x00000456; # gpio_wan6_ph1: spi1, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x0243d008 = 0x00000402; # gpio_wan7_ph2: spi1, tristate-disable, input-disable, lpdr-disable
pinmux.0x0243d000 = 0x0000040a; # gpio_wan8_ph3: spi1, pull-up, tristate-disable, input-disable, lpdr-disable

on the other hand: G13/GPIO_CAM4 F14/GPIO_CAM5 F13/GPIO_CAM6 E14/GPIO_CAM7 are config as spi1.

but, tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg file config them to rsvd2.

pinmux.0x02430038 = 0x00000056; # gpio_cam4_pn3: rsvd2, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x02430040 = 0x00000056; # gpio_cam5_pn4: rsvd2, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x02430048 = 0x00000056; # gpio_cam6_pn5: rsvd2, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x02430050 = 0x00000058; # gpio_cam7_pn6: rsvd0, pull-up, tristate-enable, input-enable, lpdr-disable

what’s more, we echo 0 to gpio value, and use multimeter to test GPIO_WAN8, it is 6.52 v. and it echo 1 to value, it is 8.3v. why?

root@ubuntu-desktop:/sys/class/gpio/gpio379# ls
active_low  device  direction  edge  power  subsystem  uevent  value
root@ubuntu-desktop:/sys/class/gpio/gpio379# cat active_low 
0
root@ubuntu-desktop:/sys/class/gpio/gpio379# cat direction 
in
root@ubuntu-desktop:/sys/class/gpio/gpio379# cat value 
0
root@ubuntu-desktop:/sys/class/gpio/gpio379# echo out > direction 
root@ubuntu-desktop:/sys/class/gpio/gpio379# echo 1 > value 
root@ubuntu-desktop:/sys/class/gpio/gpio379# cat direction 
out
root@ubuntu-desktop:/sys/class/gpio/gpio379# cat value 
1

Please use the devmem read those REG to confirm the configuration.
Also you can use devmem to write to correct value to verify the SPI functionality.

Hi

root@ubuntu-desktop:/sys/class/gpio/gpio379# devmem2 0x0243d018 w
/dev/mem opened.
Memory mapped at address 0x7f919ab000.
Value at address 0x243D018 (0x7f919ab018): 0x402
root@ubuntu-desktop:/sys/class/gpio/gpio379# devmem2 0x0243d010 w
/dev/mem opened.
Memory mapped at address 0x7f798b0000.
Value at address 0x243D010 (0x7f798b0010): 0x456
root@ubuntu-desktop:/sys/class/gpio/gpio379# devmem2 0x0243d008 w
/dev/mem opened.
Memory mapped at address 0x7fa471e000.
Value at address 0x243D008 (0x7fa471e008): 0x402
root@ubuntu-desktop:/sys/class/gpio/gpio379# devmem2 0x0243d000 w
/dev/mem opened.
Memory mapped at address 0x7fb7ca9000.
Value at address 0x243D000 (0x7fb7ca9000): 0x40A

we confirm thar the four REGs are setted right.
but, why the gpio debugfs shows nothing?

now, we use oscilloscope to test the four pins. MOSI CS and SCLK work well, but MISO goes flat. the sensor’s max frequency is 10Mhz, but now, tx2 spi works at 12.5Mhz, how to reduce it? So, we sespect that the sensor’s frequency is not match.

The REG configure doesn’t matter with the GPIO fs.
The GPIO debugfs could be in device tree configure.

Check the “spi-max-frequency” in device tree in spi@xxxx scope.
Also can try spidev_test the -s to set the frequency.

Hi
the G16/SPI1_CS0 logic low is 0.8v, but the sensor need 0v to be selected. the sensor logic level change from 0 to 1.8v. and we test the other pins, such as G15 H15, thay are 0.02v at logic low level. how to set G16 as the expected working mode?

what’s more, if we echo 1 to gpio378 value, it is 1.7v, and if we echo 0 to it, it changes to 0.01v. But, whatever we do to gpio379 or G16, it stays at 0.8v. So confused.

Could you remove the SPI configure to confirm the voltage by GPIO to check if the behavior are the same.

Hi
we figure out that it is the layout problem. the pull-down resistance influences G16, we remove it, and spi works well now.

But, we used to modify tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg (28.6 KB) manually, when we use pinmux-dts2cfg.py to modify it, there errors come up.

could you help us?

Did you use latest excel file?

Hi
we are not sure, we dowload Jetson-TX2-Series-Pinmux-Template_v1.08.xlsm on March 28th.

python pinmux-dts2cfg.py --pinmux addr_info.txt gpio_addr_info.txt por_val.txt –mandatory_pinmux_file mandatory_pinmux.txt tegra186-quill-p3310-1000-a00-pinmux.dtsi tegra186-quill-p3310-1000-a00-gpio-default.dtsi 1.0 > tegra186-quill-p3310-1000-a00-pinmux-gpio.cfg

The –mandatory_pinmux_file MANDATORY_PINMUX_FILE_NAME is optional pinmux values info file
You can ignore this option to avoid not matching errors.

Hi
this is the excel file, could you help confirm its applicability.