Skip to content

Commit af2792a

Browse files
jaimeliaoambarus
authored andcommitted
mtd: spi-nor: sfdp: get the 1-1-8 and 1-8-8 protocol from SFDP
BFPT 17th DWORD contains the information about 1-1-8 and 1-8-8. Parse BFPT DWORD[17] instruction to determine whether flash supports 1-1-8 and 1-8-8, and set its dummy cycles accordingly. Validated only the 1-1-8 read using a macronix flash with Xilinx board zynq-picozed. Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw> Reviewed-by: Michael Walle <mwalle@kernel.org> Link: https://lore.kernel.org/r/20231219102103.92738-2-jaimeliao.tw@gmail.com [ta: update commit message, get rid of extra dereference] Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent fe18e22 commit af2792a

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

drivers/mtd/spi-nor/sfdp.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
446446
u32 dword;
447447
u16 half;
448448
u8 erase_mask;
449+
u8 wait_states, mode_clocks, opcode;
449450

450451
/* JESD216 Basic Flash Parameter Table length is at least 9 DWORDs. */
451452
if (bfpt_header->length < BFPT_DWORD_MAX_JESD216)
@@ -631,6 +632,32 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
631632
if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
632633
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
633634

635+
/* Parse 1-1-8 read instruction */
636+
opcode = FIELD_GET(BFPT_DWORD17_RD_1_1_8_CMD, bfpt.dwords[SFDP_DWORD(17)]);
637+
if (opcode) {
638+
mode_clocks = FIELD_GET(BFPT_DWORD17_RD_1_1_8_MODE_CLOCKS,
639+
bfpt.dwords[SFDP_DWORD(17)]);
640+
wait_states = FIELD_GET(BFPT_DWORD17_RD_1_1_8_WAIT_STATES,
641+
bfpt.dwords[SFDP_DWORD(17)]);
642+
params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8;
643+
spi_nor_set_read_settings(&params->reads[SNOR_CMD_READ_1_1_8],
644+
mode_clocks, wait_states, opcode,
645+
SNOR_PROTO_1_1_8);
646+
}
647+
648+
/* Parse 1-8-8 read instruction */
649+
opcode = FIELD_GET(BFPT_DWORD17_RD_1_8_8_CMD, bfpt.dwords[SFDP_DWORD(17)]);
650+
if (opcode) {
651+
mode_clocks = FIELD_GET(BFPT_DWORD17_RD_1_8_8_MODE_CLOCKS,
652+
bfpt.dwords[SFDP_DWORD(17)]);
653+
wait_states = FIELD_GET(BFPT_DWORD17_RD_1_8_8_WAIT_STATES,
654+
bfpt.dwords[SFDP_DWORD(17)]);
655+
params->hwcaps.mask |= SNOR_HWCAPS_READ_1_8_8;
656+
spi_nor_set_read_settings(&params->reads[SNOR_CMD_READ_1_8_8],
657+
mode_clocks, wait_states, opcode,
658+
SNOR_PROTO_1_8_8);
659+
}
660+
634661
/* 8D-8D-8D command extension. */
635662
switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
636663
case BFPT_DWORD18_CMD_EXT_REP:
@@ -968,6 +995,8 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
968995
{ SNOR_HWCAPS_READ_1_1_1_DTR, BIT(13) },
969996
{ SNOR_HWCAPS_READ_1_2_2_DTR, BIT(14) },
970997
{ SNOR_HWCAPS_READ_1_4_4_DTR, BIT(15) },
998+
{ SNOR_HWCAPS_READ_1_1_8, BIT(20) },
999+
{ SNOR_HWCAPS_READ_1_8_8, BIT(21) },
9711000
};
9721001
static const struct sfdp_4bait programs[] = {
9731002
{ SNOR_HWCAPS_PP, BIT(6) },

drivers/mtd/spi-nor/sfdp.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ struct sfdp_bfpt {
118118
(BFPT_DWORD16_EN4B_EN4B | BFPT_DWORD16_EX4B_EX4B)
119119
#define BFPT_DWORD16_SWRST_EN_RST BIT(12)
120120

121+
#define BFPT_DWORD17_RD_1_1_8_CMD GENMASK(31, 24)
122+
#define BFPT_DWORD17_RD_1_1_8_MODE_CLOCKS GENMASK(23, 21)
123+
#define BFPT_DWORD17_RD_1_1_8_WAIT_STATES GENMASK(20, 16)
124+
#define BFPT_DWORD17_RD_1_8_8_CMD GENMASK(15, 8)
125+
#define BFPT_DWORD17_RD_1_8_8_MODE_CLOCKS GENMASK(7, 5)
126+
#define BFPT_DWORD17_RD_1_8_8_WAIT_STATES GENMASK(4, 0)
127+
121128
#define BFPT_DWORD18_CMD_EXT_MASK GENMASK(30, 29)
122129
#define BFPT_DWORD18_CMD_EXT_REP (0x0UL << 29) /* Repeat */
123130
#define BFPT_DWORD18_CMD_EXT_INV (0x1UL << 29) /* Invert */

0 commit comments

Comments
 (0)