2023-04-07 02:17 AM
Hi,
I would like to make my STM32MP157 communicate with a FPGA in spi. I need to make long transfer (2-3 Mb) spi to get data acquired by the FPGA. But when I use the "spi_sync_transfer" function in my driver, I get the following kernel message:
#spi_stm32 4000b000.spi: Overrun: RX data lost
#spi0.0: SPI transfer failed: -5
# spi_master spi0: failed to transfer one message from queue
This driver works on an ompa3 platform.
I use a kernel linux 5.10, there is my device tree overlay :
/dts-v1/;
/plugin/;
&spi2 {
ifsttarhf8ch: ifsttarhf8ch@0 {
compatible = "ifsttar,ifsttarhf8ch";
reg = <0>;
spi-max-frequency = <100000000>;
interrupt-parent = <&gpioi>;
interrupts = <9 IRQ_TYPE_EDGE_RISING>;
};
};
and my device tree :
#include "stm32mp157.dtsi"
&spi2 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi2_pins_mx>;
pinctrl-1 = <&spi2_sleep_pins_mx>;
cs-gpios = <&gpiob 9 0>,
<&gpioi 1 0>,
<&gpiob 8 0> ;
status = "okay";
spidev2_1: spidev2_1@1{
compatible = "rohm,dh2228fv";
spi-max-frequency = <30000000>;
reg = <1>;
};
spidev2_2: spidev2_2@2{
compatible = "rohm,dh2228fv";
spi-max-frequency = <30000000>;
reg = <2>;
};
};
In my driver i use this code to read on the FPGA :
temp = CMD_READ(ADDR_BURST_DATA_RX); //fpga registry
transfer[0].tx_buf = &temp;
transfer[0].len = sizeof(temp);
transfer[1].rx_buf = data
transfer[1].len = sizeof(u16)*4095*8 // 4095 data * nb channel (8)
ret = spi_sync_transfer(spiHandler,&transfer[0],2);
Another problem, when I modify the "spi-max-frequency" field in the device tree, the clock frequency does not increase more than 12.5Mhz.
Sincerely
2023-05-10 09:17 AM
Hi @Arthur Bouché ,
I cannot answer for the overrun, maybe have a look to
https://wiki.st.com/stm32mpu/wiki/SPI_overview
https://wiki.st.com/stm32mpu/wiki/SPI_device_tree_configuration
Regarding the SPI frequency limited to 12.5MHz, this is probably because your clock tree define a too low frequency for SPI 'kernel' clock. The Linux driver compute the best he can do using peripheral constrains (e.g. SPI divider is 2, 4, 8 , etc...).
You could check the frequency received by your SPI by looking at spi2_k in clock summary.
See https://wiki.st.com/stm32mpu/wiki/Clock_overview#How_to_monitor_with_debugfs
E.g. In our starter package, on DK2, spi2_k is 11.29 MHz which should allows only up to 5.6MHz.
Regards.