It appears that most SPI drivers does not honour the SPI_LSB_FIRST flag.
The Cyclone 10 LP FPGA can be configured by an SPI look-alike port, but it needs LSB first.

when I tried this, I realized that the SPI driver I was using did
not support sending with LSB first, it always sends MSB first which does not work.

I then checked the rest, and it appears that very few drivers support LSB first, and no warning is given if the flag is set.

ulf@valinor:~/projects/u-boot/u-boot-2020.10-rc5$ rgrep SPI_LSB
drivers/spi/xilinx_spi.c:       if (mode & SPI_LSB_FIRST)
drivers/spi/stm32_spi.c:        if (mode & SPI_LSB_FIRST)
drivers/spi/cf_spi.c: *      7 -  0: SPI_CPHA, SPI_CPOL, SPI_LSB_FIRST
drivers/spi/cf_spi.c:   if (cfspi->mode & SPI_LSB_FIRST)
drivers/spi/spi-sifive.c:       if (slave_plat->mode & SPI_LSB_FIRST)
drivers/spi/fsl_dspi.c: if (mode & SPI_LSB_FIRST)
drivers/spi/octeon_spi.c: FIELD_PREP(MPI_CFG_LSBFIRST, !!(slave->mode & SPI_LSB_FIRST)) |
drivers/spi/uniphier_spi.c:     if (mode & SPI_LSB_FIRST) {
drivers/spi/mt7621_spi.c:       if (mode & SPI_LSB_FIRST)
drivers/spi/kirkwood_spi.c:     if (mode & SPI_LSB_FIRST)
drivers/spi/bcm63xx_spi.c:      if (mode & SPI_LSB_FIRST)
include/spi.h:#define SPI_LSB_FIRST     BIT(3)                  /* per-word 
bits-on-wire */

I plan to extend the omap3-spi driver by checking for the condition
* 8-bit wordlen
* write only (no read or bidirectional transfer)
and then I create a temporary buffer using malloc/free.

Possibly the buffer should be statically allocated in the driver
with a configurable size defined in Kconfig.
Since the amount of FPGA configuration is fixed for a certain board
this should work.

Best Regards
Ulf Samuelsson


Reply via email to