Skip to content

Commit 1e611e1

Browse files
Kuwano-sanambarus
authored andcommitted
mtd: spi-nor: spansion: preserve CFR2V[7] when writing MEMLAT
CFR2V[7] is assigned to Flash's address mode (3- or 4-ybte) and must not be changed when writing MEMLAT (CFR2V[3:0]). CFR2V shall be used in a read, update, write back fashion. Fixes: c3266af ("mtd: spi-nor: spansion: add support for Cypress Semper flash") Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230726075257.12985-3-tudor.ambarus@linaro.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent d534fd9 commit 1e611e1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/mtd/spi-nor/spansion.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (C) 2014, Freescale Semiconductor, Inc.
55
*/
66

7+
#include <linux/bitfield.h>
78
#include <linux/device.h>
89
#include <linux/mtd/spi-nor.h>
910

@@ -28,6 +29,7 @@
2829
#define SPINOR_REG_CYPRESS_CFR2 0x3
2930
#define SPINOR_REG_CYPRESS_CFR2V \
3031
(SPINOR_REG_CYPRESS_VREG + SPINOR_REG_CYPRESS_CFR2)
32+
#define SPINOR_REG_CYPRESS_CFR2_MEMLAT_MASK GENMASK(3, 0)
3133
#define SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24 0xb
3234
#define SPINOR_REG_CYPRESS_CFR2_ADRBYT BIT(7)
3335
#define SPINOR_REG_CYPRESS_CFR3 0x4
@@ -161,8 +163,18 @@ static int cypress_nor_octal_dtr_en(struct spi_nor *nor)
161163
int ret;
162164
u8 addr_mode_nbytes = nor->params->addr_mode_nbytes;
163165

166+
op = (struct spi_mem_op)
167+
CYPRESS_NOR_RD_ANY_REG_OP(addr_mode_nbytes,
168+
SPINOR_REG_CYPRESS_CFR2V, 0, buf);
169+
170+
ret = spi_nor_read_any_reg(nor, &op, nor->reg_proto);
171+
if (ret)
172+
return ret;
173+
164174
/* Use 24 dummy cycles for memory array reads. */
165-
*buf = SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24;
175+
*buf &= ~SPINOR_REG_CYPRESS_CFR2_MEMLAT_MASK;
176+
*buf |= FIELD_PREP(SPINOR_REG_CYPRESS_CFR2_MEMLAT_MASK,
177+
SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24);
166178
op = (struct spi_mem_op)
167179
CYPRESS_NOR_WR_ANY_REG_OP(addr_mode_nbytes,
168180
SPINOR_REG_CYPRESS_CFR2V, 1, buf);

0 commit comments

Comments
 (0)