Skip to content

Commit 3ea3f0a

Browse files
mwalleambarus
authored andcommitted
mtd: spi-nor: drop .parse_sfdp
Drop the size parameter to indicate we need to do SFDP, we can do that because it is guaranteed that the size will be set by SFDP and because PARSE_SFDP forced the SFDP parsing it must be overwritten. There is a (very tiny) chance that this might break block protection support: we now rely on the SFDP reported size of the flash for the BP calculation. OTOH, if the flash reports its size wrong, we are in bigger trouble than just having the BP calculation wrong. Signed-off-by: Michael Walle <mwalle@kernel.org> Link: https://lore.kernel.org/r/20230807-mtd-flash-info-db-rework-v3-11-e60548861b10@kernel.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent 6dec24b commit 3ea3f0a

9 files changed

Lines changed: 22 additions & 36 deletions

File tree

drivers/mtd/spi-nor/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,6 @@ static const struct spi_nor_manufacturer *manufacturers[] = {
20172017

20182018
static const struct flash_info spi_nor_generic_flash = {
20192019
.name = "spi-nor-generic",
2020-
.parse_sfdp = true,
20212020
};
20222021

20232022
static const struct flash_info *spi_nor_match_id(struct spi_nor *nor,
@@ -3069,7 +3068,7 @@ static int spi_nor_init_params(struct spi_nor *nor)
30693068

30703069
spi_nor_init_default_params(nor);
30713070

3072-
if (nor->info->parse_sfdp) {
3071+
if (spi_nor_needs_sfdp(nor)) {
30733072
ret = spi_nor_parse_sfdp(nor);
30743073
if (ret) {
30753074
dev_err(nor->dev, "BFPT parsing failed. Please consider using SPI_NOR_SKIP_SFDP when declaring the flash\n");

drivers/mtd/spi-nor/core.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,6 @@ struct spi_nor_fixups {
460460
* @page_size: (optional) the flash's page size. Defaults to 256.
461461
* @addr_nbytes: number of address bytes to send.
462462
*
463-
* @parse_sfdp: true when flash supports SFDP tables. The false value has no
464-
* meaning. If one wants to skip the SFDP tables, one should
465-
* instead use the SPI_NOR_SKIP_SFDP sfdp_flag.
466463
* @flags: flags that indicate support that is not defined by the
467464
* JESD216 standard in its SFDP tables. Flag meanings:
468465
* SPI_NOR_HAS_LOCK: flash supports lock/unlock via SR
@@ -521,7 +518,6 @@ struct flash_info {
521518
u8 n_banks;
522519
u8 addr_nbytes;
523520

524-
bool parse_sfdp;
525521
u16 flags;
526522
#define SPI_NOR_HAS_LOCK BIT(0)
527523
#define SPI_NOR_HAS_TB BIT(1)
@@ -598,9 +594,6 @@ struct flash_info {
598594
.n_regions = (_n_regions), \
599595
},
600596

601-
#define PARSE_SFDP \
602-
.parse_sfdp = true, \
603-
604597
#define FLAGS(_flags) \
605598
.flags = (_flags), \
606599

@@ -740,6 +733,22 @@ static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd)
740733
return container_of(mtd, struct spi_nor, mtd);
741734
}
742735

736+
/**
737+
* spi_nor_needs_sfdp() - returns true if SFDP parsing is used for this flash.
738+
*
739+
* Return: true if SFDP parsing is needed
740+
*/
741+
static inline bool spi_nor_needs_sfdp(const struct spi_nor *nor)
742+
{
743+
/*
744+
* The flash size is one property parsed by the SFDP. We use it as an
745+
* indicator whether we need SFDP parsing for a particular flash. I.e.
746+
* non-legacy flash entries in flash_info will have a size of zero iff
747+
* SFDP should be used.
748+
*/
749+
return !nor->info->size;
750+
}
751+
743752
#ifdef CONFIG_DEBUG_FS
744753
void spi_nor_debugfs_register(struct spi_nor *nor);
745754
void spi_nor_debugfs_shutdown(void);

drivers/mtd/spi-nor/eon.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ static const struct flash_info eon_nor_parts[] = {
2525
{ "en25qh64", INFO(0x1c7017, 0, 64 * 1024, 128)
2626
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
2727
{ "en25qh128", INFO(0x1c7018, 0, 64 * 1024, 256) },
28-
{ "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512)
29-
PARSE_SFDP },
28+
{ "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 0) },
3029
{ "en25s64", INFO(0x1c3817, 0, 64 * 1024, 128)
3130
NO_SFDP_FLAGS(SECT_4K) },
3231
};

drivers/mtd/spi-nor/gigadevice.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ static const struct flash_info gigadevice_nor_parts[] = {
6262
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
6363
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
6464
SPI_NOR_QUAD_READ) },
65-
{ "gd25q256", INFO(0xc84019, 0, 64 * 1024, 512)
66-
PARSE_SFDP
65+
{ "gd25q256", INFO(0xc84019, 0, 64 * 1024, 0)
6766
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6)
6867
FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
6968
.fixups = &gd25q256_fixups },

drivers/mtd/spi-nor/issi.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ static const struct flash_info issi_nor_parts[] = {
6262
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
6363
{ "is25lp128", INFO(0x9d6018, 0, 64 * 1024, 256)
6464
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
65-
{ "is25lp256", INFO(0x9d6019, 0, 64 * 1024, 512)
66-
PARSE_SFDP
65+
{ "is25lp256", INFO(0x9d6019, 0, 64 * 1024, 0)
6766
FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
6867
.fixups = &is25lp256_fixups },
6968
{ "is25wp032", INFO(0x9d7016, 0, 64 * 1024, 64)
@@ -73,7 +72,6 @@ static const struct flash_info issi_nor_parts[] = {
7372
{ "is25wp128", INFO(0x9d7018, 0, 64 * 1024, 256)
7473
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
7574
{ "is25wp256", INFO(0x9d7019, 0, 0, 0)
76-
PARSE_SFDP
7775
FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
7876
FLAGS(SPI_NOR_QUAD_PP)
7977
.fixups = &is25lp256_fixups },

drivers/mtd/spi-nor/macronix.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ static const struct flash_info macronix_nor_parts[] = {
8383
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
8484
FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
8585
{ "mx25uw51245g", INFOB(0xc2813a, 0, 0, 0, 4)
86-
PARSE_SFDP
8786
FLAGS(SPI_NOR_RWW) },
8887
{ "mx25v8035f", INFO(0xc22314, 0, 64 * 1024, 16)
8988
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |

drivers/mtd/spi-nor/spansion.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -849,59 +849,47 @@ static const struct flash_info spansion_nor_parts[] = {
849849
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
850850
FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
851851
{ "s25fs256t", INFO6(0x342b19, 0x0f0890, 0, 0)
852-
PARSE_SFDP
853852
MFR_FLAGS(USE_CLPEF)
854853
.fixups = &s25fs256t_fixups },
855854
{ "s25hl512t", INFO6(0x342a1a, 0x0f0390, 0, 0)
856-
PARSE_SFDP
857855
MFR_FLAGS(USE_CLPEF)
858856
.fixups = &s25hx_t_fixups },
859857
{ "s25hl01gt", INFO6(0x342a1b, 0x0f0390, 0, 0)
860-
PARSE_SFDP
861858
MFR_FLAGS(USE_CLPEF)
862859
.fixups = &s25hx_t_fixups },
863860
{ "s25hl02gt", INFO6(0x342a1c, 0x0f0090, 0, 0)
864-
PARSE_SFDP
865861
MFR_FLAGS(USE_CLPEF)
866862
FLAGS(NO_CHIP_ERASE)
867863
.fixups = &s25hx_t_fixups },
868864
{ "s25hs512t", INFO6(0x342b1a, 0x0f0390, 0, 0)
869-
PARSE_SFDP
870865
MFR_FLAGS(USE_CLPEF)
871866
.fixups = &s25hx_t_fixups },
872867
{ "s25hs01gt", INFO6(0x342b1b, 0x0f0390, 0, 0)
873-
PARSE_SFDP
874868
MFR_FLAGS(USE_CLPEF)
875869
.fixups = &s25hx_t_fixups },
876870
{ "s25hs02gt", INFO6(0x342b1c, 0x0f0090, 0, 0)
877-
PARSE_SFDP
878871
MFR_FLAGS(USE_CLPEF)
879872
FLAGS(NO_CHIP_ERASE)
880873
.fixups = &s25hx_t_fixups },
881874
{ "cy15x104q", INFO6(0x042cc2, 0x7f7f7f, 512 * 1024, 1)
882875
FLAGS(SPI_NOR_NO_ERASE) },
883876
{ "s28hl512t", INFO(0x345a1a, 0, 0, 0)
884-
PARSE_SFDP
885877
MFR_FLAGS(USE_CLPEF)
886878
.fixups = &s28hx_t_fixups,
887879
},
888880
{ "s28hl01gt", INFO(0x345a1b, 0, 0, 0)
889-
PARSE_SFDP
890881
MFR_FLAGS(USE_CLPEF)
891882
.fixups = &s28hx_t_fixups,
892883
},
893884
{ "s28hs512t", INFO(0x345b1a, 0, 0, 0)
894-
PARSE_SFDP
895885
MFR_FLAGS(USE_CLPEF)
896886
.fixups = &s28hx_t_fixups,
897887
},
898888
{ "s28hs01gt", INFO(0x345b1b, 0, 0, 0)
899-
PARSE_SFDP
900889
MFR_FLAGS(USE_CLPEF)
901890
.fixups = &s28hx_t_fixups,
902891
},
903892
{ "s28hs02gt", INFO(0x345b1c, 0, 0, 0)
904-
PARSE_SFDP
905893
MFR_FLAGS(USE_CLPEF)
906894
.fixups = &s28hx_t_fixups,
907895
},

drivers/mtd/spi-nor/sst.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ static const struct flash_info sst_nor_parts[] = {
115115
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
116116
{ "sst26vf032b", INFO(0xbf2642, 0, 0, 0)
117117
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
118-
PARSE_SFDP
119118
.fixups = &sst26vf_nor_fixups },
120119
{ "sst26vf064b", INFO(0xbf2643, 0, 64 * 1024, 128)
121120
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)

drivers/mtd/spi-nor/winbond.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,20 @@ static const struct flash_info winbond_nor_parts[] = {
121121
{ "w25q80bl", INFO(0xef4014, 0, 64 * 1024, 16)
122122
NO_SFDP_FLAGS(SECT_4K) },
123123
{ "w25q128", INFO(0xef4018, 0, 0, 0)
124-
PARSE_SFDP
125124
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) },
126125
{ "w25q256", INFO(0xef4019, 0, 64 * 1024, 512)
127126
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
128127
.fixups = &w25q256_fixups },
129-
{ "w25q256jvm", INFO(0xef7019, 0, 64 * 1024, 512)
130-
PARSE_SFDP },
128+
{ "w25q256jvm", INFO(0xef7019, 0, 64 * 1024, 0) },
131129
{ "w25q256jw", INFO(0xef6019, 0, 64 * 1024, 512)
132130
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
133131
SPI_NOR_QUAD_READ) },
134132
{ "w25m512jv", INFO(0xef7119, 0, 64 * 1024, 1024)
135133
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ |
136134
SPI_NOR_DUAL_READ) },
137135
{ "w25q512nwq", INFO(0xef6020, 0, 0, 0)
138-
PARSE_SFDP
139136
OTP_INFO(256, 3, 0x1000, 0x1000) },
140-
{ "w25q512nwm", INFO(0xef8020, 0, 64 * 1024, 1024)
141-
PARSE_SFDP
137+
{ "w25q512nwm", INFO(0xef8020, 0, 64 * 1024, 0)
142138
OTP_INFO(256, 3, 0x1000, 0x1000) },
143139
{ "w25q512jvq", INFO(0xef4020, 0, 64 * 1024, 1024)
144140
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |

0 commit comments

Comments
 (0)