RE: [PATCH v2] spi: add Renesas RPC-IF driver

Chris Brandt
2020-02-10T18:06:37Z

Hi Sergei,

As I mentioned, when testing on RZ/A1, some commands are not transmitted.

Basically and SPI command that did not have 'data' payload:
0x06: Write Enable
0xDC: Erase 256 kB (4-byte address)
0x04: Write Disable

The reason seems to be there is no case to set rpc->dir when there is no data.
So, it just gets left at whatever the last transfer was.

I added this fix and now it seems to work fine.

diff --git a/drivers/spi/spi-rpc-if.c b/drivers/spi/spi-rpc-if.c
index 0ff1a538bbd5..2165a0761844 100644
--- a/drivers/spi/spi-rpc-if.c
+++ b/drivers/spi/spi-rpc-if.c
@@ -53,6 +54,9 @@ static void rpcif_spi_mem_prepare(struct spi_device *spi_dev,
default:
break;
}
+ } else {
+ rpc_op.data.dir = RPCIF_NO_DATA;
+ rpc->dir = RPCIF_NO_DATA;
}

rpcif_prepare(rpc, &rpc_op, offs, len);

This seems like a bug that would effect add devices, not just the RZ/A1.

Side note, erase seems OK...but writing data seems to get messed up.
As you can see below, it's adding 2 bytes of 00 into the write stream.

$ flash_eraseall /dev/mtd3
Erasing 256 Kibyte @ 1000000 - 100% complete.
$ hexdump -C -n100 /dev/mtd3
00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00000060
$ hexdump -C -n100 /dev/mtd3
00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00000060
$ echo "hello" > /dev/mtd3
$ hexdump -C -n100 /dev/mtd3
00000000 68 65 6c 6c 00 00 6f 0a ff ff ff ff ff ff ff ff |hell..o.........|
00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00000060

Chris