Enable SPI on TX2 with Jetpack4.2/R32.1

Hello,

I want to enable SPI1(SOM Connector)->SPI4(Customer usage)->/dev/spidev3.0(Software name),and do as this topic:TX2_SPI

1).tegra186-soc-spi.dtsi:
spi3: spi@3240000 {

    compatible = "nvidia,tegra186-spi";

    reg = <0x0 0x03240000 0x0 0x10000>;

    interrupts = <0 39 0x04>;

    #address-cells = <1>;

    #size-cells = <0>;

    iommus = <&smmu TEGRA_SID_GPCDMA_0>;

    dmas = <&gpcdma 18>, <&gpcdma 18>;

    dma-names = "rx", "tx";

    nvidia,clk-parents = "pll_p", "clk_m";

    clocks = <&tegra_car TEGRA186_CLK_SPI4>,

        <&tegra_car TEGRA186_CLK_PLLP_OUT0>,

        <&tegra_car TEGRA186_CLK_CLK_M>;

    clock-names = "spi", "pll_p", "clk_m";

    resets = <&tegra_car TEGRA186_RESET_SPI4>;

    reset-names = "spi";

    status = "okay";

#add below
spi@0 {

        compatible = "spidev";

        reg = <0x0>;

        spi-max-frequency = <0x1312D00>;

        nvidia,enable-hw-based-cs;

        nvidia,cs-setup-clk-count = <0x1e>;

        nvidia,cs-hold-clk-count = <0x1e>;

        nvidia,rx-clk-tap-delay = <0x1f>;

        nvidia,tx-clk-tap-delay = <0x0>;

    };

};

2).kernel config:
CONFIG_SPI=y
CONFIG_SPI_TEGRA114=y
CONFIG_SPI_SPIDEV=m
CONFIG_QSPI_TEGRA186=y

3).Pinmux config:
bootloader/t186ref/BCT/tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg
#default
pinmux.0x02430038 = 0x00000000; # GPIO gpio_cam4_pn3
pinmux.0x02430040 = 0x00000000; # GPIO gpio_cam5_pn4
pinmux.0x02430048 = 0x00000000; # GPIO gpio_cam6_pn5
pinmux.0x02430050 = 0x00000000; # GPIO gpio_cam7_pn6
#chang to
pinmux.0x02430038 = 0x00000401; # gpio_cam4_pn3: spi4, tristate-disable, input-disable
pinmux.0x02430040 = 0x00000455; # gpio_cam5_pn4: spi4, pull-down, tristate-enable, input-enable
pinmux.0x02430048 = 0x00000401; # gpio_cam6_pn5: spi4, tristate-disable, input-disable
pinmux.0x02430050 = 0x00000409; # gpio_cam7_pn6: spi4, pull-up, tristate-disable, input-disable

4).rebuild and reflash kernerl and dtb,reboot.

MOSI and MISO loopback test cmd:

sudo ./spidev_test -D /dev/spidev3.0

I think my spidev_test result is failed because RX data is all “00”.

What did I miss? and how to debug this issue?

Thanks!

1 Like

Hi,
I figured it out, modify tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg and reflash tx2 to set pinmux config have no effective,only manual devmem2 to chenge pinmux REG can make spi work in my test.

You need totally reflash whole system image to apply new cfg.

A little change need totally relfash whole system image,looks like unreasonable.
devmem2 is better for me.