From: Tudor Ambarus <tudor.ambarus@microchip.com> To: <michael@walle.cc>, <vigneshr@ti.com>, <p.yadav@ti.com> Cc: macromorgan@hotmail.com, jaimeliao@mxic.com.tw, Tudor Ambarus <tudor.ambarus@microchip.com>, richard@nod.at, esben@geanix.com, linux@rasmusvillemoes.dk, knaerzche@gmail.com, nicolas.ferre@microchip.com, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, code@reto-schneider.ch, miquel.raynal@bootlin.com, heiko.thiery@gmail.com, sr@denx.de, mail@david-bauer.net, zhengxunli@mxic.com.tw Subject: [PATCH v3 18/25] mtd: spi-nor: core: Init flash params based on SFDP first for new flash additions Date: Fri, 29 Oct 2021 20:26:26 +0300 [thread overview] Message-ID: <20211029172633.886453-19-tudor.ambarus@microchip.com> (raw) In-Reply-To: <20211029172633.886453-1-tudor.ambarus@microchip.com> New flash additions that support SFDP should be declared with SPI_NOR_PARSE_SFDP and with all the other flags that are not SFDP discoverable. Keep the old way of initializing the flash, until all the flashes are converted to use either SPI_NOR_PARSE_SFDP or SPI_NOR_SKIP_SFDP. Since we want to get rid of the default_init() hook, the rollback mechanism for flashes that use SPI_NOR_PARSE_SFDP does not call spi_nor_manufacturer_init_params(). Split spi_nor_info_init_params() in spi_nor_init_default_params() and spi_nor_skip_sfdp_init_params(). spi_nor_init_default_params() is called for all the flashes regardless if they support SFDP or not. spi_nor_skip_sfdp_init_params() is called just for the flashes that do not define SFDP and initializes parameters and setting solely based on flash_info data. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> --- drivers/mtd/spi-nor/core.c | 187 +++++++++++++++++++++---------------- 1 file changed, 105 insertions(+), 82 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 40d98ae300ca..c509f257a6c3 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2493,6 +2493,56 @@ static int spi_nor_setup(struct spi_nor *nor, return nor->params->setup(nor, hwcaps); } +/** + * spi_nor_init_default_params() - Default initialization of flash parameters + * and settings. Done for all flashes, regardless is they define SFDP tables + * or not. + * @nor: pointer to a 'struct spi_nor'. + */ +static void spi_nor_init_default_params(struct spi_nor *nor) +{ + struct spi_nor_flash_parameter *params = nor->params; + const struct flash_info *info = nor->info; + struct device_node *np = spi_nor_get_flash_node(nor); + + params->quad_enable = spi_nor_sr2_bit1_quad_enable; + params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; + params->setup = spi_nor_default_setup; + params->otp.org = &info->otp_org; + + /* Default to 16-bit Write Status (01h) Command */ + nor->flags |= SNOR_F_HAS_16BIT_SR; + + /* Set SPI NOR sizes. */ + params->writesize = 1; + params->size = (u64)info->sector_size * info->n_sectors; + params->page_size = info->page_size; + + if (!(info->flags & SPI_NOR_NO_FR)) { + /* Default to Fast Read for DT and non-DT platform devices. */ + params->hwcaps.mask |= SNOR_HWCAPS_READ_FAST; + + /* Mask out Fast Read if not requested at DT instantiation. */ + if (np && !of_property_read_bool(np, "m25p,fast-read")) + params->hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST; + } + + /* (Fast) Read settings. */ + params->hwcaps.mask |= SNOR_HWCAPS_READ; + spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ], + 0, 0, SPINOR_OP_READ, + SNOR_PROTO_1_1_1); + + if (params->hwcaps.mask & SNOR_HWCAPS_READ_FAST) + spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_FAST], + 0, 8, SPINOR_OP_READ_FAST, + SNOR_PROTO_1_1_1); + /* Page Program settings. */ + params->hwcaps.mask |= SNOR_HWCAPS_PP; + spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP], + SPINOR_OP_PP, SNOR_PROTO_1_1_1); +} + /** * spi_nor_manufacturer_init_params() - Initialize the flash's parameters and * settings based on MFR register and ->default_init() hook. @@ -2528,109 +2578,46 @@ static void spi_nor_post_sfdp_fixups(struct spi_nor *nor) } /** - * spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings - * based on JESD216 SFDP standard. - * @nor: pointer to a 'struct spi_nor'. - * - * The method has a roll-back mechanism: in case the SFDP parsing fails, the - * legacy flash parameters and settings will be restored. - */ -static void spi_nor_sfdp_init_params(struct spi_nor *nor) -{ - struct spi_nor_flash_parameter sfdp_params; - - memcpy(&sfdp_params, nor->params, sizeof(sfdp_params)); - - if (!spi_nor_parse_sfdp(nor)) { - spi_nor_post_sfdp_fixups(nor); - } else { - memcpy(nor->params, &sfdp_params, sizeof(*nor->params)); - nor->addr_width = 0; - nor->flags &= ~SNOR_F_4B_OPCODES; - } -} - -/** - * spi_nor_info_init_params() - Initialize the flash's parameters and settings - * based on nor->info data. + * spi_nor_skip_sfdp_init_params() - Initialize the flash's parameters and + * settings based on nor->info data. * @nor: pointer to a 'struct spi_nor'. */ -static void spi_nor_info_init_params(struct spi_nor *nor) +static void spi_nor_skip_sfdp_init_params(struct spi_nor *nor) { struct spi_nor_flash_parameter *params = nor->params; struct spi_nor_erase_map *map = ¶ms->erase_map; - const struct flash_info *info = nor->info; - struct device_node *np = spi_nor_get_flash_node(nor); + const u32 info_flags = nor->info->flags & SFDP_FLAGS_MASK; u8 i, erase_mask; - /* Initialize default flash parameters and settings. */ - params->quad_enable = spi_nor_sr2_bit1_quad_enable; - params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; - params->setup = spi_nor_default_setup; - params->otp.org = &info->otp_org; - - /* Default to 16-bit Write Status (01h) Command */ - nor->flags |= SNOR_F_HAS_16BIT_SR; - - /* Set SPI NOR sizes. */ - params->writesize = 1; - params->size = (u64)info->sector_size * info->n_sectors; - params->page_size = info->page_size; - - if (!(info->flags & SPI_NOR_NO_FR)) { - /* Default to Fast Read for DT and non-DT platform devices. */ - params->hwcaps.mask |= SNOR_HWCAPS_READ_FAST; - - /* Mask out Fast Read if not requested at DT instantiation. */ - if (np && !of_property_read_bool(np, "m25p,fast-read")) - params->hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST; - } - - /* (Fast) Read settings. */ - params->hwcaps.mask |= SNOR_HWCAPS_READ; - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ], - 0, 0, SPINOR_OP_READ, - SNOR_PROTO_1_1_1); - - if (params->hwcaps.mask & SNOR_HWCAPS_READ_FAST) - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_FAST], - 0, 8, SPINOR_OP_READ_FAST, - SNOR_PROTO_1_1_1); - - if (info->flags & SPI_NOR_DUAL_READ) { + if (info_flags & SPI_NOR_DUAL_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_2; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_2], 0, 8, SPINOR_OP_READ_1_1_2, SNOR_PROTO_1_1_2); } - if (info->flags & SPI_NOR_QUAD_READ) { + if (info_flags & SPI_NOR_QUAD_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_4], 0, 8, SPINOR_OP_READ_1_1_4, SNOR_PROTO_1_1_4); } - if (info->flags & SPI_NOR_OCTAL_READ) { + if (info_flags & SPI_NOR_OCTAL_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_8], 0, 8, SPINOR_OP_READ_1_1_8, SNOR_PROTO_1_1_8); } - if (info->flags & SPI_NOR_OCTAL_DTR_READ) { + if (info_flags & SPI_NOR_OCTAL_DTR_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_8_8_8_DTR; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_8_8_8_DTR], 0, 20, SPINOR_OP_READ_FAST, SNOR_PROTO_8_8_8_DTR); } - /* Page Program settings. */ - params->hwcaps.mask |= SNOR_HWCAPS_PP; - spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP], - SPINOR_OP_PP, SNOR_PROTO_1_1_1); - - if (info->flags & SPI_NOR_OCTAL_DTR_PP) { + if (info_flags & SPI_NOR_OCTAL_DTR_PP) { params->hwcaps.mask |= SNOR_HWCAPS_PP_8_8_8_DTR; /* * Since xSPI Page Program opcode is backward compatible with @@ -2646,23 +2633,49 @@ static void spi_nor_info_init_params(struct spi_nor *nor) */ erase_mask = 0; i = 0; - if (info->flags & SECT_4K_PMC) { + if (info_flags & SECT_4K_PMC) { erase_mask |= BIT(i); spi_nor_set_erase_type(&map->erase_type[i], 4096u, SPINOR_OP_BE_4K_PMC); i++; - } else if (info->flags & SECT_4K) { + } else if (info_flags & SECT_4K) { erase_mask |= BIT(i); spi_nor_set_erase_type(&map->erase_type[i], 4096u, SPINOR_OP_BE_4K); i++; } erase_mask |= BIT(i); - spi_nor_set_erase_type(&map->erase_type[i], info->sector_size, + spi_nor_set_erase_type(&map->erase_type[i], nor->info->sector_size, SPINOR_OP_SE); spi_nor_init_uniform_erase_map(map, erase_mask, params->size); } +/** + * spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings + * based on JESD216 SFDP standard. + * @nor: pointer to a 'struct spi_nor'. + * + * The method has a roll-back mechanism: in case the SFDP parsing fails, the + * legacy flash parameters and settings will be restored. + */ +static void spi_nor_sfdp_init_params(struct spi_nor *nor) +{ + struct spi_nor_flash_parameter sfdp_params; + + memcpy(&sfdp_params, nor->params, sizeof(sfdp_params)); + + if (!spi_nor_parse_sfdp(nor)) { + spi_nor_post_sfdp_fixups(nor); + } else { + memcpy(nor->params, &sfdp_params, sizeof(*nor->params)); + nor->addr_width = 0; + nor->flags &= ~SNOR_F_4B_OPCODES; + + if (nor->info->flags & SPI_NOR_PARSE_SFDP) + spi_nor_skip_sfdp_init_params(nor); + } +} + /** * spi_nor_nonsfdp_init_flags() - Initialize NOR flags for settings that are not * defined in the JESD216 SFDP standard, thus can not be retrieved when parsing @@ -2760,6 +2773,19 @@ static void spi_nor_late_init_params(struct spi_nor *nor) spi_nor_init_default_locking_ops(nor); } +static void spi_nor_init_params_deprecated(struct spi_nor *nor) +{ + spi_nor_skip_sfdp_init_params(nor); + + spi_nor_manufacturer_init_params(nor); + + if ((nor->info->flags & (SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | + SPI_NOR_OCTAL_READ | + SPI_NOR_OCTAL_DTR_READ)) && + !(nor->info->flags & SPI_NOR_SKIP_SFDP)) + spi_nor_sfdp_init_params(nor); +} + /** * spi_nor_init_params() - Initialize the flash's parameters and settings. * @nor: pointer to a 'struct spi_nor'. @@ -2801,15 +2827,12 @@ static int spi_nor_init_params(struct spi_nor *nor) if (!nor->params) return -ENOMEM; - spi_nor_info_init_params(nor); + spi_nor_init_default_params(nor); - spi_nor_manufacturer_init_params(nor); - - if ((nor->info->flags & (SPI_NOR_PARSE_SFDP | - SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | - SPI_NOR_OCTAL_READ | SPI_NOR_OCTAL_DTR_READ)) && - !(nor->info->flags & SPI_NOR_SKIP_SFDP)) + if (nor->info->flags & SPI_NOR_PARSE_SFDP) spi_nor_sfdp_init_params(nor); + else + spi_nor_init_params_deprecated(nor); spi_nor_late_init_params(nor); -- 2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Tudor Ambarus <tudor.ambarus@microchip.com> To: <michael@walle.cc>, <vigneshr@ti.com>, <p.yadav@ti.com> Cc: macromorgan@hotmail.com, jaimeliao@mxic.com.tw, Tudor Ambarus <tudor.ambarus@microchip.com>, richard@nod.at, esben@geanix.com, linux@rasmusvillemoes.dk, knaerzche@gmail.com, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, code@reto-schneider.ch, miquel.raynal@bootlin.com, heiko.thiery@gmail.com, sr@denx.de, figgyc@figgyc.uk, mail@david-bauer.net, zhengxunli@mxic.com.tw Subject: [PATCH v3 18/25] mtd: spi-nor: core: Init flash params based on SFDP first for new flash additions Date: Fri, 29 Oct 2021 20:26:26 +0300 [thread overview] Message-ID: <20211029172633.886453-19-tudor.ambarus@microchip.com> (raw) In-Reply-To: <20211029172633.886453-1-tudor.ambarus@microchip.com> New flash additions that support SFDP should be declared with SPI_NOR_PARSE_SFDP and with all the other flags that are not SFDP discoverable. Keep the old way of initializing the flash, until all the flashes are converted to use either SPI_NOR_PARSE_SFDP or SPI_NOR_SKIP_SFDP. Since we want to get rid of the default_init() hook, the rollback mechanism for flashes that use SPI_NOR_PARSE_SFDP does not call spi_nor_manufacturer_init_params(). Split spi_nor_info_init_params() in spi_nor_init_default_params() and spi_nor_skip_sfdp_init_params(). spi_nor_init_default_params() is called for all the flashes regardless if they support SFDP or not. spi_nor_skip_sfdp_init_params() is called just for the flashes that do not define SFDP and initializes parameters and setting solely based on flash_info data. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> --- drivers/mtd/spi-nor/core.c | 187 +++++++++++++++++++++---------------- 1 file changed, 105 insertions(+), 82 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 40d98ae300ca..c509f257a6c3 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2493,6 +2493,56 @@ static int spi_nor_setup(struct spi_nor *nor, return nor->params->setup(nor, hwcaps); } +/** + * spi_nor_init_default_params() - Default initialization of flash parameters + * and settings. Done for all flashes, regardless is they define SFDP tables + * or not. + * @nor: pointer to a 'struct spi_nor'. + */ +static void spi_nor_init_default_params(struct spi_nor *nor) +{ + struct spi_nor_flash_parameter *params = nor->params; + const struct flash_info *info = nor->info; + struct device_node *np = spi_nor_get_flash_node(nor); + + params->quad_enable = spi_nor_sr2_bit1_quad_enable; + params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; + params->setup = spi_nor_default_setup; + params->otp.org = &info->otp_org; + + /* Default to 16-bit Write Status (01h) Command */ + nor->flags |= SNOR_F_HAS_16BIT_SR; + + /* Set SPI NOR sizes. */ + params->writesize = 1; + params->size = (u64)info->sector_size * info->n_sectors; + params->page_size = info->page_size; + + if (!(info->flags & SPI_NOR_NO_FR)) { + /* Default to Fast Read for DT and non-DT platform devices. */ + params->hwcaps.mask |= SNOR_HWCAPS_READ_FAST; + + /* Mask out Fast Read if not requested at DT instantiation. */ + if (np && !of_property_read_bool(np, "m25p,fast-read")) + params->hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST; + } + + /* (Fast) Read settings. */ + params->hwcaps.mask |= SNOR_HWCAPS_READ; + spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ], + 0, 0, SPINOR_OP_READ, + SNOR_PROTO_1_1_1); + + if (params->hwcaps.mask & SNOR_HWCAPS_READ_FAST) + spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_FAST], + 0, 8, SPINOR_OP_READ_FAST, + SNOR_PROTO_1_1_1); + /* Page Program settings. */ + params->hwcaps.mask |= SNOR_HWCAPS_PP; + spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP], + SPINOR_OP_PP, SNOR_PROTO_1_1_1); +} + /** * spi_nor_manufacturer_init_params() - Initialize the flash's parameters and * settings based on MFR register and ->default_init() hook. @@ -2528,109 +2578,46 @@ static void spi_nor_post_sfdp_fixups(struct spi_nor *nor) } /** - * spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings - * based on JESD216 SFDP standard. - * @nor: pointer to a 'struct spi_nor'. - * - * The method has a roll-back mechanism: in case the SFDP parsing fails, the - * legacy flash parameters and settings will be restored. - */ -static void spi_nor_sfdp_init_params(struct spi_nor *nor) -{ - struct spi_nor_flash_parameter sfdp_params; - - memcpy(&sfdp_params, nor->params, sizeof(sfdp_params)); - - if (!spi_nor_parse_sfdp(nor)) { - spi_nor_post_sfdp_fixups(nor); - } else { - memcpy(nor->params, &sfdp_params, sizeof(*nor->params)); - nor->addr_width = 0; - nor->flags &= ~SNOR_F_4B_OPCODES; - } -} - -/** - * spi_nor_info_init_params() - Initialize the flash's parameters and settings - * based on nor->info data. + * spi_nor_skip_sfdp_init_params() - Initialize the flash's parameters and + * settings based on nor->info data. * @nor: pointer to a 'struct spi_nor'. */ -static void spi_nor_info_init_params(struct spi_nor *nor) +static void spi_nor_skip_sfdp_init_params(struct spi_nor *nor) { struct spi_nor_flash_parameter *params = nor->params; struct spi_nor_erase_map *map = ¶ms->erase_map; - const struct flash_info *info = nor->info; - struct device_node *np = spi_nor_get_flash_node(nor); + const u32 info_flags = nor->info->flags & SFDP_FLAGS_MASK; u8 i, erase_mask; - /* Initialize default flash parameters and settings. */ - params->quad_enable = spi_nor_sr2_bit1_quad_enable; - params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; - params->setup = spi_nor_default_setup; - params->otp.org = &info->otp_org; - - /* Default to 16-bit Write Status (01h) Command */ - nor->flags |= SNOR_F_HAS_16BIT_SR; - - /* Set SPI NOR sizes. */ - params->writesize = 1; - params->size = (u64)info->sector_size * info->n_sectors; - params->page_size = info->page_size; - - if (!(info->flags & SPI_NOR_NO_FR)) { - /* Default to Fast Read for DT and non-DT platform devices. */ - params->hwcaps.mask |= SNOR_HWCAPS_READ_FAST; - - /* Mask out Fast Read if not requested at DT instantiation. */ - if (np && !of_property_read_bool(np, "m25p,fast-read")) - params->hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST; - } - - /* (Fast) Read settings. */ - params->hwcaps.mask |= SNOR_HWCAPS_READ; - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ], - 0, 0, SPINOR_OP_READ, - SNOR_PROTO_1_1_1); - - if (params->hwcaps.mask & SNOR_HWCAPS_READ_FAST) - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_FAST], - 0, 8, SPINOR_OP_READ_FAST, - SNOR_PROTO_1_1_1); - - if (info->flags & SPI_NOR_DUAL_READ) { + if (info_flags & SPI_NOR_DUAL_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_2; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_2], 0, 8, SPINOR_OP_READ_1_1_2, SNOR_PROTO_1_1_2); } - if (info->flags & SPI_NOR_QUAD_READ) { + if (info_flags & SPI_NOR_QUAD_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_4], 0, 8, SPINOR_OP_READ_1_1_4, SNOR_PROTO_1_1_4); } - if (info->flags & SPI_NOR_OCTAL_READ) { + if (info_flags & SPI_NOR_OCTAL_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_8], 0, 8, SPINOR_OP_READ_1_1_8, SNOR_PROTO_1_1_8); } - if (info->flags & SPI_NOR_OCTAL_DTR_READ) { + if (info_flags & SPI_NOR_OCTAL_DTR_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_8_8_8_DTR; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_8_8_8_DTR], 0, 20, SPINOR_OP_READ_FAST, SNOR_PROTO_8_8_8_DTR); } - /* Page Program settings. */ - params->hwcaps.mask |= SNOR_HWCAPS_PP; - spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP], - SPINOR_OP_PP, SNOR_PROTO_1_1_1); - - if (info->flags & SPI_NOR_OCTAL_DTR_PP) { + if (info_flags & SPI_NOR_OCTAL_DTR_PP) { params->hwcaps.mask |= SNOR_HWCAPS_PP_8_8_8_DTR; /* * Since xSPI Page Program opcode is backward compatible with @@ -2646,23 +2633,49 @@ static void spi_nor_info_init_params(struct spi_nor *nor) */ erase_mask = 0; i = 0; - if (info->flags & SECT_4K_PMC) { + if (info_flags & SECT_4K_PMC) { erase_mask |= BIT(i); spi_nor_set_erase_type(&map->erase_type[i], 4096u, SPINOR_OP_BE_4K_PMC); i++; - } else if (info->flags & SECT_4K) { + } else if (info_flags & SECT_4K) { erase_mask |= BIT(i); spi_nor_set_erase_type(&map->erase_type[i], 4096u, SPINOR_OP_BE_4K); i++; } erase_mask |= BIT(i); - spi_nor_set_erase_type(&map->erase_type[i], info->sector_size, + spi_nor_set_erase_type(&map->erase_type[i], nor->info->sector_size, SPINOR_OP_SE); spi_nor_init_uniform_erase_map(map, erase_mask, params->size); } +/** + * spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings + * based on JESD216 SFDP standard. + * @nor: pointer to a 'struct spi_nor'. + * + * The method has a roll-back mechanism: in case the SFDP parsing fails, the + * legacy flash parameters and settings will be restored. + */ +static void spi_nor_sfdp_init_params(struct spi_nor *nor) +{ + struct spi_nor_flash_parameter sfdp_params; + + memcpy(&sfdp_params, nor->params, sizeof(sfdp_params)); + + if (!spi_nor_parse_sfdp(nor)) { + spi_nor_post_sfdp_fixups(nor); + } else { + memcpy(nor->params, &sfdp_params, sizeof(*nor->params)); + nor->addr_width = 0; + nor->flags &= ~SNOR_F_4B_OPCODES; + + if (nor->info->flags & SPI_NOR_PARSE_SFDP) + spi_nor_skip_sfdp_init_params(nor); + } +} + /** * spi_nor_nonsfdp_init_flags() - Initialize NOR flags for settings that are not * defined in the JESD216 SFDP standard, thus can not be retrieved when parsing @@ -2760,6 +2773,19 @@ static void spi_nor_late_init_params(struct spi_nor *nor) spi_nor_init_default_locking_ops(nor); } +static void spi_nor_init_params_deprecated(struct spi_nor *nor) +{ + spi_nor_skip_sfdp_init_params(nor); + + spi_nor_manufacturer_init_params(nor); + + if ((nor->info->flags & (SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | + SPI_NOR_OCTAL_READ | + SPI_NOR_OCTAL_DTR_READ)) && + !(nor->info->flags & SPI_NOR_SKIP_SFDP)) + spi_nor_sfdp_init_params(nor); +} + /** * spi_nor_init_params() - Initialize the flash's parameters and settings. * @nor: pointer to a 'struct spi_nor'. @@ -2801,15 +2827,12 @@ static int spi_nor_init_params(struct spi_nor *nor) if (!nor->params) return -ENOMEM; - spi_nor_info_init_params(nor); + spi_nor_init_default_params(nor); - spi_nor_manufacturer_init_params(nor); - - if ((nor->info->flags & (SPI_NOR_PARSE_SFDP | - SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | - SPI_NOR_OCTAL_READ | SPI_NOR_OCTAL_DTR_READ)) && - !(nor->info->flags & SPI_NOR_SKIP_SFDP)) + if (nor->info->flags & SPI_NOR_PARSE_SFDP) spi_nor_sfdp_init_params(nor); + else + spi_nor_init_params_deprecated(nor); spi_nor_late_init_params(nor); -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-10-29 18:19 UTC|newest] Thread overview: 156+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-29 17:26 [PATCH v3 00/25] mtd: spi-nor: Clean params init Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-10-29 17:26 ` [PATCH v3 01/25] mtd: spi-nor: core: Fix spi_nor_flash_parameter otp description Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 8:18 ` Michael Walle 2021-11-09 8:18 ` Michael Walle 2021-10-29 17:26 ` [PATCH v3 02/25] mtd: spi-nor: core: Use container_of to get the pointer to struct spi_nor Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 8:21 ` Michael Walle 2021-11-09 8:21 ` Michael Walle 2021-11-15 10:59 ` Pratyush Yadav 2021-11-15 10:59 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info() Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 8:22 ` Michael Walle 2021-11-09 8:22 ` Michael Walle 2021-11-15 18:52 ` Pratyush Yadav 2021-11-15 18:52 ` Pratyush Yadav 2021-11-16 14:25 ` Tudor.Ambarus 2021-11-16 14:25 ` Tudor.Ambarus 2021-11-16 18:11 ` Pratyush Yadav 2021-11-16 18:11 ` Pratyush Yadav 2021-11-17 14:36 ` Tudor.Ambarus 2021-11-17 14:36 ` Tudor.Ambarus 2021-11-19 18:23 ` Pratyush Yadav 2021-11-19 18:23 ` Pratyush Yadav 2021-11-22 8:38 ` Tudor.Ambarus 2021-11-22 8:38 ` Tudor.Ambarus 2021-10-29 17:26 ` [PATCH v3 04/25] mtd: spi-nor: Get rid of nor->page_size Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 8:24 ` Michael Walle 2021-11-09 8:24 ` Michael Walle 2021-11-09 8:34 ` Tudor.Ambarus 2021-11-09 8:34 ` Tudor.Ambarus 2021-10-29 17:26 ` [PATCH v3 05/25] mtd: spi-nor: core: Introduce the late_init() hook Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 9:31 ` Michael Walle 2021-11-09 9:31 ` Michael Walle 2021-11-15 18:56 ` Pratyush Yadav 2021-11-15 18:56 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 06/25] mtd: spi-nor: atmel: Use flash late_init() for locking Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 9:31 ` Michael Walle 2021-11-09 9:31 ` Michael Walle 2021-11-15 18:59 ` Pratyush Yadav 2021-11-15 18:59 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 07/25] mtd: spi-nor: sst: " Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 9:34 ` Michael Walle 2021-11-09 9:34 ` Michael Walle 2021-11-15 19:00 ` Pratyush Yadav 2021-11-15 19:00 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 08/25] mtd: spi-nor: winbond: Use manufacturer late_init() for OTP ops Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 9:36 ` Michael Walle 2021-11-09 9:36 ` Michael Walle 2021-11-15 19:00 ` Pratyush Yadav 2021-11-15 19:00 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 09/25] mtd: spi-nor: xilinx: Use manufacturer late_init() to set setup method Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 9:43 ` Michael Walle 2021-11-09 9:43 ` Michael Walle 2021-11-15 19:01 ` Pratyush Yadav 2021-11-15 19:01 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 10/25] mtd: spi-nor: sst: Use manufacturer late_init() to set _write() Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 9:47 ` Michael Walle 2021-11-09 9:47 ` Michael Walle 2021-11-09 10:22 ` Tudor.Ambarus 2021-11-09 10:22 ` Tudor.Ambarus 2021-11-09 10:23 ` Tudor.Ambarus 2021-11-09 10:23 ` Tudor.Ambarus 2021-11-09 10:24 ` Michael Walle 2021-11-09 10:24 ` Michael Walle 2021-11-15 19:03 ` Pratyush Yadav 2021-11-15 19:03 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 11/25] mtd: spi-nor: spansion: Use manufacturer late_init() Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 9:48 ` Michael Walle 2021-11-09 9:48 ` Michael Walle 2021-11-15 19:06 ` Pratyush Yadav 2021-11-15 19:06 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 12/25] mtd: spi-nor: core: Call spi_nor_post_sfdp_fixups() only when SFDP is defined Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 10:18 ` Michael Walle 2021-11-09 10:18 ` Michael Walle 2021-10-29 17:26 ` [PATCH v3 13/25] mtd: spi-nor: sst: Get rid of SST_WRITE flash_info flag Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-09 12:21 ` Michael Walle 2021-11-09 12:21 ` Michael Walle 2021-11-09 12:31 ` Tudor.Ambarus 2021-11-09 12:31 ` Tudor.Ambarus 2021-11-12 21:28 ` Michael Walle 2021-11-12 21:28 ` Michael Walle 2021-10-29 17:26 ` [PATCH v3 14/25] mtd: spi-nor: Introduce flash_info flags masks Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-12 21:50 ` Michael Walle 2021-11-12 21:50 ` Michael Walle 2021-11-15 4:55 ` Tudor.Ambarus 2021-11-15 4:55 ` Tudor.Ambarus 2021-10-29 17:26 ` [PATCH v3 15/25] mtd: spi-nor: Introduce spi_nor_nonsfdp_init_flags() Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-15 19:12 ` Pratyush Yadav 2021-11-15 19:12 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 16/25] mtd: spi-nor: Introduce spi_nor_init_fixup_flags() Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-16 10:57 ` Pratyush Yadav 2021-11-16 10:57 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 17/25] mtd: spi-nor: core: Introduce SPI_NOR_PARSE_SFDP Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus [this message] 2021-10-29 17:26 ` [PATCH v3 18/25] mtd: spi-nor: core: Init flash params based on SFDP first for new flash additions Tudor Ambarus 2021-11-16 11:07 ` Pratyush Yadav 2021-11-16 11:07 ` Pratyush Yadav 2021-10-29 17:26 ` [PATCH v3 19/25] mtd: spi-nor: core: Move spi_nor_set_addr_width() in spi_nor_setup() Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-11-12 21:53 ` Michael Walle 2021-11-12 21:53 ` Michael Walle 2021-10-29 17:26 ` [PATCH v3 20/25] mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-10-29 17:31 ` Tudor.Ambarus 2021-10-29 17:31 ` Tudor.Ambarus 2021-11-09 12:25 ` Michael Walle 2021-11-09 12:25 ` Michael Walle 2021-11-09 12:33 ` Tudor.Ambarus 2021-11-09 12:33 ` Tudor.Ambarus 2021-11-09 12:37 ` Michael Walle 2021-11-09 12:37 ` Michael Walle 2021-10-29 17:26 ` [PATCH v3 21/25] mtd: spi-nor: winbond: w25q256jvm: " Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-10-29 17:31 ` Tudor.Ambarus 2021-10-29 17:31 ` Tudor.Ambarus 2021-10-29 17:26 ` [PATCH v3 22/25] mtd: spi-nor: spansion: s25fl256s0: Skip SFDP parsing Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-10-29 17:26 ` [PATCH v3 23/25] mtd: spi-nor: gigadevice: gd25q256: Init flash based on SFDP Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-10-29 17:33 ` Tudor.Ambarus 2021-10-29 17:33 ` Tudor.Ambarus 2021-10-29 17:26 ` [PATCH v3 24/25] mtd: spi-nor: issi: is25lp256: " Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-10-29 17:33 ` Tudor.Ambarus 2021-10-29 17:33 ` Tudor.Ambarus 2021-10-29 17:26 ` [PATCH v3 25/25] mtd: spi-nor: macronix: mx25l25635e: " Tudor Ambarus 2021-10-29 17:26 ` Tudor Ambarus 2021-10-29 17:34 ` Tudor.Ambarus 2021-10-29 17:34 ` Tudor.Ambarus 2021-11-08 10:15 ` [PATCH v3 00/25] mtd: spi-nor: Clean params init Tudor.Ambarus 2021-11-08 10:15 ` Tudor.Ambarus 2021-11-08 10:31 ` Michael Walle 2021-11-08 10:31 ` Michael Walle 2021-11-16 11:36 ` Pratyush Yadav 2021-11-16 11:36 ` Pratyush Yadav 2021-11-16 11:56 ` Michael Walle 2021-11-16 11:56 ` Michael Walle 2021-11-17 13:17 ` (subset)[PATCH " Tudor Ambarus 2021-11-17 13:17 ` Tudor Ambarus
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211029172633.886453-19-tudor.ambarus@microchip.com \ --to=tudor.ambarus@microchip.com \ --cc=code@reto-schneider.ch \ --cc=esben@geanix.com \ --cc=heiko.thiery@gmail.com \ --cc=jaimeliao@mxic.com.tw \ --cc=knaerzche@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-mtd@lists.infradead.org \ --cc=linux@rasmusvillemoes.dk \ --cc=macromorgan@hotmail.com \ --cc=mail@david-bauer.net \ --cc=michael@walle.cc \ --cc=miquel.raynal@bootlin.com \ --cc=nicolas.ferre@microchip.com \ --cc=p.yadav@ti.com \ --cc=richard@nod.at \ --cc=sr@denx.de \ --cc=vigneshr@ti.com \ --cc=zhengxunli@mxic.com.tw \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.