linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: move SECT_4K_PMC special handling
@ 2022-04-18 11:26 Michael Walle
  2022-04-20  6:27 ` Pratyush Yadav
  2022-06-27 10:13 ` Pratyush Yadav
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Walle @ 2022-04-18 11:26 UTC (permalink / raw)
  To: Tudor Ambarus, Pratyush Yadav
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	linux-mtd, linux-kernel, Michael Walle

The SECT_4K_PMC flag will set a device specific opcode for the 4k sector
erase. Instead of handling it in the core, we can move it to a
late_init(). In that late init, loop over all erase types, look for the
4k size and replace the opcode.

Signed-off-by: Michael Walle <michael@walle.cc>
---
Please have a closer look here. This is only compile time tested. Also
I didn't see much reason to reorder the flags.

 drivers/mtd/spi-nor/core.c |  7 +------
 drivers/mtd/spi-nor/core.h |  2 --
 drivers/mtd/spi-nor/issi.c | 23 +++++++++++++++++++++--
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 848836535cdd..fd41ab9a8746 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2364,12 +2364,7 @@ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor)
 	 */
 	erase_mask = 0;
 	i = 0;
-	if (no_sfdp_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 (no_sfdp_flags & SECT_4K) {
+	if (no_sfdp_flags & SECT_4K) {
 		erase_mask |= BIT(i);
 		spi_nor_set_erase_type(&map->erase_type[i], 4096u,
 				       SPINOR_OP_BE_4K);
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 14bf28473cf3..e355457a8555 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -352,7 +352,6 @@ struct spi_nor_fixups {
  *                  flags are used together with the SPI_NOR_SKIP_SFDP flag.
  *   SPI_NOR_SKIP_SFDP:       skip parsing of SFDP tables.
  *   SECT_4K:                 SPINOR_OP_BE_4K works uniformly.
- *   SECT_4K_PMC:             SPINOR_OP_BE_4K_PMC works uniformly.
  *   SPI_NOR_DUAL_READ:       flash supports Dual Read.
  *   SPI_NOR_QUAD_READ:       flash supports Quad Read.
  *   SPI_NOR_OCTAL_READ:      flash supports Octal Read.
@@ -400,7 +399,6 @@ struct flash_info {
 	u8 no_sfdp_flags;
 #define SPI_NOR_SKIP_SFDP		BIT(0)
 #define SECT_4K				BIT(1)
-#define SECT_4K_PMC			BIT(2)
 #define SPI_NOR_DUAL_READ		BIT(3)
 #define SPI_NOR_QUAD_READ		BIT(4)
 #define SPI_NOR_OCTAL_READ		BIT(5)
diff --git a/drivers/mtd/spi-nor/issi.c b/drivers/mtd/spi-nor/issi.c
index c012bc2486e1..3c7d51d2b050 100644
--- a/drivers/mtd/spi-nor/issi.c
+++ b/drivers/mtd/spi-nor/issi.c
@@ -29,6 +29,21 @@ static const struct spi_nor_fixups is25lp256_fixups = {
 	.post_bfpt = is25lp256_post_bfpt_fixups,
 };
 
+static void pm25lv_nor_late_init(struct spi_nor *nor)
+{
+	struct spi_nor_erase_map *map = &nor->params->erase_map;
+	int i;
+
+	/* The PM25LV series has a different 4k sector erase opcode */
+	for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++)
+		if (map->erase_type[i].size == 4096)
+			map->erase_type[i].opcode = SPINOR_OP_BE_4K_PMC;
+}
+
+static const struct spi_nor_fixups pm25lv_nor_fixups = {
+	.late_init = pm25lv_nor_late_init,
+};
+
 static const struct flash_info issi_nor_parts[] = {
 	/* ISSI */
 	{ "is25cd512",  INFO(0x7f9d20, 0, 32 * 1024,   2)
@@ -62,9 +77,13 @@ static const struct flash_info issi_nor_parts[] = {
 
 	/* PMC */
 	{ "pm25lv512",   INFO(0,        0, 32 * 1024,    2)
-		NO_SFDP_FLAGS(SECT_4K_PMC) },
+		NO_SFDP_FLAGS(SECT_4K)
+		.fixups = &pm25lv_nor_fixups
+	},
 	{ "pm25lv010",   INFO(0,        0, 32 * 1024,    4)
-		NO_SFDP_FLAGS(SECT_4K_PMC) },
+		NO_SFDP_FLAGS(SECT_4K)
+		.fixups = &pm25lv_nor_fixups
+	},
 	{ "pm25lq032",   INFO(0x7f9d46, 0, 64 * 1024,   64)
 		NO_SFDP_FLAGS(SECT_4K) },
 };
-- 
2.30.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: spi-nor: move SECT_4K_PMC special handling
  2022-04-18 11:26 [PATCH] mtd: spi-nor: move SECT_4K_PMC special handling Michael Walle
@ 2022-04-20  6:27 ` Pratyush Yadav
  2022-06-27 10:13 ` Pratyush Yadav
  1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Yadav @ 2022-04-20  6:27 UTC (permalink / raw)
  To: Michael Walle
  Cc: Tudor Ambarus, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, linux-mtd, linux-kernel

On 18/04/22 01:26PM, Michael Walle wrote:
> The SECT_4K_PMC flag will set a device specific opcode for the 4k sector
> erase. Instead of handling it in the core, we can move it to a
> late_init(). In that late init, loop over all erase types, look for the
> 4k size and replace the opcode.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
> Please have a closer look here. This is only compile time tested. Also
> I didn't see much reason to reorder the flags.

Patch looks okay to me but I would like someone to test it on the flash 
before I apply it.

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: spi-nor: move SECT_4K_PMC special handling
  2022-04-18 11:26 [PATCH] mtd: spi-nor: move SECT_4K_PMC special handling Michael Walle
  2022-04-20  6:27 ` Pratyush Yadav
@ 2022-06-27 10:13 ` Pratyush Yadav
  1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Yadav @ 2022-06-27 10:13 UTC (permalink / raw)
  To: Tudor Ambarus, Michael Walle
  Cc: linux-mtd, linux-kernel, Vignesh Raghavendra, Miquel Raynal,
	Richard Weinberger

On Mon, 18 Apr 2022 13:26:50 +0200, Michael Walle wrote:
> The SECT_4K_PMC flag will set a device specific opcode for the 4k sector
> erase. Instead of handling it in the core, we can move it to a
> late_init(). In that late init, loop over all erase types, look for the
> 4k size and replace the opcode.
> 
> 

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git spi-nor/next, thanks!
[1/1] mtd: spi-nor: move SECT_4K_PMC special handling
      https://git.kernel.org/mtd/c/77d4ac6d38

--
Regards,
Pratyush Yadav
Texas Instruments Inc.


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-27 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-18 11:26 [PATCH] mtd: spi-nor: move SECT_4K_PMC special handling Michael Walle
2022-04-20  6:27 ` Pratyush Yadav
2022-06-27 10:13 ` Pratyush Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).