imx93 high frequency SPI

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx93 high frequency SPI

678 Views
LorenzoSpadaro
Contributor II

Hi,

I need to interface an external microcontroller to an iMX93 som module. I need to use the SPI at minimum 20-25MHz frequency. I am considering two operating possibilities:

The first would be to have the SPI of the imx93-som as slave; the microcontroller sends a block of data after it samples them, the som accumulates them in a buffer, and the high level software empties the buffer when it needs to (no more frequently than 100 times per second). This would be the preferred solution.

The second would be to use the SPI as master from the som; the microcontroller accumulates the data in itself and the som empties it at regular intervals. We like this solution less because we would have to control the SPI directly from the application instead of simply reading a buffer.

Which solution do you think would be easier to implement? Do you know how can i do it? I attach the actual device tree, i tryed to configure the SPI in slave mode but i do not know which command i need to use to interact with it or how to test it.

I am using the kernel version 6.1.22, the configuration has not been touched.

Thank you in advance

Lorenzo

0 Kudos
Reply
2 Replies

608 Views
LorenzoSpadaro
Contributor II

Hi,

I am trying the second way.

I have implemented the DTB in order to use the micro as SPI master. I am using spidev driver. I noticed that a can send max 8 bytes per time, if i send more the transaction is divided in blocks of 8 bytes each; here an example (there is aliasing because the clk freq is high, but they are 8 bytes transfer (32 bytes in total):

DS1Z_QuickPrint1.png

This is my device tree configuration:

file imx93.dtsi:

  lpspi3: spi@42550000 {
    #address-cells = <1>;
    #size-cells = <0>;
    compatible = "fsl,imx93-spi", "fsl,imx7ulp-spi";
    reg = <0x42550000 0x10000>;
    interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
    clocks = <&clk IMX93_CLK_LPSPI3_GATE>,
    <&clk IMX93_CLK_BUS_WAKEUP>;
    clock-names = "per", "ipg";
    status = "disabled";
};

file ucm-imx93.dts:

&lpspi3 {
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&pinctrl_lpspi3>;
    pinctrl-1 = <&pinctrl_lpspi3>;
    fsl,spi-num-chipselects = <1>;
    cs-gpios = <&gpio2 8 GPIO_ACTIVE_LOW>;
    status = "okay";
    spidev0: spidev@0 {
      reg = <0>;
      compatible = "rohm,dh2228fv";
      spi-max-frequency = <20000000>;
      status = "okay";
    };
};

I tryed to add DMA in order to avoid this problem:

file ucm-imx93.dts:

&lpspi3 {
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&pinctrl_lpspi3>;
    pinctrl-1 = <&pinctrl_lpspi3>;
    fsl,spi-num-chipselects = <1>;
    cs-gpios = <&gpio2 8 GPIO_ACTIVE_LOW>;
    status = "okay";
    dmas = <&edma2 12 0 0>, <&edma2 13 0 1>;
    dma-names = "tx","rx";
    spidev0: spidev@0 {
      reg = <0>;
      compatible = "rohm,dh2228fv";
      spi-max-frequency = <20000000>;
      status = "okay";
    };
};

but with the two code lines for the DMA, the SPI does not work anymore.

Do you know which the error can be in the device tree that cause the SPI not to work with DMA?

Is the delay problem fixable with the DMA? In case, do you know another way to fix it?

 

Thank you in advance

 

Lorenzo

 

 

 

0 Kudos
Reply

650 Views
jimmychan
NXP TechSupport
NXP TechSupport

I think the second one is more easier to implement. The mcu like as a SPI device. You could write a driver for it. You could write the control code in the driver. Add it in the device tree like other spi device.

0 Kudos
Reply