This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6422: Need to use OSPI as generic SPI device

Part Number: AM6422


Hi,

We are testing OSPI in AM6422 based custom board with as a generic SPI device(rohm,dh2228fv).

The spidev0.0 is getting registered in /dev after booting but when writing or reading from the device below error is shown.

./spidev_test -D /dev/spidev0.0
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 kHz)
can't send spi message: Unknown error 524

Can the OSPI be used a generic SPI device with spidev driver?

We are testing using 8.6 SDK

  • Hi Vinay,

    Can the OSPI be used a generic SPI device with spidev driver?

    We are testing using 8.6 SDK

    I'm not sure this has been tried, or is supported. But two quick things you can attempt:

    1) Limit the tx/rx bus width (per DTS entry) to "1"

    2) Try latest SDK v9.2 as a baseline (at least for testing). It's a much newer Kernel and general SW stack.

    Regards, Andreas

  • Hi Andreas,

    The tx/rx bus width is set to 1 in device tree but still same issue is observed.

    We are able to control the MCSPI4 with spidev driver but when testing ospi we are facing the error.

    When compared both MCSPI and OSPI driver files we found the OSPI driver only supports mem_ops and doesnot have transfer/transfer_one operations.

    We traced the error to 524 in drivers/spi/spi.c and we get the error when the controller doesnot support transfer operation.

    Kindly refer the below images

    We are using spidev_test and spidev_fdx application in kernel source code to test the generic SPI device.

    Is there any patch to support transfer operations in ospi driver or any sample application to read and write to SPI device without transfer operations

  • Hi Vinay,

    When compared both MCSPI and OSPI driver files we found the OSPI driver only supports mem_ops and doesnot have transfer/transfer_one operations.

    We traced the error to 524 in drivers/spi/spi.c and we get the error when the controller doesnot support transfer operation.

    well thanks for looking into this closer some more yourself; it does indeed sound like that's not supported.

    I'm curious as to why did you try to use the OSPI module in the first place? Can't you use one of the regular "McSPI" peripherals for what you need?

    Regards, Andreas

  • Hi Andreas,

    We want to control 2 spi devices in the board and the expansion connector supports mcspi4 and ospi pins so we have configured both mcspi4 and ospi as generic spi devices but ospi gives error when doing any read or write operation.

    Is there any patch to support transfer operations in ospi driver to resolve this error or to use ospi as generic spi?

  • Hi Vinay,

    Is there any patch to support transfer operations in ospi driver to resolve this error or to use ospi as generic spi?

    No there is not. If you really need that you'd need to invest time/effort and add this functionality, ideally also proposing your changes upstream for mainline kernel integration.

    the expansion connector supports mcspi4 and ospi pins so we have configured both mcspi4 and ospi as generic spi devices

    How about you you just use GPIO pins that are available on your header (or even the OSPI pins in GPIO mode) to bit-bang a SPI interface? It'll not be the fastest but is definitely a workable solution for quite a few scenarios. Look into CONFIG_SPI_BITBANG.

    Regards, Andreas