spi: xilinx: Detect stall with Unknown commands
authorRicardo Ribalda <ricardo.ribalda@gmail.com>
Tue, 21 Nov 2017 09:09:02 +0000 (10:09 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 24 Nov 2017 13:09:22 +0000 (13:09 +0000)
commit5a1314fa697fc65cefaba64cd4699bfc3e6882a6
treea124f65cf82d4ae9b9ccf6b1a891224cdb1b46d3
parentabbdb5ce31c21a4b3c3922c56030f3d487497933
spi: xilinx: Detect stall with Unknown commands

When the core is configured in C_SPI_MODE > 0, it integrates a
lookup table that automatically configures the core in dual or quad mode
based on the command (first byte on the tx fifo).

Unfortunately, that list mode_?_memoy_*.mif does not contain all the
supported commands by the flash.

Since 4.14 spi-nor automatically tries to probe the flash using SFDP
(command 0x5a), and that command is not part of the list_mode table.

Whit the right combination of C_SPI_MODE and C_SPI_MEMORY this leads
into a stall that can only be recovered with a soft rest.

This patch detects this kind of stall and returns -EIO to the caller on
those commands. spi-nor can handle this error properly:

m25p80 spi0.0: Detected stall. Check C_SPI_MODE and C_SPI_MEMORY. 0x21 0x2404
m25p80 spi0.0: SPI transfer failed: -5
spi_master spi0: failed to transfer one message from queue
m25p80 spi0.0: s25sl064p (8192 Kbytes)

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
drivers/spi/spi-xilinx.c