Skip to contentSkip to conversation

Get the 1-1-8 protocol from BFPT

PATCH Superseded Jaime Liao 3 participants 10 messages Dec 14, 2023 – Dec 15, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jaime Liao

author
#0 lore raw

v2 cover Get the 1-1-8 protocol from BFPT

From: appswa2 <[email protected]>

v2:
Change unnecessary description in commit log.
Remove SFDP version judgement.

JaimeLiao (1):
mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

 drivers/mtd/spi-nor/sfdp.c | 13 ++++++++++++-
 drivers/mtd/spi-nor/sfdp.h |  3 +++
 2 files changed, 15 insertions(+), 1 deletion(-)
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
author
#1 lore raw

PATCH v2 1/1 mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8, Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

---
 drivers/mtd/spi-nor/sfdp.c | 13 ++++++++++++-
 drivers/mtd/spi-nor/sfdp.h |  3 +++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/sfdp.c +12 -1
index b3b11dfed789..c55f39978762 100644
@@ -446,6 +446,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 	u32 dword;
 	u16 half;
 	u8 erase_mask;
+	u8 dummy, opcode;
 
 	/* JESD216 Basic Flash Parameter Table length is at least 9 DWORDs. */
 	if (bfpt_header->length < BFPT_DWORD_MAX_JESD216)
@@ -525,7 +526,6 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 	for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_erases); i++) {
 		const struct sfdp_bfpt_erase *er = &sfdp_bfpt_erases[i];
 		u32 erasesize;
-		u8 opcode;
 
 		half = bfpt.dwords[er->dword] >> er->shift;
 		erasesize = half & 0xff;
@@ -631,6 +631,16 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 	if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
 		return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
 
+	/* Parse 1-1-8 read instruction */
+	opcode = FIELD_GET(BFPT_DWORD17_RD_1_1_8_CMD, bfpt.dwords[SFDP_DWORD(17)]);
+	if (opcode) {
+		dummy = FIELD_GET(BFPT_DWORD17_RD_1_1_8_DUMMY, bfpt.dwords[SFDP_DWORD(17)]);
+		nor->params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8;
+		spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_1_1_8],
+					  0, dummy, opcode,
+					  SNOR_PROTO_1_1_8);
+	}
+
 	/* 8D-8D-8D command extension. */
 	switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
 	case BFPT_DWORD18_CMD_EXT_REP:
@@ -968,6 +978,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
 		{ SNOR_HWCAPS_READ_1_1_1_DTR,	BIT(13) },
 		{ SNOR_HWCAPS_READ_1_2_2_DTR,	BIT(14) },
 		{ SNOR_HWCAPS_READ_1_4_4_DTR,	BIT(15) },
+		{ SNOR_HWCAPS_READ_1_1_8,	BIT(20) },
 	};
 	static const struct sfdp_4bait programs[] = {
 		{ SNOR_HWCAPS_PP,		BIT(6) },
drivers/mtd/spi-nor/sfdp.h +3 -0
index 6eb99e1cdd61..584a05f9931d 100644
@@ -118,6 +118,9 @@ struct sfdp_bfpt {
 	(BFPT_DWORD16_EN4B_EN4B | BFPT_DWORD16_EX4B_EX4B)
 #define BFPT_DWORD16_SWRST_EN_RST		BIT(12)
 
+#define BFPT_DWORD17_RD_1_1_8_CMD		GENMASK(31, 24)
+#define BFPT_DWORD17_RD_1_1_8_DUMMY		GENMASK(20, 16)
+
 #define BFPT_DWORD18_CMD_EXT_MASK		GENMASK(30, 29)
 #define BFPT_DWORD18_CMD_EXT_REP		(0x0UL << 29) /* Repeat */
 #define BFPT_DWORD18_CMD_EXT_INV		(0x1UL << 29) /* Invert */
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Reviewed-by on v2 1/1
#2 lore raw

Re: [PATCH v2 1/1] mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

Hi,

Quoted 8 lines

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8, Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

Quoted 1 line

---

no need for a 0/N cover letter just for the changelog. That can be included here below the "---".

And you can also keep my Rb tag.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

author
#3 lore raw

Re: [PATCH v2 1/1] mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

Hi Michael

Quoted 12 lines

Hi,

Quoted 8 lines

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8, Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

Quoted 8 lines
Quoted 1 line

---

no need for a 0/N cover letter just for the changelog. That can be included here below the "---".

And you can also keep my Rb tag.

Got it.
Would this version be accepted or should I send a new one?

Quoted 2 lines

-michael

Thanks
Jaime

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#4 lore raw

Re: [PATCH v2 1/1] mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

Quoted 11 lines
Quoted 11 lines
Quoted 8 lines

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8, Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

---

no need for a 0/N cover letter just for the changelog. That can be included here below the "---".

And you can also keep my Rb tag.

Got it.
Would this version be accepted or should I send a new one?

No need for a new one. Just for your future patches.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

author
#5 lore raw

Re: [PATCH v2 1/1] mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

Hi Michael

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 9 lines

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8, Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

Quoted 1 line

---

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

no need for a 0/N cover letter just for the changelog. That can be included here below the "---".

And you can also keep my Rb tag.

Got it.
Would this version be accepted or should I send a new one?

No need for a new one. Just for your future patches.

Thank for your reply.

Quoted 2 lines

-michael

Thank
Jaime

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#6 lore raw

Re: [PATCH v2 1/1] mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

In reply to Jaime Liao

Hi, Jaime,

Please update the commit subject to indicate that you parse 4BAIT as well.

Quoted 3 lines · Jaime Liao

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8,

Please run checkpatch on further submissions:
./scripts/checkpatch.pl --strict 000*
WARNING: 'informations' may be misspelled - perhaps 'information'? #6:
BFPT 17th DWORD contains the informations about 1-1-8,

                             ^^^^^^^^^^^^

total: 0 errors, 1 warnings, 0 checks, 46 lines checked

Quoted 33 lines

Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

---
 drivers/mtd/spi-nor/sfdp.c | 13 ++++++++++++-
 drivers/mtd/spi-nor/sfdp.h |  3 +++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/sfdp.c +1 -1
index b3b11dfed789..c55f39978762 100644
@@ -446,6 +446,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 	u32 dword;
 	u16 half;
 	u8 erase_mask;
+	u8 dummy, opcode;
 
 	/* JESD216 Basic Flash Parameter Table length is at least 9 DWORDs. */
 	if (bfpt_header->length < BFPT_DWORD_MAX_JESD216)
@@ -525,7 +526,6 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 	for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_erases); i++) {
 		const struct sfdp_bfpt_erase *er = &sfdp_bfpt_erases[i];
 		u32 erasesize;
-		u8 opcode;
 
 		half = bfpt.dwords[er->dword] >> er->shift;
 		erasesize = half & 0xff;
@@ -631,6 +631,16 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 	if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
 		return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);

drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_bfpt(struct spi_nor *nor, · line 642

Quoted 10 lines
drivers/mtd/spi-nor/sfdp.c +9 -0
 
+	/* Parse 1-1-8 read instruction */
+	opcode = FIELD_GET(BFPT_DWORD17_RD_1_1_8_CMD, bfpt.dwords[SFDP_DWORD(17)]);
+	if (opcode) {
+		dummy = FIELD_GET(BFPT_DWORD17_RD_1_1_8_DUMMY, bfpt.dwords[SFDP_DWORD(17)]);
+		nor->params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8;
+		spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_1_1_8],
+					  0, dummy, opcode,
+					  SNOR_PROTO_1_1_8);
+	}

You missed the mode clocks. You missed to parse 1-8-8. Please check how the read settings are parsed and set in parse_bfpt() and do the same here. See:
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/drivers/mtd/spi-nor/sfdp.c?h=spi-nor/next#n502

drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_4bait(struct spi_nor *nor, · line 981

Quoted 9 lines
drivers/mtd/spi-nor/sfdp.c +2 -0
+
 	/* 8D-8D-8D command extension. */
 	switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
 	case BFPT_DWORD18_CMD_EXT_REP:
@@ -968,6 +978,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
 		{ SNOR_HWCAPS_READ_1_1_1_DTR,	BIT(13) },
 		{ SNOR_HWCAPS_READ_1_2_2_DTR,	BIT(14) },
 		{ SNOR_HWCAPS_READ_1_4_4_DTR,	BIT(15) },
+		{ SNOR_HWCAPS_READ_1_1_8,	BIT(20) },

let's set 1-8-8 as well please

Quoted 8 lines
drivers/mtd/spi-nor/sfdp.c +0 -0
 	};
 	static const struct sfdp_4bait programs[] = {
 		{ SNOR_HWCAPS_PP,		BIT(6) },
drivers/mtd/spi-nor/sfdp.h +0 -0
index 6eb99e1cdd61..584a05f9931d 100644

drivers/mtd/spi-nor/sfdp.h struct sfdp_bfpt { · line 126

Quoted 9 lines
drivers/mtd/spi-nor/sfdp.h +3 -0
@@ -118,6 +118,9 @@ struct sfdp_bfpt {
 	(BFPT_DWORD16_EN4B_EN4B | BFPT_DWORD16_EX4B_EX4B)
 #define BFPT_DWORD16_SWRST_EN_RST		BIT(12)
 
+#define BFPT_DWORD17_RD_1_1_8_CMD		GENMASK(31, 24)
+#define BFPT_DWORD17_RD_1_1_8_DUMMY		GENMASK(20, 16)
+
 #define BFPT_DWORD18_CMD_EXT_MASK		GENMASK(30, 29)
 #define BFPT_DWORD18_CMD_EXT_REP		(0x0UL << 29) /* Repeat */
 #define BFPT_DWORD18_CMD_EXT_INV		(0x1UL << 29) /* Invert */

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

author
#7 lore raw

Re: [PATCH v2 1/1] mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

Hi Tudor

Quoted 4 lines

Hi, Jaime,

Please update the commit subject to indicate that you parse 4BAIT as well.

Got it.

Quoted 50 lines · Jaime Liao
Quoted 3 lines

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8,

Please run checkpatch on further submissions:
./scripts/checkpatch.pl --strict 000*
WARNING: 'informations' may be misspelled - perhaps 'information'? #6:
BFPT 17th DWORD contains the informations about 1-1-8,

                             ^^^^^^^^^^^^

total: 0 errors, 1 warnings, 0 checks, 46 lines checked

Quoted 34 lines

Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

---
 drivers/mtd/spi-nor/sfdp.c | 13 ++++++++++++-
 drivers/mtd/spi-nor/sfdp.h |  3 +++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/sfdp.c +1 -1
index b3b11dfed789..c55f39978762 100644
@@ -446,6 +446,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      u32 dword;
      u16 half;
      u8 erase_mask;
+     u8 dummy, opcode;
 
      /* JESD216 Basic Flash Parameter Table length is at least 9 DWORDs. */
      if (bfpt_header->length < BFPT_DWORD_MAX_JESD216)
@@ -525,7 +526,6 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_erases); i++) {
              const struct sfdp_bfpt_erase *er = &sfdp_bfpt_erases[i];
              u32 erasesize;
-             u8 opcode;
 
              half = bfpt.dwords[er->dword] >> er->shift;
              erasesize = half & 0xff;
@@ -631,6 +631,16 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
              return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
 
Quoted 14 lines

drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_bfpt(struct spi_nor *nor, · line 642

Quoted 9 lines
drivers/mtd/spi-nor/sfdp.c +9 -0
+     /* Parse 1-1-8 read instruction */
+     opcode = FIELD_GET(BFPT_DWORD17_RD_1_1_8_CMD, bfpt.dwords[SFDP_DWORD(17)]);
+     if (opcode) {
+             dummy = FIELD_GET(BFPT_DWORD17_RD_1_1_8_DUMMY, bfpt.dwords[SFDP_DWORD(17)]);
+             nor->params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8;
+             spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_1_1_8],
+                                       0, dummy, opcode,
+                                       SNOR_PROTO_1_1_8);
+     }

You missed the mode clocks. You missed to parse 1-8-8. Please check how the read settings are parsed and set in parse_bfpt() and do the same here. See:
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/drivers/mtd/spi-nor/sfdp.c?h=spi-nor/next#n502

Macronix Flash didn't support 1-8-8 feature.
So that I have no sample for validate it.
About read setting in parse_bfpt(), that is a good way for scan and set for each protocol.
But 1-1-8 support judgement is not a single bit.
1-1-8 read instruction could determine wether 1-1-8 support or not.

Quoted 24 lines

drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_4bait(struct spi_nor *nor, · line 981

Quoted 10 lines
drivers/mtd/spi-nor/sfdp.c +2 -0
+
      /* 8D-8D-8D command extension. */
      switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
      case BFPT_DWORD18_CMD_EXT_REP:
@@ -968,6 +978,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
              { SNOR_HWCAPS_READ_1_1_1_DTR,   BIT(13) },
              { SNOR_HWCAPS_READ_1_2_2_DTR,   BIT(14) },
              { SNOR_HWCAPS_READ_1_4_4_DTR,   BIT(15) },
+             { SNOR_HWCAPS_READ_1_1_8,       BIT(20) },

let's set 1-8-8 as well please

Quoted 11 lines
drivers/mtd/spi-nor/sfdp.c +0 -0
      };
      static const struct sfdp_4bait programs[] = {
              { SNOR_HWCAPS_PP,               BIT(6) },
drivers/mtd/spi-nor/sfdp.h +0 -0
index 6eb99e1cdd61..584a05f9931d 100644
@@ -118,6 +118,9 @@ struct sfdp_bfpt {
      (BFPT_DWORD16_EN4B_EN4B | BFPT_DWORD16_EX4B_EX4B)
 #define BFPT_DWORD16_SWRST_EN_RST            BIT(12)
 
Quoted 6 lines

drivers/mtd/spi-nor/sfdp.h struct sfdp_bfpt { · line 126

Quoted 6 lines
drivers/mtd/spi-nor/sfdp.h +3 -0
+#define BFPT_DWORD17_RD_1_1_8_CMD            GENMASK(31, 24)
+#define BFPT_DWORD17_RD_1_1_8_DUMMY          GENMASK(20, 16)
+
 #define BFPT_DWORD18_CMD_EXT_MASK            GENMASK(30, 29)
 #define BFPT_DWORD18_CMD_EXT_REP             (0x0UL << 29) /* Repeat */
 #define BFPT_DWORD18_CMD_EXT_INV             (0x1UL << 29) /* Invert */

Thanks
Jaime

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#8 lore raw

Re: [PATCH v2 1/1] mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

Quoted 2 lines · liao jaime

Hi Tudor

Hi!

Quoted 71 lines
Quoted 5 lines

Hi, Jaime,

Please update the commit subject to indicate that you parse 4BAIT as well.

Got it.

Quoted 50 lines · Jaime Liao
Quoted 3 lines

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8,

Please run checkpatch on further submissions:
./scripts/checkpatch.pl --strict 000*
WARNING: 'informations' may be misspelled - perhaps 'information'? #6:
BFPT 17th DWORD contains the informations about 1-1-8,

                             ^^^^^^^^^^^^

total: 0 errors, 1 warnings, 0 checks, 46 lines checked

Quoted 34 lines

Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

---
 drivers/mtd/spi-nor/sfdp.c | 13 ++++++++++++-
 drivers/mtd/spi-nor/sfdp.h |  3 +++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/sfdp.c +1 -1
index b3b11dfed789..c55f39978762 100644
@@ -446,6 +446,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      u32 dword;
      u16 half;
      u8 erase_mask;
+     u8 dummy, opcode;
 
      /* JESD216 Basic Flash Parameter Table length is at least 9 DWORDs. */
      if (bfpt_header->length < BFPT_DWORD_MAX_JESD216)
@@ -525,7 +526,6 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_erases); i++) {
              const struct sfdp_bfpt_erase *er = &sfdp_bfpt_erases[i];
              u32 erasesize;
-             u8 opcode;
 
              half = bfpt.dwords[er->dword] >> er->shift;
              erasesize = half & 0xff;
@@ -631,6 +631,16 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
              return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
 
Quoted 14 lines

drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_bfpt(struct spi_nor *nor, · line 642

Quoted 9 lines
drivers/mtd/spi-nor/sfdp.c +9 -0
+     /* Parse 1-1-8 read instruction */
+     opcode = FIELD_GET(BFPT_DWORD17_RD_1_1_8_CMD, bfpt.dwords[SFDP_DWORD(17)]);
+     if (opcode) {
+             dummy = FIELD_GET(BFPT_DWORD17_RD_1_1_8_DUMMY, bfpt.dwords[SFDP_DWORD(17)]);
+             nor->params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8;
+             spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_1_1_8],
+                                       0, dummy, opcode,
+                                       SNOR_PROTO_1_1_8);
+     }

You missed the mode clocks. You missed to parse 1-8-8. Please check how the read settings are parsed and set in parse_bfpt() and do the same here. See:
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/drivers/mtd/spi-nor/sfdp.c?h=spi-nor/next#n502

Quoted 2 lines

Macronix Flash didn't support 1-8-8 feature.
So that I have no sample for validate it.

don't worry, add it anyway. Specify in the commit message that you validated just 1-1-8.

Quoted 3 lines

About read setting in parse_bfpt(), that is a good way for scan and set for each protocol.
But 1-1-8 support judgement is not a single bit.

oh the horror. And then it becomes a single bit judgement in bfpt dword
21. Nice consistency :).

Quoted 1 line

1-1-8 read instruction could determine wether 1-1-8 support or not.

Right. Then introduce a dedicated logic for these 2.

Quoted 25 lines
Quoted 25 lines

drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_4bait(struct spi_nor *nor, · line 981

Quoted 11 lines
drivers/mtd/spi-nor/sfdp.c +2 -0
+
      /* 8D-8D-8D command extension. */
      switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
      case BFPT_DWORD18_CMD_EXT_REP:
@@ -968,6 +978,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
              { SNOR_HWCAPS_READ_1_1_1_DTR,   BIT(13) },
              { SNOR_HWCAPS_READ_1_2_2_DTR,   BIT(14) },
              { SNOR_HWCAPS_READ_1_4_4_DTR,   BIT(15) },
+             { SNOR_HWCAPS_READ_1_1_8,       BIT(20) },

let's set 1-8-8 as well please

Quoted 11 lines
drivers/mtd/spi-nor/sfdp.c +0 -0
      };
      static const struct sfdp_4bait programs[] = {
              { SNOR_HWCAPS_PP,               BIT(6) },
drivers/mtd/spi-nor/sfdp.h +0 -0
index 6eb99e1cdd61..584a05f9931d 100644
@@ -118,6 +118,9 @@ struct sfdp_bfpt {
      (BFPT_DWORD16_EN4B_EN4B | BFPT_DWORD16_EX4B_EX4B)
 #define BFPT_DWORD16_SWRST_EN_RST            BIT(12)
 
Quoted 10 lines
Quoted 6 lines

drivers/mtd/spi-nor/sfdp.h struct sfdp_bfpt { · line 126

Quoted 6 lines
drivers/mtd/spi-nor/sfdp.h +3 -0
+#define BFPT_DWORD17_RD_1_1_8_CMD            GENMASK(31, 24)
+#define BFPT_DWORD17_RD_1_1_8_DUMMY          GENMASK(20, 16)
+
 #define BFPT_DWORD18_CMD_EXT_MASK            GENMASK(30, 29)
 #define BFPT_DWORD18_CMD_EXT_REP             (0x0UL << 29) /* Repeat */
 #define BFPT_DWORD18_CMD_EXT_INV             (0x1UL << 29) /* Invert */

Thanks
Jaime

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

author
#9 lore raw

Re: [PATCH v2 1/1] mtd: spi-nor: sfdp: Get the 1-1-8 protocol from BFPT

Hi Tudor

Quoted 79 lines · liao jaime
Quoted 2 lines

Hi Tudor

Hi!

Quoted 71 lines
Quoted 5 lines

Hi, Jaime,

Please update the commit subject to indicate that you parse 4BAIT as well.

Got it.

Quoted 64 lines · Jaime Liao
Quoted 3 lines

From: JaimeLiao <[email protected]>

BFPT 17th DWORD contains the informations about 1-1-8,

Please run checkpatch on further submissions:
./scripts/checkpatch.pl --strict 000*
WARNING: 'informations' may be misspelled - perhaps 'information'? #6:
BFPT 17th DWORD contains the informations about 1-1-8,

                             ^^^^^^^^^^^^

total: 0 errors, 1 warnings, 0 checks, 46 lines checked

Quoted 33 lines

Parse BFPT 17 DWORD instruction to determine whether flash support 1-1-8, and set its dummy cycle accordingly.

---
 drivers/mtd/spi-nor/sfdp.c | 13 ++++++++++++-
 drivers/mtd/spi-nor/sfdp.h |  3 +++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/sfdp.c +1 -1
index b3b11dfed789..c55f39978762 100644
@@ -446,6 +446,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      u32 dword;
      u16 half;
      u8 erase_mask;
+     u8 dummy, opcode;
 
      /* JESD216 Basic Flash Parameter Table length is at least 9 DWORDs. */
      if (bfpt_header->length < BFPT_DWORD_MAX_JESD216)
@@ -525,7 +526,6 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_erases); i++) {
              const struct sfdp_bfpt_erase *er = &sfdp_bfpt_erases[i];
              u32 erasesize;
-             u8 opcode;
 
              half = bfpt.dwords[er->dword] >> er->shift;
              erasesize = half & 0xff;
@@ -631,6 +631,16 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
      if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
              return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);

drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_bfpt(struct spi_nor *nor, · line 642

Quoted 10 lines
drivers/mtd/spi-nor/sfdp.c +9 -0
 
+     /* Parse 1-1-8 read instruction */
+     opcode = FIELD_GET(BFPT_DWORD17_RD_1_1_8_CMD, bfpt.dwords[SFDP_DWORD(17)]);
+     if (opcode) {
+             dummy = FIELD_GET(BFPT_DWORD17_RD_1_1_8_DUMMY, bfpt.dwords[SFDP_DWORD(17)]);
+             nor->params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8;
+             spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_1_1_8],
+                                       0, dummy, opcode,
+                                       SNOR_PROTO_1_1_8);
+     }

You missed the mode clocks. You missed to parse 1-8-8. Please check how the read settings are parsed and set in parse_bfpt() and do the same here. See:
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/drivers/mtd/spi-nor/sfdp.c?h=spi-nor/next#n502

Quoted 5 lines
Quoted 2 lines

Macronix Flash didn't support 1-8-8 feature.
So that I have no sample for validate it.

don't worry, add it anyway. Specify in the commit message that you validated just 1-1-8.

Got it.

Quoted 7 lines
Quoted 4 lines

About read setting in parse_bfpt(), that is a good way for scan and set for each protocol.
But 1-1-8 support judgement is not a single bit.

oh the horror. And then it becomes a single bit judgement in bfpt dword
21. Nice consistency :).

As I know JESD216F BFPT 21th dowrd includes information about 1s-4d-4d and etc. I didn't get it.

Quoted 4 lines
Quoted 2 lines

1-1-8 read instruction could determine wether 1-1-8 support or not.

Right. Then introduce a dedicated logic for these 2.

OK.

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines

drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_4bait(struct spi_nor *nor, · line 981

Quoted 12 lines
drivers/mtd/spi-nor/sfdp.c +2 -0
+
      /* 8D-8D-8D command extension. */
      switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
      case BFPT_DWORD18_CMD_EXT_REP:
@@ -968,6 +978,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
              { SNOR_HWCAPS_READ_1_1_1_DTR,   BIT(13) },
              { SNOR_HWCAPS_READ_1_2_2_DTR,   BIT(14) },
              { SNOR_HWCAPS_READ_1_4_4_DTR,   BIT(15) },
+             { SNOR_HWCAPS_READ_1_1_8,       BIT(20) },

let's set 1-8-8 as well please

Quoted 11 lines
drivers/mtd/spi-nor/sfdp.c +0 -0
      };
      static const struct sfdp_4bait programs[] = {
              { SNOR_HWCAPS_PP,               BIT(6) },
drivers/mtd/spi-nor/sfdp.h +0 -0
index 6eb99e1cdd61..584a05f9931d 100644
@@ -118,6 +118,9 @@ struct sfdp_bfpt {
      (BFPT_DWORD16_EN4B_EN4B | BFPT_DWORD16_EX4B_EX4B)
 #define BFPT_DWORD16_SWRST_EN_RST            BIT(12)
 
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

drivers/mtd/spi-nor/sfdp.h struct sfdp_bfpt { · line 126

Quoted 6 lines
drivers/mtd/spi-nor/sfdp.h +3 -0
+#define BFPT_DWORD17_RD_1_1_8_CMD            GENMASK(31, 24)
+#define BFPT_DWORD17_RD_1_1_8_DUMMY          GENMASK(20, 16)
+
 #define BFPT_DWORD18_CMD_EXT_MASK            GENMASK(30, 29)
 #define BFPT_DWORD18_CMD_EXT_REP             (0x0UL << 29) /* Repeat */
 #define BFPT_DWORD18_CMD_EXT_INV             (0x1UL << 29) /* Invert */

Thanks
Jaime

Thanks
Jaime

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/