iMX8X: max frequency of spidev

Hi @Mowlwurf,

According to the reference manual, “The LPSPI divides the functional clock by a prescaler; the resulting frequency must be at least 2 times faster than the SPI external clock frequency (LPSPI_SCK).”

I’m afraid it’s impossible to use LPSPI_CLK (freq on spi_clk pin in your terms) 60MHz with the input clock 116363636 Hz. The same rule is for other freqs.

Also, it is impossible to set LPSPI_SCK to 120000000. The source for the SPI clock is DIG_PLL0 with 1280MHz. The divider for this source is an integer, so you can set 128000000 (1280000000 / 10) or 116363636 (128000000 / 11).

So, to use SPI with 60000000 bps speed, you should set LPSPI_SCK to 128000000 or higher value.


&lpspi2 {
    ...
    assigned-clock-rates = <128000000>;
    ...
}

root@colibri-imx8x:~# cat /sys/kernel/debug/clk/clk_summary | grep spi2
     spi2_div                                 1            1  128000000           0 0  
        spi2_clk                              1            1  128000000           0 0  
        spi2_ipg_clk                          1            1   120000000          0 0  

I slightly changed your test program and got the following result with mentioned settings:

root@colibri-imx8x:~# ./spi-freq
SPI open: OK (3)
SPI set SPI_MODE_0 mode: OK
SPI set 32 bits per word: OK
Set speed 1000000...OK
Set speed 2000000...OK
Set speed 5000000...OK
Set speed 10000000...OK
Set speed 20000000...OK
Set speed 30000000...OK
Set speed 40000000...OK
Set speed 58181818...OK
Set speed 60000000...OK

Please, look at the patch I’ve attached to this answer.link text