Skip to content

Commit 653f6de

Browse files
Kuwano-sanprati0100
authored andcommitted
mtd: spi-nor: sfdp: introduce smpt_read_dummy fixup hook
SMPT contains config detection info that describes opcode, address, and dummy cycles to read sector map config. The dummy cycles parameter can be SMPT_CMD_READ_DUMMY_IS_VARIABLE and in that case nor->read_dummy (initialized as 0) is used. In Infineon flash chips, Read Any Register command with variable dummy cycle is defined in SMPT. S25Hx/S28Hx flash has 0 dummy cycle by default to read volatile regiters and nor->read_dummy can work. S25FS-S flash has 8 dummy cycles so we need a hook that can fix dummy cycles with actually used value. Inroduce smpt_read_dummy() in struct spi_nor_fixups. It is called when the dummy cycle field in SMPT config detection is 'varialble'. 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> Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
1 parent 604cf6a commit 653f6de

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

drivers/mtd/spi-nor/core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ struct spi_nor_flash_parameter {
409409
* flash parameters when information provided by the flash_info
410410
* table is incomplete or wrong.
411411
* @post_bfpt: called after the BFPT table has been parsed
412+
* @smpt_read_dummy: called during SMPT table is being parsed. Used to fix the
413+
* number of dummy cycles in read register ops.
412414
* @post_sfdp: called after SFDP has been parsed (is also called for SPI NORs
413415
* that do not support RDSFDP). Typically used to tweak various
414416
* parameters that could not be extracted by other means (i.e.
@@ -426,6 +428,7 @@ struct spi_nor_fixups {
426428
int (*post_bfpt)(struct spi_nor *nor,
427429
const struct sfdp_parameter_header *bfpt_header,
428430
const struct sfdp_bfpt *bfpt);
431+
void (*smpt_read_dummy)(const struct spi_nor *nor, u8 *read_dummy);
429432
int (*post_sfdp)(struct spi_nor *nor);
430433
int (*late_init)(struct spi_nor *nor);
431434
};

drivers/mtd/spi-nor/sfdp.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,17 @@ static u8 spi_nor_smpt_addr_nbytes(const struct spi_nor *nor, const u32 settings
699699
}
700700
}
701701

702+
static void spi_nor_smpt_read_dummy_fixups(const struct spi_nor *nor,
703+
u8 *read_dummy)
704+
{
705+
if (nor->manufacturer && nor->manufacturer->fixups &&
706+
nor->manufacturer->fixups->smpt_read_dummy)
707+
nor->manufacturer->fixups->smpt_read_dummy(nor, read_dummy);
708+
709+
if (nor->info->fixups && nor->info->fixups->smpt_read_dummy)
710+
nor->info->fixups->smpt_read_dummy(nor, read_dummy);
711+
}
712+
702713
/**
703714
* spi_nor_smpt_read_dummy() - return the configuration detection command read
704715
* latency, in clock cycles.
@@ -711,8 +722,11 @@ static u8 spi_nor_smpt_read_dummy(const struct spi_nor *nor, const u32 settings)
711722
{
712723
u8 read_dummy = SMPT_CMD_READ_DUMMY(settings);
713724

714-
if (read_dummy == SMPT_CMD_READ_DUMMY_IS_VARIABLE)
715-
return nor->read_dummy;
725+
if (read_dummy == SMPT_CMD_READ_DUMMY_IS_VARIABLE) {
726+
read_dummy = nor->read_dummy;
727+
spi_nor_smpt_read_dummy_fixups(nor, &read_dummy);
728+
}
729+
716730
return read_dummy;
717731
}
718732

0 commit comments

Comments
 (0)