Skip to content

Commit 86d4cdf

Browse files
Kuwano-sanambarus
authored andcommitted
mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD()
BFPT_DWORD() converts 1-based indexing to 0-based indexing for C arrays, and is used in BFPT parse. Per JESD216F.02, the conversion is applicable to other parameter tables than BFPT. This patch renames the macro to SFDP_DWORD() so that we can use it for other parameter tables than BFPT. Suggested-by: Tudor Ambarus <tudor.ambarus@linaro.org> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> Link: https://lore.kernel.org/r/e42feac840fe3a31187419e91b2d514d9f259d15.1672026365.git.Takahiro.Kuwano@infineon.com
1 parent ad9679f commit 86d4cdf

4 files changed

Lines changed: 28 additions & 29 deletions

File tree

drivers/mtd/spi-nor/issi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor,
1818
* BFPT_DWORD1_ADDRESS_BYTES_3_ONLY.
1919
* Overwrite the number of address bytes advertised by the BFPT.
2020
*/
21-
if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
21+
if ((bfpt->dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
2222
BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
2323
nor->params->addr_nbytes = 4;
2424

drivers/mtd/spi-nor/macronix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
2222
* seems that the F version advertises support for Fast Read 4-4-4 in
2323
* its BFPT table.
2424
*/
25-
if (bfpt->dwords[BFPT_DWORD(5)] & BFPT_DWORD5_FAST_READ_4_4_4)
25+
if (bfpt->dwords[SFDP_DWORD(5)] & BFPT_DWORD5_FAST_READ_4_4_4)
2626
nor->flags |= SNOR_F_4B_OPCODES;
2727

2828
return 0;

drivers/mtd/spi-nor/sfdp.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -242,64 +242,64 @@ static const struct sfdp_bfpt_read sfdp_bfpt_reads[] = {
242242
/* Fast Read 1-1-2 */
243243
{
244244
SNOR_HWCAPS_READ_1_1_2,
245-
BFPT_DWORD(1), BIT(16), /* Supported bit */
246-
BFPT_DWORD(4), 0, /* Settings */
245+
SFDP_DWORD(1), BIT(16), /* Supported bit */
246+
SFDP_DWORD(4), 0, /* Settings */
247247
SNOR_PROTO_1_1_2,
248248
},
249249

250250
/* Fast Read 1-2-2 */
251251
{
252252
SNOR_HWCAPS_READ_1_2_2,
253-
BFPT_DWORD(1), BIT(20), /* Supported bit */
254-
BFPT_DWORD(4), 16, /* Settings */
253+
SFDP_DWORD(1), BIT(20), /* Supported bit */
254+
SFDP_DWORD(4), 16, /* Settings */
255255
SNOR_PROTO_1_2_2,
256256
},
257257

258258
/* Fast Read 2-2-2 */
259259
{
260260
SNOR_HWCAPS_READ_2_2_2,
261-
BFPT_DWORD(5), BIT(0), /* Supported bit */
262-
BFPT_DWORD(6), 16, /* Settings */
261+
SFDP_DWORD(5), BIT(0), /* Supported bit */
262+
SFDP_DWORD(6), 16, /* Settings */
263263
SNOR_PROTO_2_2_2,
264264
},
265265

266266
/* Fast Read 1-1-4 */
267267
{
268268
SNOR_HWCAPS_READ_1_1_4,
269-
BFPT_DWORD(1), BIT(22), /* Supported bit */
270-
BFPT_DWORD(3), 16, /* Settings */
269+
SFDP_DWORD(1), BIT(22), /* Supported bit */
270+
SFDP_DWORD(3), 16, /* Settings */
271271
SNOR_PROTO_1_1_4,
272272
},
273273

274274
/* Fast Read 1-4-4 */
275275
{
276276
SNOR_HWCAPS_READ_1_4_4,
277-
BFPT_DWORD(1), BIT(21), /* Supported bit */
278-
BFPT_DWORD(3), 0, /* Settings */
277+
SFDP_DWORD(1), BIT(21), /* Supported bit */
278+
SFDP_DWORD(3), 0, /* Settings */
279279
SNOR_PROTO_1_4_4,
280280
},
281281

282282
/* Fast Read 4-4-4 */
283283
{
284284
SNOR_HWCAPS_READ_4_4_4,
285-
BFPT_DWORD(5), BIT(4), /* Supported bit */
286-
BFPT_DWORD(7), 16, /* Settings */
285+
SFDP_DWORD(5), BIT(4), /* Supported bit */
286+
SFDP_DWORD(7), 16, /* Settings */
287287
SNOR_PROTO_4_4_4,
288288
},
289289
};
290290

291291
static const struct sfdp_bfpt_erase sfdp_bfpt_erases[] = {
292292
/* Erase Type 1 in DWORD8 bits[15:0] */
293-
{BFPT_DWORD(8), 0},
293+
{SFDP_DWORD(8), 0},
294294

295295
/* Erase Type 2 in DWORD8 bits[31:16] */
296-
{BFPT_DWORD(8), 16},
296+
{SFDP_DWORD(8), 16},
297297

298298
/* Erase Type 3 in DWORD9 bits[15:0] */
299-
{BFPT_DWORD(9), 0},
299+
{SFDP_DWORD(9), 0},
300300

301301
/* Erase Type 4 in DWORD9 bits[31:16] */
302-
{BFPT_DWORD(9), 16},
302+
{SFDP_DWORD(9), 16},
303303
};
304304

305305
/**
@@ -458,7 +458,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
458458
le32_to_cpu_array(bfpt.dwords, BFPT_DWORD_MAX);
459459

460460
/* Number of address bytes. */
461-
switch (bfpt.dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) {
461+
switch (bfpt.dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) {
462462
case BFPT_DWORD1_ADDRESS_BYTES_3_ONLY:
463463
case BFPT_DWORD1_ADDRESS_BYTES_3_OR_4:
464464
params->addr_nbytes = 3;
@@ -475,7 +475,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
475475
}
476476

477477
/* Flash Memory Density (in bits). */
478-
val = bfpt.dwords[BFPT_DWORD(2)];
478+
val = bfpt.dwords[SFDP_DWORD(2)];
479479
if (val & BIT(31)) {
480480
val &= ~BIT(31);
481481

@@ -555,13 +555,13 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
555555
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
556556

557557
/* Page size: this field specifies 'N' so the page size = 2^N bytes. */
558-
val = bfpt.dwords[BFPT_DWORD(11)];
558+
val = bfpt.dwords[SFDP_DWORD(11)];
559559
val &= BFPT_DWORD11_PAGE_SIZE_MASK;
560560
val >>= BFPT_DWORD11_PAGE_SIZE_SHIFT;
561561
params->page_size = 1U << val;
562562

563563
/* Quad Enable Requirements. */
564-
switch (bfpt.dwords[BFPT_DWORD(15)] & BFPT_DWORD15_QER_MASK) {
564+
switch (bfpt.dwords[SFDP_DWORD(15)] & BFPT_DWORD15_QER_MASK) {
565565
case BFPT_DWORD15_QER_NONE:
566566
params->quad_enable = NULL;
567567
break;
@@ -608,15 +608,15 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
608608
}
609609

610610
/* Soft Reset support. */
611-
if (bfpt.dwords[BFPT_DWORD(16)] & BFPT_DWORD16_SWRST_EN_RST)
611+
if (bfpt.dwords[SFDP_DWORD(16)] & BFPT_DWORD16_SWRST_EN_RST)
612612
nor->flags |= SNOR_F_SOFT_RESET;
613613

614614
/* Stop here if not JESD216 rev C or later. */
615615
if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
616616
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
617617

618618
/* 8D-8D-8D command extension. */
619-
switch (bfpt.dwords[BFPT_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
619+
switch (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
620620
case BFPT_DWORD18_CMD_EXT_REP:
621621
nor->cmd_ext_type = SPI_NOR_EXT_REPEAT;
622622
break;

drivers/mtd/spi-nor/sfdp.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
#define SFDP_JESD216A_MINOR 5
1414
#define SFDP_JESD216B_MINOR 6
1515

16+
/* SFDP DWORDS are indexed from 1 but C arrays are indexed from 0. */
17+
#define SFDP_DWORD(i) ((i) - 1)
18+
1619
/* Basic Flash Parameter Table */
1720

18-
/*
19-
* JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs.
20-
* They are indexed from 1 but C arrays are indexed from 0.
21-
*/
22-
#define BFPT_DWORD(i) ((i) - 1)
21+
/* JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs. */
2322
#define BFPT_DWORD_MAX 20
2423

2524
struct sfdp_bfpt {

0 commit comments

Comments
 (0)