Unverified Commit 3ea3f0ac authored by Michael Walle's avatar Michael Walle Committed by Tudor Ambarus
Browse files

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: default avatarMichael Walle <mwalle@kernel.org>
Link: https://lore.kernel.org/r/20230807-mtd-flash-info-db-rework-v3-11-e60548861b10@kernel.org


Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
parent 6dec24b1
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2017,7 +2017,6 @@ static const struct spi_nor_manufacturer *manufacturers[] = {

static const struct flash_info spi_nor_generic_flash = {
	.name = "spi-nor-generic",
	.parse_sfdp = true,
};

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)

	spi_nor_init_default_params(nor);

	if (nor->info->parse_sfdp) {
	if (spi_nor_needs_sfdp(nor)) {
		ret = spi_nor_parse_sfdp(nor);
		if (ret) {
			dev_err(nor->dev, "BFPT parsing failed. Please consider using SPI_NOR_SKIP_SFDP when declaring the flash\n");
+16 −7
Original line number Diff line number Diff line
@@ -460,9 +460,6 @@ struct spi_nor_fixups {
 * @page_size:      (optional) the flash's page size. Defaults to 256.
 * @addr_nbytes:    number of address bytes to send.
 *
 * @parse_sfdp:     true when flash supports SFDP tables. The false value has no
 *                  meaning. If one wants to skip the SFDP tables, one should
 *                  instead use the SPI_NOR_SKIP_SFDP sfdp_flag.
 * @flags:          flags that indicate support that is not defined by the
 *                  JESD216 standard in its SFDP tables. Flag meanings:
 *   SPI_NOR_HAS_LOCK:        flash supports lock/unlock via SR
@@ -521,7 +518,6 @@ struct flash_info {
	u8 n_banks;
	u8 addr_nbytes;

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

#define PARSE_SFDP							\
	.parse_sfdp = true,						\

#define FLAGS(_flags)							\
		.flags = (_flags),					\

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

/**
 * spi_nor_needs_sfdp() - returns true if SFDP parsing is used for this flash.
 *
 * Return: true if SFDP parsing is needed
 */
static inline bool spi_nor_needs_sfdp(const struct spi_nor *nor)
{
	/*
	 * The flash size is one property parsed by the SFDP. We use it as an
	 * indicator whether we need SFDP parsing for a particular flash. I.e.
	 * non-legacy flash entries in flash_info will have a size of zero iff
	 * SFDP should be used.
	 */
	return !nor->info->size;
}

#ifdef CONFIG_DEBUG_FS
void spi_nor_debugfs_register(struct spi_nor *nor);
void spi_nor_debugfs_shutdown(void);
+1 −2
Original line number Diff line number Diff line
@@ -25,8 +25,7 @@ static const struct flash_info eon_nor_parts[] = {
	{ "en25qh64",   INFO(0x1c7017, 0, 64 * 1024,  128)
		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
	{ "en25qh128",  INFO(0x1c7018, 0, 64 * 1024,  256) },
	{ "en25qh256",  INFO(0x1c7019, 0, 64 * 1024,  512)
		PARSE_SFDP },
	{ "en25qh256",  INFO(0x1c7019, 0, 64 * 1024,  0) },
	{ "en25s64",	INFO(0x1c3817, 0, 64 * 1024,  128)
		NO_SFDP_FLAGS(SECT_4K) },
};
+1 −2
Original line number Diff line number Diff line
@@ -62,8 +62,7 @@ static const struct flash_info gigadevice_nor_parts[] = {
		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
			      SPI_NOR_QUAD_READ) },
	{ "gd25q256", INFO(0xc84019, 0, 64 * 1024, 512)
		PARSE_SFDP
	{ "gd25q256", INFO(0xc84019, 0, 64 * 1024, 0)
		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6)
		FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
		.fixups = &gd25q256_fixups },
+1 −3
Original line number Diff line number Diff line
@@ -62,8 +62,7 @@ static const struct flash_info issi_nor_parts[] = {
		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
	{ "is25lp128",  INFO(0x9d6018, 0, 64 * 1024, 256)
		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
	{ "is25lp256",  INFO(0x9d6019, 0, 64 * 1024, 512)
		PARSE_SFDP
	{ "is25lp256",  INFO(0x9d6019, 0, 64 * 1024, 0)
		FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
		.fixups = &is25lp256_fixups },
	{ "is25wp032",  INFO(0x9d7016, 0, 64 * 1024,  64)
@@ -73,7 +72,6 @@ static const struct flash_info issi_nor_parts[] = {
	{ "is25wp128",  INFO(0x9d7018, 0, 64 * 1024, 256)
		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
	{ "is25wp256", INFO(0x9d7019, 0, 0, 0)
		PARSE_SFDP
		FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
		FLAGS(SPI_NOR_QUAD_PP)
		.fixups = &is25lp256_fixups },
Loading