Skip to content

Commit dec18bd

Browse files
Pratyush Yadavambarus
authored andcommitted
mtd: spi-nor: sfdp: prepare BFPT parsing for JESD216 rev D
JESD216 rev D makes BFPT 20 DWORDs. Update the BFPT size define to reflect that. The check for rev A or later compared the BFPT header length with the maximum BFPT length, BFPT_DWORD_MAX. Since BFPT_DWORD_MAX was 16, and so was the BFPT length for both rev A and B, this check worked fine. But now, since BFPT_DWORD_MAX is 20, it means this check will also stop BFPT parsing for rev A or B, since their length is 16. So, instead check for BFPT_DWORD_MAX_JESD216 to stop BFPT parsing for the first JESD216 version, and check for BFPT_DWORD_MAX_JESD216B for the next two versions. Signed-off-by: Pratyush Yadav <[email protected]> Signed-off-by: Tudor Ambarus <[email protected]>
1 parent f9acd7f commit dec18bd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

drivers/mtd/spi-nor/sfdp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
549549
SNOR_ERASE_TYPE_MASK;
550550

551551
/* Stop here if not JESD216 rev A or later. */
552-
if (bfpt_header->length < BFPT_DWORD_MAX)
552+
if (bfpt_header->length == BFPT_DWORD_MAX_JESD216)
553553
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt,
554554
params);
555555

@@ -605,6 +605,11 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
605605
return -EINVAL;
606606
}
607607

608+
/* Stop here if not JESD216 rev C or later. */
609+
if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
610+
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt,
611+
params);
612+
608613
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params);
609614
}
610615

drivers/mtd/spi-nor/sfdp.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@
1010
/* Basic Flash Parameter Table */
1111

1212
/*
13-
* JESD216 rev B defines a Basic Flash Parameter Table of 16 DWORDs.
13+
* JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs.
1414
* They are indexed from 1 but C arrays are indexed from 0.
1515
*/
1616
#define BFPT_DWORD(i) ((i) - 1)
17-
#define BFPT_DWORD_MAX 16
17+
#define BFPT_DWORD_MAX 20
1818

1919
struct sfdp_bfpt {
2020
u32 dwords[BFPT_DWORD_MAX];
2121
};
2222

2323
/* The first version of JESD216 defined only 9 DWORDs. */
2424
#define BFPT_DWORD_MAX_JESD216 9
25+
#define BFPT_DWORD_MAX_JESD216B 16
2526

2627
/* 1st DWORD. */
2728
#define BFPT_DWORD1_FAST_READ_1_1_2 BIT(16)

0 commit comments

Comments
 (0)