Skip to content

Commit 46b6256

Browse files
committed
mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT
Parse BFPT in order to retrieve the byte order in 8D-8D-8D mode. This info flag will be used as a basis to determine whether there is byte swapping of data for SPI NOR flash in octal DTR mode. The controller driver will check whether byte swapping is supported to determine whether the corresponding operation are supported, thus avoiding the generation of unexpected data order. Merge Tudor's patch and add modifications for suiting newer version of Linux kernel. Reviewed-by: Michael Walle <mwalle@kernel.org> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw> Signed-off-by: AlvinZhou <alvinzhou@mxic.com.tw> Link: https://lore.kernel.org/r/20240926141956.2386374-5-alvinzhou.tw@gmail.com Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent 6a42bc9 commit 46b6256

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

drivers/mtd/spi-nor/sfdp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,10 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
671671
return -EOPNOTSUPP;
672672
}
673673

674+
/* Byte order in 8D-8D-8D mode */
675+
if (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_BYTE_ORDER_SWAPPED)
676+
nor->flags |= SNOR_F_SWAP16;
677+
674678
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
675679
}
676680

drivers/mtd/spi-nor/sfdp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ struct sfdp_bfpt {
130130
#define BFPT_DWORD18_CMD_EXT_INV (0x1UL << 29) /* Invert */
131131
#define BFPT_DWORD18_CMD_EXT_RES (0x2UL << 29) /* Reserved */
132132
#define BFPT_DWORD18_CMD_EXT_16B (0x3UL << 29) /* 16-bit opcode */
133+
#define BFPT_DWORD18_BYTE_ORDER_SWAPPED BIT(31) /* Byte order swapped in 8D-8D-8D mode */
133134

134135
struct sfdp_parameter_header {
135136
u8 id_lsb;

0 commit comments

Comments
 (0)