Skip to content

Commit 301e85f

Browse files
Kuwano-sangregkh
authored andcommitted
mtd: spi-nor: sfdp: introduce smpt_map_id fixup hook
[ Upstream commit f74de39 ] Certain chips have inconsistent Sector Map Parameter Table (SMPT) data, which leads to the wrong map ID being identified, causing failures to detect the correct sector map. To fix this, introduce smpt_map_id() into the struct spi_nor_fixups. This function will be called after the initial SMPT-based detection, allowing chip-specific logic to correct the map ID. Infineon S25FS512S needs this fixup as it has inconsistency between map ID definition and configuration register value actually obtained. Co-developed-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org> Tested-by: Marek Vasut <marek.vasut+renesas@mailbox.org> # S25FS512S Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>> Signed-off-by: Pratyush Yadav <pratyush@kernel.org> Stable-dep-of: 3620d67 ("mtd: spi-nor: update spi_nor_fixups::post_sfdp() documentation") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2e472d2 commit 301e85f

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/mtd/spi-nor/core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ struct spi_nor_flash_parameter {
418418
* @post_bfpt: called after the BFPT table has been parsed
419419
* @smpt_read_dummy: called during SMPT table is being parsed. Used to fix the
420420
* number of dummy cycles in read register ops.
421+
* @smpt_map_id: called after map ID in SMPT table has been determined for the
422+
* case the map ID is wrong and needs to be fixed.
421423
* @post_sfdp: called after SFDP has been parsed (is also called for SPI NORs
422424
* that do not support RDSFDP). Typically used to tweak various
423425
* parameters that could not be extracted by other means (i.e.
@@ -436,6 +438,7 @@ struct spi_nor_fixups {
436438
const struct sfdp_parameter_header *bfpt_header,
437439
const struct sfdp_bfpt *bfpt);
438440
void (*smpt_read_dummy)(const struct spi_nor *nor, u8 *read_dummy);
441+
void (*smpt_map_id)(const struct spi_nor *nor, u8 *map_id);
439442
int (*post_sfdp)(struct spi_nor *nor);
440443
int (*late_init)(struct spi_nor *nor);
441444
};

drivers/mtd/spi-nor/sfdp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,16 @@ static u8 spi_nor_smpt_read_dummy(const struct spi_nor *nor, const u32 settings)
705705
return read_dummy;
706706
}
707707

708+
static void spi_nor_smpt_map_id_fixups(const struct spi_nor *nor, u8 *map_id)
709+
{
710+
if (nor->manufacturer && nor->manufacturer->fixups &&
711+
nor->manufacturer->fixups->smpt_map_id)
712+
nor->manufacturer->fixups->smpt_map_id(nor, map_id);
713+
714+
if (nor->info->fixups && nor->info->fixups->smpt_map_id)
715+
nor->info->fixups->smpt_map_id(nor, map_id);
716+
}
717+
708718
/**
709719
* spi_nor_get_map_in_use() - get the configuration map in use
710720
* @nor: pointer to a 'struct spi_nor'
@@ -758,6 +768,8 @@ static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt,
758768
map_id = map_id << 1 | !!(*buf & read_data_mask);
759769
}
760770

771+
spi_nor_smpt_map_id_fixups(nor, &map_id);
772+
761773
/*
762774
* If command descriptors are provided, they always precede map
763775
* descriptors in the table. There is no need to start the iteration

0 commit comments

Comments
 (0)