The Linux Kernel Mailing List
 help / color / mirror / Atom feed
diff for duplicates of <20200916124418.833-9-p.yadav@ti.com>

diff --git a/a/1.txt b/N1/1.txt
index 8b13789..78a51ec 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -1 +1,58 @@
+Some controllers, like the cadence qspi controller, have trouble reading
+only 1 byte in DTR mode. So, do 2 byte reads for SR and FSR commands in
+DTR mode, and then discard the second byte.
 
+Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
+---
+ drivers/mtd/spi-nor/core.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
+index 88c9e18067f4..87c568debf14 100644
+--- a/drivers/mtd/spi-nor/core.c
++++ b/drivers/mtd/spi-nor/core.c
+@@ -368,7 +368,7 @@ int spi_nor_write_disable(struct spi_nor *nor)
+  * spi_nor_read_sr() - Read the Status Register.
+  * @nor:	pointer to 'struct spi_nor'.
+  * @sr:		pointer to a DMA-able buffer where the value of the
+- *              Status Register will be written.
++ *              Status Register will be written. Should be at least 2 bytes.
+  *
+  * Return: 0 on success, -errno otherwise.
+  */
+@@ -386,6 +386,11 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr)
+ 		if (spi_nor_protocol_is_dtr(nor->reg_proto)) {
+ 			op.addr.nbytes = nor->params->rdsr_addr_nbytes;
+ 			op.dummy.nbytes = nor->params->rdsr_dummy;
++			/*
++			 * We don't want to read only one byte in DTR mode. So,
++			 * read 2 and then discard the second byte.
++			 */
++			op.data.nbytes = 2;
+ 		}
+ 
+ 		spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
+@@ -405,7 +410,8 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr)
+  * spi_nor_read_fsr() - Read the Flag Status Register.
+  * @nor:	pointer to 'struct spi_nor'
+  * @fsr:	pointer to a DMA-able buffer where the value of the
+- *              Flag Status Register will be written.
++ *              Flag Status Register will be written. Should be at least 2
++ *              bytes.
+  *
+  * Return: 0 on success, -errno otherwise.
+  */
+@@ -423,6 +429,11 @@ static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr)
+ 		if (spi_nor_protocol_is_dtr(nor->reg_proto)) {
+ 			op.addr.nbytes = nor->params->rdsr_addr_nbytes;
+ 			op.dummy.nbytes = nor->params->rdsr_dummy;
++			/*
++			 * We don't want to read only one byte in DTR mode. So,
++			 * read 2 and then discard the second byte.
++			 */
++			op.data.nbytes = 2;
+ 		}
+ 
+ 		spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
+-- 
+2.28.0
diff --git a/a/content_digest b/N1/content_digest
index 405ccba..c064644 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -13,5 +13,63 @@
  " Boris Brezillon <boris.brezillon@collabora.com>\0"
  "\00:1\0"
  "b\0"
+ "Some controllers, like the cadence qspi controller, have trouble reading\n"
+ "only 1 byte in DTR mode. So, do 2 byte reads for SR and FSR commands in\n"
+ "DTR mode, and then discard the second byte.\n"
+ "\n"
+ "Signed-off-by: Pratyush Yadav <p.yadav@ti.com>\n"
+ "---\n"
+ " drivers/mtd/spi-nor/core.c | 15 +++++++++++++--\n"
+ " 1 file changed, 13 insertions(+), 2 deletions(-)\n"
+ "\n"
+ "diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c\n"
+ "index 88c9e18067f4..87c568debf14 100644\n"
+ "--- a/drivers/mtd/spi-nor/core.c\n"
+ "+++ b/drivers/mtd/spi-nor/core.c\n"
+ "@@ -368,7 +368,7 @@ int spi_nor_write_disable(struct spi_nor *nor)\n"
+ "  * spi_nor_read_sr() - Read the Status Register.\n"
+ "  * @nor:\tpointer to 'struct spi_nor'.\n"
+ "  * @sr:\t\tpointer to a DMA-able buffer where the value of the\n"
+ "- *              Status Register will be written.\n"
+ "+ *              Status Register will be written. Should be at least 2 bytes.\n"
+ "  *\n"
+ "  * Return: 0 on success, -errno otherwise.\n"
+ "  */\n"
+ "@@ -386,6 +386,11 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr)\n"
+ " \t\tif (spi_nor_protocol_is_dtr(nor->reg_proto)) {\n"
+ " \t\t\top.addr.nbytes = nor->params->rdsr_addr_nbytes;\n"
+ " \t\t\top.dummy.nbytes = nor->params->rdsr_dummy;\n"
+ "+\t\t\t/*\n"
+ "+\t\t\t * We don't want to read only one byte in DTR mode. So,\n"
+ "+\t\t\t * read 2 and then discard the second byte.\n"
+ "+\t\t\t */\n"
+ "+\t\t\top.data.nbytes = 2;\n"
+ " \t\t}\n"
+ " \n"
+ " \t\tspi_nor_spimem_setup_op(nor, &op, nor->reg_proto);\n"
+ "@@ -405,7 +410,8 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr)\n"
+ "  * spi_nor_read_fsr() - Read the Flag Status Register.\n"
+ "  * @nor:\tpointer to 'struct spi_nor'\n"
+ "  * @fsr:\tpointer to a DMA-able buffer where the value of the\n"
+ "- *              Flag Status Register will be written.\n"
+ "+ *              Flag Status Register will be written. Should be at least 2\n"
+ "+ *              bytes.\n"
+ "  *\n"
+ "  * Return: 0 on success, -errno otherwise.\n"
+ "  */\n"
+ "@@ -423,6 +429,11 @@ static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr)\n"
+ " \t\tif (spi_nor_protocol_is_dtr(nor->reg_proto)) {\n"
+ " \t\t\top.addr.nbytes = nor->params->rdsr_addr_nbytes;\n"
+ " \t\t\top.dummy.nbytes = nor->params->rdsr_dummy;\n"
+ "+\t\t\t/*\n"
+ "+\t\t\t * We don't want to read only one byte in DTR mode. So,\n"
+ "+\t\t\t * read 2 and then discard the second byte.\n"
+ "+\t\t\t */\n"
+ "+\t\t\top.data.nbytes = 2;\n"
+ " \t\t}\n"
+ " \n"
+ " \t\tspi_nor_spimem_setup_op(nor, &op, nor->reg_proto);\n"
+ "-- \n"
+ 2.28.0
 
-6e512b0fff9e858d4a01d62e1e16c693bd881c6e4dd7d4e6205a2c9c4c7dd2aa
+b1a9f38c25b4fd948118dd6d2679e7384dd6780bd6b5eff4d92deed9f9982d02

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox