[PATCH v8 1/3] mtd: spi-nor: spansion: Add support for Read Any Register

tkuw584924 at gmail.com tkuw584924 at gmail.com
Sun Feb 20 23:14:10 PST 2022


From: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>

The Read Any Register instruction (65h) is followed by register address
and dummy cycles, then the selected register byte is returned. This patch
adds a spi_mem_op template for that. The spi_mem_op is passed to
spi_nor_read_reg() introduced by:
https://lore.kernel.org/linux-mtd/20220210023334.408926-1-tudor.ambarus@microchip.com/T/#m05d56c77f8d55eb6f3dee4cb138bde4ff390d6c1

Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
---
Changes in v8:
  - Remove controller_ops
  - Remove spansion_read/write_any_reg()
  - Add spi_mem_op macro for Read Any Register
  
Changes in v7:
  - No change

Changes in v6:
  - Add helper functions for controller_ops
  - Add 'reg_addr_width' parameter to spansion_read/write_any_reg()
  - Remove spi_nor_write_enable() from spansion_write_any_reg() and modified
    function header comment

Changes in v5:
  - Fix 'if (ret == 1)' to 'if (ret < 0)' in spansion_read_any_reg()

Changes in v4:
  - Fix dummy cycle calculation in spansion_read_any_reg()
  - Modify comment for spansion_write_any_reg()
  
Changes in v3:
  - Cleanup implementation

 drivers/mtd/spi-nor/spansion.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
index 9bb239f1e142..9040edf7359f 100644
--- a/drivers/mtd/spi-nor/spansion.c
+++ b/drivers/mtd/spi-nor/spansion.c
@@ -20,6 +20,11 @@
 #define SPINOR_OP_CYPRESS_RD_FAST		0xee
 
 /* Spansion/Cypress SPI NOR flash operations. */
+#define SPI_NOR_SPANSION_RD_ANY_REG_OP(naddr, addr, ndummy, ndata, buf)	\
+	SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 0),		\
+		   SPI_MEM_OP_ADDR(naddr, addr, 0),			\
+		   SPI_MEM_OP_DUMMY(ndummy, 0),				\
+		   SPI_MEM_OP_DATA_IN(ndata, buf, 0))
 #define SPI_NOR_SPANSION_WR_ANY_REG_OP(naddr, addr, ndata, buf)		\
 	SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_ANY_REG, 0),		\
 		   SPI_MEM_OP_ADDR(naddr, addr, 0),			\
-- 
2.25.1




More information about the linux-mtd mailing list