Hi,
I’m trying to enable SPI on the Jetson Xavier NX production module but I cant get it to work. I created a dtb overlay to enable it in the device tree and change the max clock speed (there are more unrelated changed in the complete overlay):
fragment@4 {
target-path = "/spi@3210000/spi@0";
__overlay__ {
spi-max-frequency = <10000000>;
};
};
fragment@5 {
target-path = "/spi@3210000/spi@1";
__overlay__ {
spi-max-frequency = <10000000>;
};
};
fragment@6 {
target-path = "/spi@3230000/spi@0";
__overlay__ {
spi-max-frequency = <10000000>;
};
};
fragment@7 {
target-path = "/spi@3230000/spi@1";
__overlay__ {
spi-max-frequency = <10000000>;
};
};
fragment@8 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@9 {
target = <&spi2>;
__overlay__ {
status = "okay";
};
};
Later I also added the 40 pin header IO config to the overlay:
fragment@10 {
target = <&pinmux>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&hdr40_pinmux>;
hdr40_pinmux: header-40pin-pinmux {
pin19 {
nvidia,pins = "spi1_mosi_pz5";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
pin21 {
nvidia,pins = "spi1_miso_pz4";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
pin22 {
nvidia,pins = "spi3_miso_py1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
pin23 {
nvidia,pins = "spi1_sck_pz3";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
pin24 {
nvidia,pins = "spi1_cs0_pz6";
nvidia,pull = <TEGRA_PIN_PULL_UP>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
pin26 {
nvidia,pins = "spi1_cs1_pz7";
nvidia,pull = <TEGRA_PIN_PULL_UP>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
};
};
};
I also changed the pinmux config:
$ grep spi1 /sys/kernel/debug/tegra_pinctrl_reg
Bank: 0 Reg: 0x0243d010 Val: 0x00000458 -> spi1_cs0_pz6
Bank: 0 Reg: 0x0243d020 Val: 0x00000454 -> spi1_miso_pz4
Bank: 0 Reg: 0x0243d040 Val: 0x00000454 -> spi1_sck_pz3
Bank: 0 Reg: 0x0243d050 Val: 0x00000458 -> spi1_cs1_pz7
Bank: 0 Reg: 0x0243d058 Val: 0x00000454 -> spi1_mosi_pz5
To test I placed the board in a devkit carrier board and connected the probe to pin 23, and then sent some data to the SPI using:
$ echo -ne "\xFE" | spi-pipe -d /dev/spidev0.0 -s 1000000 | hexdump
0000000 0000
0000001
However there is no signal from the device. What I do find odd is that hexdump outputs data, which makes me think its still configured as loopback. Am I missing something obvious?
Please let me know if you need anymore info.
Rens