* [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro
@ 2022-12-23 7:21 tkuw584924
2022-12-23 7:21 ` [PATCH 1/3] mtd: spi-nor: sfdp: Fix index value for SCCR dwords tkuw584924
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: tkuw584924 @ 2022-12-23 7:21 UTC (permalink / raw)
To: linux-mtd
Cc: tudor.ambarus, pratyush, michael, miquel.raynal, richard,
vigneshr, tkuw584924, Bacem.Daassi, Takahiro Kuwano
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Existing BFPT_DWORD() converts 1-based indexing to 0-based indexing for
C arrays, and is used in BFPT parse. This is applicable to other parameter
tables than BFPT.
Based on a suggestion in:
https://patchwork.ozlabs.org/project/linux-mtd/patch/20220912051317.2369-1-Takahiro.Kuwano@infineon.com/
Confirmed all parameter tables described in JESD216F.02 use the same
(1-based) indexing.
Tested with S25HS01GT and S28HS01GT.
Takahiro Kuwano (3):
mtd: spi-nor: sfdp: Fix index value for SCCR dwords
mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD()
mtd: spi-nor: sfdp: Use SFDP_DWORD() macro for optional parameter
tables
drivers/mtd/spi-nor/issi.c | 2 +-
drivers/mtd/spi-nor/macronix.c | 2 +-
drivers/mtd/spi-nor/sfdp.c | 72 ++++++++++++++++++----------------
drivers/mtd/spi-nor/sfdp.h | 9 ++---
4 files changed, 44 insertions(+), 41 deletions(-)
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] mtd: spi-nor: sfdp: Fix index value for SCCR dwords
2022-12-23 7:21 [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro tkuw584924
@ 2022-12-23 7:21 ` tkuw584924
2022-12-23 7:32 ` Tudor Ambarus
2022-12-23 7:21 ` [PATCH 2/3] mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD() tkuw584924
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: tkuw584924 @ 2022-12-23 7:21 UTC (permalink / raw)
To: linux-mtd
Cc: tudor.ambarus, pratyush, michael, miquel.raynal, richard,
vigneshr, tkuw584924, Bacem.Daassi, Takahiro Kuwano
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Array index for SCCR 22th DOWRD should be 21.
Fixes: 981a8d60e01f ("mtd: spi-nor: Parse SFDP SCCR Map")
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Reviewed-by: Michael Walle <michael@walle.cc>
---
drivers/mtd/spi-nor/sfdp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index 8434f654eca1..5df2fcba5483 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -1228,7 +1228,7 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
le32_to_cpu_array(dwords, sccr_header->length);
- if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE, dwords[22]))
+ if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE, dwords[21]))
nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE;
out:
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD()
2022-12-23 7:21 [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro tkuw584924
2022-12-23 7:21 ` [PATCH 1/3] mtd: spi-nor: sfdp: Fix index value for SCCR dwords tkuw584924
@ 2022-12-23 7:21 ` tkuw584924
2022-12-23 7:34 ` Tudor Ambarus
2022-12-23 7:21 ` [PATCH 3/3] mtd: spi-nor: sfdp: Use SFDP_DWORD() macro for optional parameter tables tkuw584924
2022-12-23 7:31 ` [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro Tudor Ambarus
3 siblings, 1 reply; 8+ messages in thread
From: tkuw584924 @ 2022-12-23 7:21 UTC (permalink / raw)
To: linux-mtd
Cc: tudor.ambarus, pratyush, michael, miquel.raynal, richard,
vigneshr, tkuw584924, Bacem.Daassi, Takahiro Kuwano
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
To use this macro for other parameter tables than BFPT.
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
drivers/mtd/spi-nor/issi.c | 2 +-
drivers/mtd/spi-nor/macronix.c | 2 +-
drivers/mtd/spi-nor/sfdp.c | 44 +++++++++++++++++-----------------
drivers/mtd/spi-nor/sfdp.h | 9 ++++---
4 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/drivers/mtd/spi-nor/issi.c b/drivers/mtd/spi-nor/issi.c
index a0ddad2afffc..400e2b42f45a 100644
--- a/drivers/mtd/spi-nor/issi.c
+++ b/drivers/mtd/spi-nor/issi.c
@@ -18,7 +18,7 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor,
* BFPT_DWORD1_ADDRESS_BYTES_3_ONLY.
* Overwrite the number of address bytes advertised by the BFPT.
*/
- if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
+ if ((bfpt->dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
nor->params->addr_nbytes = 4;
diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index d81a4cb2812b..6853ec9ae65d 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -22,7 +22,7 @@ mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
* seems that the F version advertises support for Fast Read 4-4-4 in
* its BFPT table.
*/
- if (bfpt->dwords[BFPT_DWORD(5)] & BFPT_DWORD5_FAST_READ_4_4_4)
+ if (bfpt->dwords[SFDP_DWORD(5)] & BFPT_DWORD5_FAST_READ_4_4_4)
nor->flags |= SNOR_F_4B_OPCODES;
return 0;
diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index 5df2fcba5483..5c2ab868707b 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -242,64 +242,64 @@ static const struct sfdp_bfpt_read sfdp_bfpt_reads[] = {
/* Fast Read 1-1-2 */
{
SNOR_HWCAPS_READ_1_1_2,
- BFPT_DWORD(1), BIT(16), /* Supported bit */
- BFPT_DWORD(4), 0, /* Settings */
+ SFDP_DWORD(1), BIT(16), /* Supported bit */
+ SFDP_DWORD(4), 0, /* Settings */
SNOR_PROTO_1_1_2,
},
/* Fast Read 1-2-2 */
{
SNOR_HWCAPS_READ_1_2_2,
- BFPT_DWORD(1), BIT(20), /* Supported bit */
- BFPT_DWORD(4), 16, /* Settings */
+ SFDP_DWORD(1), BIT(20), /* Supported bit */
+ SFDP_DWORD(4), 16, /* Settings */
SNOR_PROTO_1_2_2,
},
/* Fast Read 2-2-2 */
{
SNOR_HWCAPS_READ_2_2_2,
- BFPT_DWORD(5), BIT(0), /* Supported bit */
- BFPT_DWORD(6), 16, /* Settings */
+ SFDP_DWORD(5), BIT(0), /* Supported bit */
+ SFDP_DWORD(6), 16, /* Settings */
SNOR_PROTO_2_2_2,
},
/* Fast Read 1-1-4 */
{
SNOR_HWCAPS_READ_1_1_4,
- BFPT_DWORD(1), BIT(22), /* Supported bit */
- BFPT_DWORD(3), 16, /* Settings */
+ SFDP_DWORD(1), BIT(22), /* Supported bit */
+ SFDP_DWORD(3), 16, /* Settings */
SNOR_PROTO_1_1_4,
},
/* Fast Read 1-4-4 */
{
SNOR_HWCAPS_READ_1_4_4,
- BFPT_DWORD(1), BIT(21), /* Supported bit */
- BFPT_DWORD(3), 0, /* Settings */
+ SFDP_DWORD(1), BIT(21), /* Supported bit */
+ SFDP_DWORD(3), 0, /* Settings */
SNOR_PROTO_1_4_4,
},
/* Fast Read 4-4-4 */
{
SNOR_HWCAPS_READ_4_4_4,
- BFPT_DWORD(5), BIT(4), /* Supported bit */
- BFPT_DWORD(7), 16, /* Settings */
+ SFDP_DWORD(5), BIT(4), /* Supported bit */
+ SFDP_DWORD(7), 16, /* Settings */
SNOR_PROTO_4_4_4,
},
};
static const struct sfdp_bfpt_erase sfdp_bfpt_erases[] = {
/* Erase Type 1 in DWORD8 bits[15:0] */
- {BFPT_DWORD(8), 0},
+ {SFDP_DWORD(8), 0},
/* Erase Type 2 in DWORD8 bits[31:16] */
- {BFPT_DWORD(8), 16},
+ {SFDP_DWORD(8), 16},
/* Erase Type 3 in DWORD9 bits[15:0] */
- {BFPT_DWORD(9), 0},
+ {SFDP_DWORD(9), 0},
/* Erase Type 4 in DWORD9 bits[31:16] */
- {BFPT_DWORD(9), 16},
+ {SFDP_DWORD(9), 16},
};
/**
@@ -458,7 +458,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
le32_to_cpu_array(bfpt.dwords, BFPT_DWORD_MAX);
/* Number of address bytes. */
- switch (bfpt.dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) {
+ switch (bfpt.dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) {
case BFPT_DWORD1_ADDRESS_BYTES_3_ONLY:
case BFPT_DWORD1_ADDRESS_BYTES_3_OR_4:
params->addr_nbytes = 3;
@@ -475,7 +475,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
}
/* Flash Memory Density (in bits). */
- val = bfpt.dwords[BFPT_DWORD(2)];
+ val = bfpt.dwords[SFDP_DWORD(2)];
if (val & BIT(31)) {
val &= ~BIT(31);
@@ -555,13 +555,13 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
/* Page size: this field specifies 'N' so the page size = 2^N bytes. */
- val = bfpt.dwords[BFPT_DWORD(11)];
+ val = bfpt.dwords[SFDP_DWORD(11)];
val &= BFPT_DWORD11_PAGE_SIZE_MASK;
val >>= BFPT_DWORD11_PAGE_SIZE_SHIFT;
params->page_size = 1U << val;
/* Quad Enable Requirements. */
- switch (bfpt.dwords[BFPT_DWORD(15)] & BFPT_DWORD15_QER_MASK) {
+ switch (bfpt.dwords[SFDP_DWORD(15)] & BFPT_DWORD15_QER_MASK) {
case BFPT_DWORD15_QER_NONE:
params->quad_enable = NULL;
break;
@@ -608,7 +608,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
}
/* Soft Reset support. */
- if (bfpt.dwords[BFPT_DWORD(16)] & BFPT_DWORD16_SWRST_EN_RST)
+ if (bfpt.dwords[SFDP_DWORD(16)] & BFPT_DWORD16_SWRST_EN_RST)
nor->flags |= SNOR_F_SOFT_RESET;
/* Stop here if not JESD216 rev C or later. */
@@ -616,7 +616,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
/* 8D-8D-8D command extension. */
- switch (bfpt.dwords[BFPT_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
+ switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
case BFPT_DWORD18_CMD_EXT_REP:
nor->cmd_ext_type = SPI_NOR_EXT_REPEAT;
break;
diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h
index c1969f0a2f46..500659b35655 100644
--- a/drivers/mtd/spi-nor/sfdp.h
+++ b/drivers/mtd/spi-nor/sfdp.h
@@ -13,13 +13,12 @@
#define SFDP_JESD216A_MINOR 5
#define SFDP_JESD216B_MINOR 6
+/* SFDP DWORDS are indexed from 1 but C arrays are indexed from 0. */
+#define SFDP_DWORD(i) ((i) - 1)
+
/* Basic Flash Parameter Table */
-/*
- * JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs.
- * They are indexed from 1 but C arrays are indexed from 0.
- */
-#define BFPT_DWORD(i) ((i) - 1)
+/* JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs. */
#define BFPT_DWORD_MAX 20
struct sfdp_bfpt {
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] mtd: spi-nor: sfdp: Use SFDP_DWORD() macro for optional parameter tables
2022-12-23 7:21 [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro tkuw584924
2022-12-23 7:21 ` [PATCH 1/3] mtd: spi-nor: sfdp: Fix index value for SCCR dwords tkuw584924
2022-12-23 7:21 ` [PATCH 2/3] mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD() tkuw584924
@ 2022-12-23 7:21 ` tkuw584924
2022-12-23 7:36 ` Tudor Ambarus
2022-12-23 7:31 ` [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro Tudor Ambarus
3 siblings, 1 reply; 8+ messages in thread
From: tkuw584924 @ 2022-12-23 7:21 UTC (permalink / raw)
To: linux-mtd
Cc: tudor.ambarus, pratyush, michael, miquel.raynal, richard,
vigneshr, tkuw584924, Bacem.Daassi, Takahiro Kuwano
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Change 0-based indexing values of parameter tables to 1-based ones by
SFDP_DWORD() macro.
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
drivers/mtd/spi-nor/sfdp.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index 5c2ab868707b..3acc01c3a900 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -1004,7 +1004,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
discard_hwcaps |= read->hwcaps;
if ((params->hwcaps.mask & read->hwcaps) &&
- (dwords[0] & read->supported_bit))
+ (dwords[SFDP_DWORD(1)] & read->supported_bit))
read_hwcaps |= read->hwcaps;
}
@@ -1023,7 +1023,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
* authority for specifying Page Program support.
*/
discard_hwcaps |= program->hwcaps;
- if (dwords[0] & program->supported_bit)
+ if (dwords[SFDP_DWORD(1)] & program->supported_bit)
pp_hwcaps |= program->hwcaps;
}
@@ -1035,7 +1035,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) {
const struct sfdp_4bait *erase = &erases[i];
- if (dwords[0] & erase->supported_bit)
+ if (dwords[SFDP_DWORD(1)] & erase->supported_bit)
erase_mask |= BIT(i);
}
@@ -1086,7 +1086,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) {
if (erase_mask & BIT(i))
- erase_type[i].opcode = (dwords[1] >>
+ erase_type[i].opcode = (dwords[SFDP_DWORD(2)] >>
erase_type[i].idx * 8) & 0xFF;
else
spi_nor_set_erase_type(&erase_type[i], 0u, 0xFF);
@@ -1145,15 +1145,15 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
le32_to_cpu_array(dwords, profile1_header->length);
/* Get 8D-8D-8D fast read opcode and dummy cycles. */
- opcode = FIELD_GET(PROFILE1_DWORD1_RD_FAST_CMD, dwords[0]);
+ opcode = FIELD_GET(PROFILE1_DWORD1_RD_FAST_CMD, dwords[SFDP_DWORD(1)]);
/* Set the Read Status Register dummy cycles and dummy address bytes. */
- if (dwords[0] & PROFILE1_DWORD1_RDSR_DUMMY)
+ if (dwords[SFDP_DWORD(1)] & PROFILE1_DWORD1_RDSR_DUMMY)
nor->params->rdsr_dummy = 8;
else
nor->params->rdsr_dummy = 4;
- if (dwords[0] & PROFILE1_DWORD1_RDSR_ADDR_BYTES)
+ if (dwords[SFDP_DWORD(1)] & PROFILE1_DWORD1_RDSR_ADDR_BYTES)
nor->params->rdsr_addr_nbytes = 4;
else
nor->params->rdsr_addr_nbytes = 0;
@@ -1167,13 +1167,16 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
* Default to PROFILE1_DUMMY_DEFAULT if we don't find anything, and let
* flashes set the correct value if needed in their fixup hooks.
*/
- dummy = FIELD_GET(PROFILE1_DWORD4_DUMMY_200MHZ, dwords[3]);
+ dummy = FIELD_GET(PROFILE1_DWORD4_DUMMY_200MHZ, dwords[SFDP_DWORD(4)]);
if (!dummy)
- dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_166MHZ, dwords[4]);
+ dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_166MHZ,
+ dwords[SFDP_DWORD(5)]);
if (!dummy)
- dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_133MHZ, dwords[4]);
+ dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_133MHZ,
+ dwords[SFDP_DWORD(5)]);
if (!dummy)
- dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_100MHZ, dwords[4]);
+ dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_100MHZ,
+ dwords[SFDP_DWORD(5)]);
if (!dummy)
dev_dbg(nor->dev,
"Can't find dummy cycles from Profile 1.0 table\n");
@@ -1228,7 +1231,8 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
le32_to_cpu_array(dwords, sccr_header->length);
- if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE, dwords[21]))
+ if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE,
+ dwords[SFDP_DWORD(22)]))
nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE;
out:
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro
2022-12-23 7:21 [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro tkuw584924
` (2 preceding siblings ...)
2022-12-23 7:21 ` [PATCH 3/3] mtd: spi-nor: sfdp: Use SFDP_DWORD() macro for optional parameter tables tkuw584924
@ 2022-12-23 7:31 ` Tudor Ambarus
3 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2022-12-23 7:31 UTC (permalink / raw)
To: tkuw584924, linux-mtd
Cc: pratyush, michael, miquel.raynal, richard, vigneshr,
Bacem.Daassi, Takahiro Kuwano
Thanks for working on this, Takahiro!
On 23.12.2022 09:21, tkuw584924@gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>
> Existing BFPT_DWORD() converts 1-based indexing to 0-based indexing for
> C arrays, and is used in BFPT parse. This is applicable to other parameter
> tables than BFPT.
>
> Based on a suggestion in:
> https://patchwork.ozlabs.org/project/linux-mtd/patch/20220912051317.2369-1-Takahiro.Kuwano@infineon.com/
Feel free to add the Suggestion-by tag, it will split responsibility and
also give some credit.
>
> Confirmed all parameter tables described in JESD216F.02 use the same
> (1-based) indexing.
>
> Tested with S25HS01GT and S28HS01GT.
>
Cool!
> Takahiro Kuwano (3):
> mtd: spi-nor: sfdp: Fix index value for SCCR dwords
> mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD()
> mtd: spi-nor: sfdp: Use SFDP_DWORD() macro for optional parameter
> tables
>
> drivers/mtd/spi-nor/issi.c | 2 +-
> drivers/mtd/spi-nor/macronix.c | 2 +-
> drivers/mtd/spi-nor/sfdp.c | 72 ++++++++++++++++++----------------
> drivers/mtd/spi-nor/sfdp.h | 9 ++---
> 4 files changed, 44 insertions(+), 41 deletions(-)
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] mtd: spi-nor: sfdp: Fix index value for SCCR dwords
2022-12-23 7:21 ` [PATCH 1/3] mtd: spi-nor: sfdp: Fix index value for SCCR dwords tkuw584924
@ 2022-12-23 7:32 ` Tudor Ambarus
0 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2022-12-23 7:32 UTC (permalink / raw)
To: tkuw584924, linux-mtd
Cc: pratyush, michael, miquel.raynal, richard, vigneshr,
Bacem.Daassi, Takahiro Kuwano
On 23.12.2022 09:21, tkuw584924@gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>
> Array index for SCCR 22th DOWRD should be 21.
>
don't forget to cc stable:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> Fixes: 981a8d60e01f ("mtd: spi-nor: Parse SFDP SCCR Map")
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> Reviewed-by: Michael Walle <michael@walle.cc>
> ---
> drivers/mtd/spi-nor/sfdp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
> index 8434f654eca1..5df2fcba5483 100644
> --- a/drivers/mtd/spi-nor/sfdp.c
> +++ b/drivers/mtd/spi-nor/sfdp.c
> @@ -1228,7 +1228,7 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
>
> le32_to_cpu_array(dwords, sccr_header->length);
>
> - if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE, dwords[22]))
> + if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE, dwords[21]))
> nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE;
>
> out:
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD()
2022-12-23 7:21 ` [PATCH 2/3] mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD() tkuw584924
@ 2022-12-23 7:34 ` Tudor Ambarus
0 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2022-12-23 7:34 UTC (permalink / raw)
To: tkuw584924, linux-mtd
Cc: pratyush, michael, miquel.raynal, richard, vigneshr,
Bacem.Daassi, Takahiro Kuwano
On 23.12.2022 09:21, tkuw584924@gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>
> To use this macro for other parameter tables than BFPT.
In the future please try to not use the commit message as a continuation
of the commit subject. Explain what you do also in the commit message.
looks good!
>
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> ---
> drivers/mtd/spi-nor/issi.c | 2 +-
> drivers/mtd/spi-nor/macronix.c | 2 +-
> drivers/mtd/spi-nor/sfdp.c | 44 +++++++++++++++++-----------------
> drivers/mtd/spi-nor/sfdp.h | 9 ++++---
> 4 files changed, 28 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/issi.c b/drivers/mtd/spi-nor/issi.c
> index a0ddad2afffc..400e2b42f45a 100644
> --- a/drivers/mtd/spi-nor/issi.c
> +++ b/drivers/mtd/spi-nor/issi.c
> @@ -18,7 +18,7 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor,
> * BFPT_DWORD1_ADDRESS_BYTES_3_ONLY.
> * Overwrite the number of address bytes advertised by the BFPT.
> */
> - if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
> + if ((bfpt->dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
> BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
> nor->params->addr_nbytes = 4;
>
> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> index d81a4cb2812b..6853ec9ae65d 100644
> --- a/drivers/mtd/spi-nor/macronix.c
> +++ b/drivers/mtd/spi-nor/macronix.c
> @@ -22,7 +22,7 @@ mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
> * seems that the F version advertises support for Fast Read 4-4-4 in
> * its BFPT table.
> */
> - if (bfpt->dwords[BFPT_DWORD(5)] & BFPT_DWORD5_FAST_READ_4_4_4)
> + if (bfpt->dwords[SFDP_DWORD(5)] & BFPT_DWORD5_FAST_READ_4_4_4)
> nor->flags |= SNOR_F_4B_OPCODES;
>
> return 0;
> diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
> index 5df2fcba5483..5c2ab868707b 100644
> --- a/drivers/mtd/spi-nor/sfdp.c
> +++ b/drivers/mtd/spi-nor/sfdp.c
> @@ -242,64 +242,64 @@ static const struct sfdp_bfpt_read sfdp_bfpt_reads[] = {
> /* Fast Read 1-1-2 */
> {
> SNOR_HWCAPS_READ_1_1_2,
> - BFPT_DWORD(1), BIT(16), /* Supported bit */
> - BFPT_DWORD(4), 0, /* Settings */
> + SFDP_DWORD(1), BIT(16), /* Supported bit */
> + SFDP_DWORD(4), 0, /* Settings */
> SNOR_PROTO_1_1_2,
> },
>
> /* Fast Read 1-2-2 */
> {
> SNOR_HWCAPS_READ_1_2_2,
> - BFPT_DWORD(1), BIT(20), /* Supported bit */
> - BFPT_DWORD(4), 16, /* Settings */
> + SFDP_DWORD(1), BIT(20), /* Supported bit */
> + SFDP_DWORD(4), 16, /* Settings */
> SNOR_PROTO_1_2_2,
> },
>
> /* Fast Read 2-2-2 */
> {
> SNOR_HWCAPS_READ_2_2_2,
> - BFPT_DWORD(5), BIT(0), /* Supported bit */
> - BFPT_DWORD(6), 16, /* Settings */
> + SFDP_DWORD(5), BIT(0), /* Supported bit */
> + SFDP_DWORD(6), 16, /* Settings */
> SNOR_PROTO_2_2_2,
> },
>
> /* Fast Read 1-1-4 */
> {
> SNOR_HWCAPS_READ_1_1_4,
> - BFPT_DWORD(1), BIT(22), /* Supported bit */
> - BFPT_DWORD(3), 16, /* Settings */
> + SFDP_DWORD(1), BIT(22), /* Supported bit */
> + SFDP_DWORD(3), 16, /* Settings */
> SNOR_PROTO_1_1_4,
> },
>
> /* Fast Read 1-4-4 */
> {
> SNOR_HWCAPS_READ_1_4_4,
> - BFPT_DWORD(1), BIT(21), /* Supported bit */
> - BFPT_DWORD(3), 0, /* Settings */
> + SFDP_DWORD(1), BIT(21), /* Supported bit */
> + SFDP_DWORD(3), 0, /* Settings */
> SNOR_PROTO_1_4_4,
> },
>
> /* Fast Read 4-4-4 */
> {
> SNOR_HWCAPS_READ_4_4_4,
> - BFPT_DWORD(5), BIT(4), /* Supported bit */
> - BFPT_DWORD(7), 16, /* Settings */
> + SFDP_DWORD(5), BIT(4), /* Supported bit */
> + SFDP_DWORD(7), 16, /* Settings */
> SNOR_PROTO_4_4_4,
> },
> };
>
> static const struct sfdp_bfpt_erase sfdp_bfpt_erases[] = {
> /* Erase Type 1 in DWORD8 bits[15:0] */
> - {BFPT_DWORD(8), 0},
> + {SFDP_DWORD(8), 0},
>
> /* Erase Type 2 in DWORD8 bits[31:16] */
> - {BFPT_DWORD(8), 16},
> + {SFDP_DWORD(8), 16},
>
> /* Erase Type 3 in DWORD9 bits[15:0] */
> - {BFPT_DWORD(9), 0},
> + {SFDP_DWORD(9), 0},
>
> /* Erase Type 4 in DWORD9 bits[31:16] */
> - {BFPT_DWORD(9), 16},
> + {SFDP_DWORD(9), 16},
> };
>
> /**
> @@ -458,7 +458,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
> le32_to_cpu_array(bfpt.dwords, BFPT_DWORD_MAX);
>
> /* Number of address bytes. */
> - switch (bfpt.dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) {
> + switch (bfpt.dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) {
> case BFPT_DWORD1_ADDRESS_BYTES_3_ONLY:
> case BFPT_DWORD1_ADDRESS_BYTES_3_OR_4:
> params->addr_nbytes = 3;
> @@ -475,7 +475,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
> }
>
> /* Flash Memory Density (in bits). */
> - val = bfpt.dwords[BFPT_DWORD(2)];
> + val = bfpt.dwords[SFDP_DWORD(2)];
> if (val & BIT(31)) {
> val &= ~BIT(31);
>
> @@ -555,13 +555,13 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
> return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
>
> /* Page size: this field specifies 'N' so the page size = 2^N bytes. */
> - val = bfpt.dwords[BFPT_DWORD(11)];
> + val = bfpt.dwords[SFDP_DWORD(11)];
> val &= BFPT_DWORD11_PAGE_SIZE_MASK;
> val >>= BFPT_DWORD11_PAGE_SIZE_SHIFT;
> params->page_size = 1U << val;
>
> /* Quad Enable Requirements. */
> - switch (bfpt.dwords[BFPT_DWORD(15)] & BFPT_DWORD15_QER_MASK) {
> + switch (bfpt.dwords[SFDP_DWORD(15)] & BFPT_DWORD15_QER_MASK) {
> case BFPT_DWORD15_QER_NONE:
> params->quad_enable = NULL;
> break;
> @@ -608,7 +608,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
> }
>
> /* Soft Reset support. */
> - if (bfpt.dwords[BFPT_DWORD(16)] & BFPT_DWORD16_SWRST_EN_RST)
> + if (bfpt.dwords[SFDP_DWORD(16)] & BFPT_DWORD16_SWRST_EN_RST)
> nor->flags |= SNOR_F_SOFT_RESET;
>
> /* Stop here if not JESD216 rev C or later. */
> @@ -616,7 +616,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
> return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
>
> /* 8D-8D-8D command extension. */
> - switch (bfpt.dwords[BFPT_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
> + switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
> case BFPT_DWORD18_CMD_EXT_REP:
> nor->cmd_ext_type = SPI_NOR_EXT_REPEAT;
> break;
> diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h
> index c1969f0a2f46..500659b35655 100644
> --- a/drivers/mtd/spi-nor/sfdp.h
> +++ b/drivers/mtd/spi-nor/sfdp.h
> @@ -13,13 +13,12 @@
> #define SFDP_JESD216A_MINOR 5
> #define SFDP_JESD216B_MINOR 6
>
> +/* SFDP DWORDS are indexed from 1 but C arrays are indexed from 0. */
> +#define SFDP_DWORD(i) ((i) - 1)
> +
> /* Basic Flash Parameter Table */
>
> -/*
> - * JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs.
> - * They are indexed from 1 but C arrays are indexed from 0.
> - */
> -#define BFPT_DWORD(i) ((i) - 1)
> +/* JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs. */
> #define BFPT_DWORD_MAX 20
>
> struct sfdp_bfpt {
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] mtd: spi-nor: sfdp: Use SFDP_DWORD() macro for optional parameter tables
2022-12-23 7:21 ` [PATCH 3/3] mtd: spi-nor: sfdp: Use SFDP_DWORD() macro for optional parameter tables tkuw584924
@ 2022-12-23 7:36 ` Tudor Ambarus
0 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2022-12-23 7:36 UTC (permalink / raw)
To: tkuw584924, linux-mtd
Cc: pratyush, michael, miquel.raynal, richard, vigneshr,
Bacem.Daassi, Takahiro Kuwano
On 23.12.2022 09:21, tkuw584924@gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>
> Change 0-based indexing values of parameter tables to 1-based ones by
> SFDP_DWORD() macro.
>
marvelous! The series is looking good. If you want to resubmit for those
small comments, fine, otherwise I'll handle them when applying.
Cheers,
ta
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> ---
> drivers/mtd/spi-nor/sfdp.c | 28 ++++++++++++++++------------
> 1 file changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
> index 5c2ab868707b..3acc01c3a900 100644
> --- a/drivers/mtd/spi-nor/sfdp.c
> +++ b/drivers/mtd/spi-nor/sfdp.c
> @@ -1004,7 +1004,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
>
> discard_hwcaps |= read->hwcaps;
> if ((params->hwcaps.mask & read->hwcaps) &&
> - (dwords[0] & read->supported_bit))
> + (dwords[SFDP_DWORD(1)] & read->supported_bit))
> read_hwcaps |= read->hwcaps;
> }
>
> @@ -1023,7 +1023,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
> * authority for specifying Page Program support.
> */
> discard_hwcaps |= program->hwcaps;
> - if (dwords[0] & program->supported_bit)
> + if (dwords[SFDP_DWORD(1)] & program->supported_bit)
> pp_hwcaps |= program->hwcaps;
> }
>
> @@ -1035,7 +1035,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
> for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) {
> const struct sfdp_4bait *erase = &erases[i];
>
> - if (dwords[0] & erase->supported_bit)
> + if (dwords[SFDP_DWORD(1)] & erase->supported_bit)
> erase_mask |= BIT(i);
> }
>
> @@ -1086,7 +1086,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
>
> for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) {
> if (erase_mask & BIT(i))
> - erase_type[i].opcode = (dwords[1] >>
> + erase_type[i].opcode = (dwords[SFDP_DWORD(2)] >>
> erase_type[i].idx * 8) & 0xFF;
> else
> spi_nor_set_erase_type(&erase_type[i], 0u, 0xFF);
> @@ -1145,15 +1145,15 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
> le32_to_cpu_array(dwords, profile1_header->length);
>
> /* Get 8D-8D-8D fast read opcode and dummy cycles. */
> - opcode = FIELD_GET(PROFILE1_DWORD1_RD_FAST_CMD, dwords[0]);
> + opcode = FIELD_GET(PROFILE1_DWORD1_RD_FAST_CMD, dwords[SFDP_DWORD(1)]);
>
> /* Set the Read Status Register dummy cycles and dummy address bytes. */
> - if (dwords[0] & PROFILE1_DWORD1_RDSR_DUMMY)
> + if (dwords[SFDP_DWORD(1)] & PROFILE1_DWORD1_RDSR_DUMMY)
> nor->params->rdsr_dummy = 8;
> else
> nor->params->rdsr_dummy = 4;
>
> - if (dwords[0] & PROFILE1_DWORD1_RDSR_ADDR_BYTES)
> + if (dwords[SFDP_DWORD(1)] & PROFILE1_DWORD1_RDSR_ADDR_BYTES)
> nor->params->rdsr_addr_nbytes = 4;
> else
> nor->params->rdsr_addr_nbytes = 0;
> @@ -1167,13 +1167,16 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
> * Default to PROFILE1_DUMMY_DEFAULT if we don't find anything, and let
> * flashes set the correct value if needed in their fixup hooks.
> */
> - dummy = FIELD_GET(PROFILE1_DWORD4_DUMMY_200MHZ, dwords[3]);
> + dummy = FIELD_GET(PROFILE1_DWORD4_DUMMY_200MHZ, dwords[SFDP_DWORD(4)]);
> if (!dummy)
> - dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_166MHZ, dwords[4]);
> + dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_166MHZ,
> + dwords[SFDP_DWORD(5)]);
> if (!dummy)
> - dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_133MHZ, dwords[4]);
> + dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_133MHZ,
> + dwords[SFDP_DWORD(5)]);
> if (!dummy)
> - dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_100MHZ, dwords[4]);
> + dummy = FIELD_GET(PROFILE1_DWORD5_DUMMY_100MHZ,
> + dwords[SFDP_DWORD(5)]);
> if (!dummy)
> dev_dbg(nor->dev,
> "Can't find dummy cycles from Profile 1.0 table\n");
> @@ -1228,7 +1231,8 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
>
> le32_to_cpu_array(dwords, sccr_header->length);
>
> - if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE, dwords[21]))
> + if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE,
> + dwords[SFDP_DWORD(22)]))
> nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE;
>
> out:
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-12-23 7:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 7:21 [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro tkuw584924
2022-12-23 7:21 ` [PATCH 1/3] mtd: spi-nor: sfdp: Fix index value for SCCR dwords tkuw584924
2022-12-23 7:32 ` Tudor Ambarus
2022-12-23 7:21 ` [PATCH 2/3] mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD() tkuw584924
2022-12-23 7:34 ` Tudor Ambarus
2022-12-23 7:21 ` [PATCH 3/3] mtd: spi-nor: sfdp: Use SFDP_DWORD() macro for optional parameter tables tkuw584924
2022-12-23 7:36 ` Tudor Ambarus
2022-12-23 7:31 ` [PATCH 0/3] mtd: spi-nor: sfdp: Introduce SFDP_DWORD() macro Tudor Ambarus
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.