SPI3 Speed not higher then 8 MHZ

Hi everyone,

I’m trying to connect my SPI3 to a Lepton FLIR 3. The SPI Speed required is: 20 MHz. After hours of debugging
why the lepton transmits false frames, I have tried to make an loopback from MOSI <-> MISO On Spi3.

This works till I put the speed higher then 8 MHz. Above 8 MHz the data is received faulty.

also I’ve tries to add spi-max-frequency to the device tree. This is set to 25000000 MHz. This shouldn’t be a problem.

Can somebody please help me a bit, cause I have no clue what can be wrong.

Hardware used: Jetson TX 2 on a J90

Device Tree Spi3

spi@3240000 {
		reg = <0x0 0x3240000 0x0 0x10000>;
		dmas = <0x19 0x12 0x19 0x12>;
		interrupts = <0x0 0x27 0x4>;
		compatible = "nvidia,tegra186-spi";
		clock-names = "spi", "pll_p", "clk_m";
		reset-names = "spi";
		clocks = <0xd 0x4a 0xd 0x10d 0xd 0x264>;
		nvidia,dma-request-selector = <0x19 0x12>;
		resets = <0xd 0x2b>;
		status = "okay";
		#address-cells = <0x1>;
		phandle = <0x7d>;
		nvidia,clk-parents = "pll_p", "clk_m";
		#stream-id-cells = <0x1>;
		#size-cells = <0x0>;
		dma-names = "rx", "tx";
		linux,phandle = <0x7d>;
		spi-max-frequency = <25000000>;
		spidev@0 {
			reg = <0x0>;
			compatible = "spidev";
			spi-max-frequency = <25000000>;
			spi-cpha;
			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>;
		};

		spidev@1 {
			reg = <0x1>;
			compatible = "spidev";
			spi-max-frequency = <25000000>;
			spi-cpha;
			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>;
		};
	};

Thanks in advance,

What’s you command for the loopback test?

Hi Shane,

I’m using spidev_test. This works on other development board @ 20 MHz, but just not on the J90. Cant figure out why after setting the SPI clock to 25 its not working properbly above 8 Mhz (Data gets scrambled).

Do i need to set an another clock somewhere in the DTB or so?

Thanks.

What is J90?
We just confirm the SPI should be working with 25 Mhz.

Hi Shane,

Thanks for your reply. Is the 25Mhz confirmed based upon my device tree I’ve attached or based on the hardware?

The J90 is the Auvidea Carrierboard J90 for Jetson TX1/TX2

Technical Reference: https://nl.mouser.com/ds/2/864/J90_technical_reference_1.2-1130377.pdf

Also I did further measurements. The SPI is still Working 8.4MHz. SPI Speeds higher then 8.4 MHz are corrupted.

What could it be?

Thanks

The spi-max-frequency should be no problem in your DT.
Did you use -s xxxx for transfer speed test?

Hi Shane, Yes I did. Every speed between 1MHz and 8.3 MHZ show correct results. Everythin Above 8.4 Mhz Shows scrambled results. Also I find the 1 MHz weird, since everybody else states the Jetson Is not able todo speeds Bellow 3 MHz.

I also have tried it on Version 28.1 and today on version 28.2. Results are the same!.

Could it be possible that the pinmux is conflicting in the DTB? And if, how does that work?

Thanks

Does the SPI loopback MOSI <-> MISO get the same result?

Yes, I wired it with an wire from MOSI <-> MISO

How do you verify the speed of SPI loopback can’t higher than 8Mhz, does the spidev_test show error?

Yes Indeeed, You send Characters to the TX channel, and shows you the character received on the RX Channel.

Ex. It will print out the following:

TX: ABCDEF
RX: ABCDEF

When the speed is between 1 - 8 Mhz

When the speed is above 8 Mhz it wil print out something like this:

TX: ABCDEF
RX: @%A

Hmm. Can you attach the specific input, output, and frequency for a failure case? Do you know which bits are being “skipped” (if any)? Have you attached a scope (rather than a logic analyzer)?

Rx errors on loopback could be because wire length is high. Could you use short wire or a simple jumper as pins are close by.
If it is still failing could you try with setting different tap values for rx in command2 register (passed through dt).

    spi@3240000 {
           prod-settings {
                   prod_c_cs0 {
                        /* enabled for spi flash rom only */
                       prod = <0x04 0x0000003f 0x00000008>;
                   };
           };
   };