Skip to content

Commit a45ab83

Browse files
Kuwano-sanPratyush Yadav
authored andcommitted
mtd: spi-nor: spansion: Fixup params->set_4byte_addr_mode for SEMPER
Infineon SEMPER flash family does not support E9h opcode as Exit 4-byte mode (EX4B). Therefore, params->set_4byte_addr_mode is not determined by BFPT parse. Fixup it up by introducing vendor specific EX4B opcode (B8h) and function. Fixes: c87c9b1 ("mtd: spi-nor: spansion: Determine current address mode") Signed-off-by: Takahiro Kuwano <[email protected]> Acked-by: Tudor Ambarus <[email protected]> Acked-by: Pratyush Yadav <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d8b73ce commit a45ab83

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drivers/mtd/spi-nor/spansion.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#define SPINOR_OP_CLSR 0x30 /* Clear status register 1 */
1919
#define SPINOR_OP_CLPEF 0x82 /* Clear program/erase failure flags */
20+
#define SPINOR_OP_CYPRESS_EX4B 0xB8 /* Exit 4-byte address mode */
2021
#define SPINOR_OP_CYPRESS_DIE_ERASE 0x61 /* Chip (die) erase */
2122
#define SPINOR_OP_RD_ANY_REG 0x65 /* Read any register */
2223
#define SPINOR_OP_WR_ANY_REG 0x71 /* Write any register */
@@ -58,6 +59,13 @@
5859
SPI_MEM_OP_DUMMY(ndummy, 0), \
5960
SPI_MEM_OP_DATA_IN(1, buf, 0))
6061

62+
#define CYPRESS_NOR_EN4B_EX4B_OP(enable) \
63+
SPI_MEM_OP(SPI_MEM_OP_CMD(enable ? SPINOR_OP_EN4B : \
64+
SPINOR_OP_CYPRESS_EX4B, 0), \
65+
SPI_MEM_OP_NO_ADDR, \
66+
SPI_MEM_OP_NO_DUMMY, \
67+
SPI_MEM_OP_NO_DATA)
68+
6169
#define SPANSION_OP(opcode) \
6270
SPI_MEM_OP(SPI_MEM_OP_CMD(opcode, 0), \
6371
SPI_MEM_OP_NO_ADDR, \
@@ -356,6 +364,20 @@ static int cypress_nor_quad_enable_volatile(struct spi_nor *nor)
356364
return 0;
357365
}
358366

367+
static int cypress_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
368+
{
369+
int ret;
370+
struct spi_mem_op op = CYPRESS_NOR_EN4B_EX4B_OP(enable);
371+
372+
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
373+
374+
ret = spi_mem_exec_op(nor->spimem, &op);
375+
if (ret)
376+
dev_dbg(nor->dev, "error %d setting 4-byte mode\n", ret);
377+
378+
return ret;
379+
}
380+
359381
/**
360382
* cypress_nor_determine_addr_mode_by_sr1() - Determine current address mode
361383
* (3 or 4-byte) by querying status
@@ -526,6 +548,9 @@ s25fs256t_post_bfpt_fixup(struct spi_nor *nor,
526548
struct spi_mem_op op;
527549
int ret;
528550

551+
/* Assign 4-byte address mode method that is not determined in BFPT */
552+
nor->params->set_4byte_addr_mode = cypress_nor_set_4byte_addr_mode;
553+
529554
ret = cypress_nor_set_addr_mode_nbytes(nor);
530555
if (ret)
531556
return ret;
@@ -591,6 +616,9 @@ s25hx_t_post_bfpt_fixup(struct spi_nor *nor,
591616
{
592617
int ret;
593618

619+
/* Assign 4-byte address mode method that is not determined in BFPT */
620+
nor->params->set_4byte_addr_mode = cypress_nor_set_4byte_addr_mode;
621+
594622
ret = cypress_nor_set_addr_mode_nbytes(nor);
595623
if (ret)
596624
return ret;
@@ -718,6 +746,9 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,
718746
const struct sfdp_parameter_header *bfpt_header,
719747
const struct sfdp_bfpt *bfpt)
720748
{
749+
/* Assign 4-byte address mode method that is not determined in BFPT */
750+
nor->params->set_4byte_addr_mode = cypress_nor_set_4byte_addr_mode;
751+
721752
return cypress_nor_set_addr_mode_nbytes(nor);
722753
}
723754

0 commit comments

Comments
 (0)