Use flexspi controller to communicate with a device using regular SPI

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

Use flexspi controller to communicate with a device using regular SPI

1,466 Views
betheev
Contributor I

Hi,

is it at all possible to use the flexspi controller of an i.MX8M Plus processor and spidev to talk to a device that speaks regular SPI (mode 0)? If yes, how do you do that? I get the following error:

$ spidev_test -v --device /dev/spidev0.0 -p "0xFF"
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 kHz)
can't send spi message: Unknown error 524
Aborted (core dumped)

Note: I modified spidev_test to use SPI_IOC_WR_MODE and SPI_IOC_RD_MODE instead of SPI_IOC_WR_MODE32 and SPI_IOC_RD_MODE32.

Tags (1)
0 Kudos
Reply
11 Replies

1,383 Views
betheev
Contributor I

I added the property "nxp,fspi-individual-mode" that I had overlooked but I'm still getting the same error:

&flexspi {
   nxp,fspi-individual-mode;
    status = "okay";
    spidev0: spi@0 {
        reg = <0>;
        compatible = "rohm,dh2228fv";
        spi-max-frequency = <10000000>;
        spi-rx-bus-width = <1>;
        spi-tx-bus-width = <1>;
    };
};

 

0 Kudos
Reply

1,450 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @betheev!
Thank you for contacting NXP Support!

 

The SPI bus is working good by my side.

What BSP version are you using?

What board are you using?

 

Can you share your device tree?

 

Best Regards!
Chavira

0 Kudos
Reply

1,370 Views
xojico
Contributor I

 

Chavira,

Do you understand that xSPI and ordinary SPI are two very different things?

0 Kudos
Reply

1,427 Views
betheev
Contributor I

Hi Chavira,

I'm glad to hear it is working on your side. That gives me hope

I'm working with a SOM-SMARC-MX8M-Plus from Seco. I'm using the seco-imx8mp-d18.dts file as reference device tree and have attached spidev as follows:

&flexspi {
    status = "okay";
    spidev0: spi@0 {
        reg = <0>;
        compatible = "rohm,dh2228fv";
        spi-max-frequency = <10000000>;
        spi-rx-bus-width = <1>;
        spi-tx-bus-width = <1>;
    };
};

For the sake of simplicity, let's assume that the device I want to talk to is always selected.

What I have managed to understand so far is that, in general, flexspi controllers are part of the MTD Linux subsystem (because their main purpose is to communicate with flash devices) whereas spidev belongs to the SPI subsystem and that's why spidev cannot "talk" to flexspi controllers. However, the NXP FSPI Controller Driver is under drivers/spi/. I was expecting it to play nice with spidev. So what am I missing? Why does spidev_test return an error?

Best regards,

Betheev

0 Kudos
Reply

1,371 Views
xojico
Contributor I

flexSPI is designed for storage following the xSPI standard. The full name of xSPI (JESD251C) is EXpanded Serial Peripheral Interface (xSPI) for Non Volatile Memory Devices. SPI has only a few datasheets and is a de facto standard for applications. It is designed for connectivity. These two standards have completely different purposes. The standard protocol definitions are very different. It is impossible to use xSPI to do the work of ordinary SPI.

0 Kudos
Reply

1,337 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @xojico!

 

FlexSPI Flash with support for XIP  and support for either one Octal SPI, or parallel read mode of two identical Quad SPI FLASH devices. It also supports both Serial NOR and Serial NAND flash using the FlexSPI.

 

Unfortunately he i.MX 8M Plus does not natively support the xSPI (JESD251) standard.

FlexSPI: Supported on i.MX 8M Plus, used for interfacing with NOR flash (e.g., QSPI, Octal SPI) and xSPI (JESD251) is not officially supported or documented as compliant in the i.MX 8M Plus datasheet or reference manual.

 

Best Regards!

Chavira

0 Kudos
Reply

1,279 Views
xojico
Contributor I

I suggest you ask the engineers who designed your chips. Which flexspi IP did they use? Which standard the flexspi ip follows ? Your ignorance makes you have no idea what question Betheev is asking.

0 Kudos
Reply

1,307 Views
betheev
Contributor I

Hi Chavira,

what about my original question? You say that regular SPI is working on your side. How? What driver do you use? How did you configure your device tree? I analyzed the spi code a bit further and the reason I get the error is because spi-nxp-fspi.c does not implement the function spi_controller-> transfer called here

Best regards,

Betheev

0 Kudos
Reply

1,277 Views
xojico
Contributor I

See? This is the level of NXP engineers. If I don't tell him the knowledge of xSPI, he will never know it in his life. And  Chavira  won't answer your original question, because before I tell him this knowledge, he has no idea and can't understand your question. 

 

Chavira  cannot tell an  xSPI and a SPI. 

0 Kudos
Reply

1,289 Views
betheev
Contributor I

After spending a long time reading driver code, I finally understood the problem. The only driver compatible with "nxp,imx8mp-fspi" as required by the flexspi node in imx8mp.dtsi is drivers/spi/spi-nxp-fspi.c. This driver, however, does not implement any of the functions transfer() (deprecated), transfer_one() or transfer_one_message() of struct spi_controller that the SPI device driver (drivers/spi/spi.c) needs to send SPI messages.

@Chavira: what driver did you use to send regular SPI messages using the flexspi node in the device tree?

0 Kudos
Reply

1,360 Views
betheev
Contributor I

I understand that xSPI has a completely different purpose but doesn't it nonetheless provide compatibility with legacy SPI devices? According to this website, it does.

0 Kudos
Reply