linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities
@ 2020-05-19 10:46 Sagar Shrikant Kadam
  2020-05-19 10:46 ` [PATCH v2 1/2] riscv: defconfig: enable spi nor on Hifive Unleashed A00 Sagar Shrikant Kadam
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sagar Shrikant Kadam @ 2020-05-19 10:46 UTC (permalink / raw)
  To: linux-riscv, linux-kernel, linux-mtd
  Cc: aou, vigneshr, tudor.ambarus, richard, paul.walmsley, anup.patel,
	palmer, Sagar Shrikant Kadam, miquel.raynal

HiFive Unleashed A00 board has is25wp256d snor chip. It is observed
that it gets configured with Serial Input Page program by the end
of spi_nor_scan. Using the post bfpt fixup hook we prioritize the
page program settings to use quad input page program (opcode:0x34)
over serial input page program (opcode: 0x12).

The patchset is tested on Linux 5.7.0-rc5.

Changelog:
===============================
V2:
-Split common code between is25lp256 and is25wp256 devices as suggested
 Added a generic post bfpt fixup handler that identifies the flash parts
 based on their device id and uses the corresponding fixup. Other device's
 that need a post bfpt fixup can just add the device id check and either
 reuse the available fixups or write the necessary fixup code if one is not
 available.
 
V1:
-Moved SPI_SIFIVE from defconfig to Kconfig.socs for SOC_SIFIVE.
 Retained it's configurability using "imply" instead of "select"

V0: Base version patch (Tested on 5.7.0-rc3).


Sagar Shrikant Kadam (2):
  riscv: defconfig: enable spi nor on Hifive Unleashed A00
  spi: nor: update page program settings for is25wp256 using post bfpt
    fixup

 arch/riscv/Kconfig.socs      |  1 +
 arch/riscv/configs/defconfig |  3 +-
 drivers/mtd/spi-nor/issi.c   | 72 ++++++++++++++++++++++++++++++++++++--------
 3 files changed, 63 insertions(+), 13 deletions(-)

-- 
2.7.4


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

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

* [PATCH v2 1/2] riscv: defconfig: enable spi nor on Hifive Unleashed A00
  2020-05-19 10:46 [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities Sagar Shrikant Kadam
@ 2020-05-19 10:46 ` Sagar Shrikant Kadam
  2020-05-19 10:46 ` [PATCH v2 2/2] spi: nor: update page program settings for is25wp256 using post bfpt fixup Sagar Shrikant Kadam
  2020-05-25  5:45 ` [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities Sagar Kadam
  2 siblings, 0 replies; 4+ messages in thread
From: Sagar Shrikant Kadam @ 2020-05-19 10:46 UTC (permalink / raw)
  To: linux-riscv, linux-kernel, linux-mtd
  Cc: aou, vigneshr, tudor.ambarus, richard, paul.walmsley, anup.patel,
	palmer, Sagar Shrikant Kadam, miquel.raynal

Enable MTD based SPI-NOR framework in order to use spi flash available
on HiFive Unleashed A00 board, and move SPI_SIFIVE to Kconfig.socs. The
configurability of SPI_SIFIVE is retained and still can be enabled or
disabled as required.

Signed-off-by: Sagar Shrikant Kadam <sagar.kadam@sifive.com>
---
 arch/riscv/Kconfig.socs      | 1 +
 arch/riscv/configs/defconfig | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs
index 216286d..bcb0b1a 100644
--- a/arch/riscv/Kconfig.socs
+++ b/arch/riscv/Kconfig.socs
@@ -7,6 +7,7 @@ config SOC_SIFIVE
 	select CLK_SIFIVE
 	select CLK_SIFIVE_FU540_PRCI
 	select SIFIVE_PLIC
+	imply SPI_SIFIVE if SPI
 	help
 	  This enables support for SiFive SoC platform hardware.
 
diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig
index 4da4886..8e2d467 100644
--- a/arch/riscv/configs/defconfig
+++ b/arch/riscv/configs/defconfig
@@ -62,7 +62,6 @@ CONFIG_VIRTIO_CONSOLE=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_VIRTIO=y
 CONFIG_SPI=y
-CONFIG_SPI_SIFIVE=y
 # CONFIG_PTP_1588_CLOCK is not set
 CONFIG_POWER_RESET=y
 CONFIG_DRM=y
@@ -80,6 +79,8 @@ CONFIG_USB_STORAGE=y
 CONFIG_USB_UAS=y
 CONFIG_MMC=y
 CONFIG_MMC_SPI=y
+CONFIG_MTD=y
+CONFIG_MTD_SPI_NOR=y
 CONFIG_RTC_CLASS=y
 CONFIG_VIRTIO_PCI=y
 CONFIG_VIRTIO_BALLOON=y
-- 
2.7.4


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

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

* [PATCH v2 2/2] spi: nor: update page program settings for is25wp256 using post bfpt fixup
  2020-05-19 10:46 [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities Sagar Shrikant Kadam
  2020-05-19 10:46 ` [PATCH v2 1/2] riscv: defconfig: enable spi nor on Hifive Unleashed A00 Sagar Shrikant Kadam
@ 2020-05-19 10:46 ` Sagar Shrikant Kadam
  2020-05-25  5:45 ` [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities Sagar Kadam
  2 siblings, 0 replies; 4+ messages in thread
From: Sagar Shrikant Kadam @ 2020-05-19 10:46 UTC (permalink / raw)
  To: linux-riscv, linux-kernel, linux-mtd
  Cc: aou, vigneshr, tudor.ambarus, richard, paul.walmsley, anup.patel,
	palmer, Sagar Shrikant Kadam, miquel.raynal

Make a generic post_bfpt fixup handler which uses part specific fixup's
based on device id, as done here for is25lp256 and is25wp256 devices.

During SFDP parsing it is seen that the IS25WP256d device is missing 4BAIT
(4-Byte address instruction table), due to which it's page program
capacity doesn't get correctly populated and the device gets configured
with 4-byte Address Serial Input Page Program i.e. SNOR_PROTO_1_1_1
even though it can work with SNOR_PROTO_1_1_4.

Here using the post bfpt fixup hooks we update the page program
settings to 4-byte QUAD Input Page program operations.

The patch is tested on HiFive Unleashed A00 board and it benefits
few seconds of average write time for entire flash write.

QUAD Input Page Program operations:
> time mtd_debug write /dev/mtd0 0 33554432 rd32M
Copied 33554432 bytes from rd32M to address 0x00000000 in flash
real    0m 35.23s
user    0m 0.00s
sys     0m 23.97s

Serial Input Page Program operations:
> time mtd_debug write /dev/mtd0 0 33554432 rd32M
Copied 33554432 bytes from rd32M to address 0x00000000 in flash
real    0m 39.25s
user    0m 0.00s
sys     0m 27.93s

Signed-off-by: Sagar Shrikant Kadam <sagar.kadam@sifive.com>
---
 drivers/mtd/spi-nor/issi.c | 72 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 60 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/spi-nor/issi.c b/drivers/mtd/spi-nor/issi.c
index ffcb60e..efa0fe7 100644
--- a/drivers/mtd/spi-nor/issi.c
+++ b/drivers/mtd/spi-nor/issi.c
@@ -8,26 +8,74 @@
 
 #include "core.h"
 
-static int
-is25lp256_post_bfpt_fixups(struct spi_nor *nor,
-			   const struct sfdp_parameter_header *bfpt_header,
-			   const struct sfdp_bfpt *bfpt,
-			   struct spi_nor_flash_parameter *params)
+static int issi_fix_addr_width(struct spi_nor *nor,
+			       const struct sfdp_bfpt *bfpt)
 {
 	/*
-	 * IS25LP256 supports 4B opcodes, but the BFPT advertises a
+	 * If device supports 4B opcodes, but the BFPT advertises a
 	 * BFPT_DWORD1_ADDRESS_BYTES_3_ONLY address width.
 	 * Overwrite the address width advertised by the BFPT.
 	 */
-	if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
-		BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
+	if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK)
+		== BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
 		nor->addr_width = 4;
 
 	return 0;
 }
 
-static struct spi_nor_fixups is25lp256_fixups = {
-	.post_bfpt = is25lp256_post_bfpt_fixups,
+static int issi_update_proto(struct spi_nor *nor,
+			     struct spi_nor_flash_parameter *params)
+{
+	/*
+	 * For a device whose 4-Byte address instruction table doesn't
+	 * get populated and the device get's configured with 4-byte
+	 * Address Serial Input Page Program i.e. SNOR_PROTO_1_1_1 even
+	 * though it supports SNOR_PROTO_1_1_4, so priorotize QUAD write
+	 * over SINGLE write if device id table holds SPI_NOR_QUAD_READ.
+	 */
+	if (nor->info->flags & SPI_NOR_QUAD_READ) {
+		params->hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4;
+		spi_nor_set_pp_settings
+			(&params->page_programs[SNOR_CMD_PP_1_1_4],
+			 SPINOR_OP_PP_1_1_4,
+			 SNOR_PROTO_1_1_4);
+	}
+
+	return 0;
+}
+
+static int
+issi_post_bfpt_fixups(struct spi_nor *nor,
+		      const struct sfdp_parameter_header *bfpt_header,
+		      const struct sfdp_bfpt *bfpt,
+		      struct spi_nor_flash_parameter *params)
+{
+	long deviceid;
+
+	deviceid = (nor->info->id[1] << 8 | nor->info->id[2]);
+
+	/* As this is for same MFR i.e ISSI, just check the device ID's */
+	switch (deviceid) {
+	case 0x6019:
+		/* is25lp256 */
+		issi_fix_addr_width(nor, bfpt);
+		break;
+
+	case 0x7019:
+		/* is25wp256 */
+		issi_fix_addr_width(nor, bfpt);
+		issi_update_proto(nor, params);
+		break;
+
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static struct spi_nor_fixups is25_fixups = {
+	.post_bfpt = issi_post_bfpt_fixups,
 };
 
 static const struct flash_info issi_parts[] = {
@@ -48,7 +96,7 @@ static const struct flash_info issi_parts[] = {
 	{ "is25lp256",  INFO(0x9d6019, 0, 64 * 1024, 512,
 			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
 			     SPI_NOR_4B_OPCODES)
-		.fixups = &is25lp256_fixups },
+		.fixups = &is25_fixups },
 	{ "is25wp032",  INFO(0x9d7016, 0, 64 * 1024,  64,
 			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ "is25wp064",  INFO(0x9d7017, 0, 64 * 1024, 128,
@@ -58,7 +106,7 @@ static const struct flash_info issi_parts[] = {
 	{ "is25wp256", INFO(0x9d7019, 0, 64 * 1024, 512,
 			    SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
 			    SPI_NOR_4B_OPCODES)
-		.fixups = &is25lp256_fixups },
+		.fixups = &is25_fixups },
 
 	/* PMC */
 	{ "pm25lv512",   INFO(0,        0, 32 * 1024,    2, SECT_4K_PMC) },
-- 
2.7.4


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

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

* RE: [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities
  2020-05-19 10:46 [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities Sagar Shrikant Kadam
  2020-05-19 10:46 ` [PATCH v2 1/2] riscv: defconfig: enable spi nor on Hifive Unleashed A00 Sagar Shrikant Kadam
  2020-05-19 10:46 ` [PATCH v2 2/2] spi: nor: update page program settings for is25wp256 using post bfpt fixup Sagar Shrikant Kadam
@ 2020-05-25  5:45 ` Sagar Kadam
  2 siblings, 0 replies; 4+ messages in thread
From: Sagar Kadam @ 2020-05-25  5:45 UTC (permalink / raw)
  To: linux-riscv, linux-kernel, linux-mtd
  Cc: aou, vigneshr, tudor.ambarus, richard, Paul Walmsley, anup.patel,
	palmer, miquel.raynal

Hi,

A gentle reminder.
Any suggestions here?

BR,
Sagar Kadam

> -----Original Message-----
> From: Sagar Kadam <sagar.kadam@sifive.com>
> Sent: Tuesday, May 19, 2020 4:16 PM
> To: linux-riscv@lists.infradead.org; linux-kernel@vger.kernel.org; linux-
> mtd@lists.infradead.org
> Cc: Paul Walmsley <paul.walmsley@sifive.com>; palmer@dabbelt.com;
> aou@eecs.berkeley.edu; tudor.ambarus@microchip.com;
> miquel.raynal@bootlin.com; richard@nod.at; vigneshr@ti.com;
> anup.patel@wdc.com; Sagar Kadam <sagar.kadam@sifive.com>
> Subject: [PATCH v2 0/2] enable spi flash and update is25wp256d page write
> capabilities
> 
> HiFive Unleashed A00 board has is25wp256d snor chip. It is observed that it
> gets configured with Serial Input Page program by the end of spi_nor_scan.
> Using the post bfpt fixup hook we prioritize the page program settings to
> use quad input page program (opcode:0x34) over serial input page program
> (opcode: 0x12).
> 
> The patchset is tested on Linux 5.7.0-rc5.
> 
> Changelog:
> ===============================
> V2:
> -Split common code between is25lp256 and is25wp256 devices as suggested
> Added a generic post bfpt fixup handler that identifies the flash parts
> based on their device id and uses the corresponding fixup. Other device's
> that need a post bfpt fixup can just add the device id check and either
> reuse the available fixups or write the necessary fixup code if one is not
> available.
> 
> V1:
> -Moved SPI_SIFIVE from defconfig to Kconfig.socs for SOC_SIFIVE.
>  Retained it's configurability using "imply" instead of "select"
> 
> V0: Base version patch (Tested on 5.7.0-rc3).
> 
> 
> Sagar Shrikant Kadam (2):
>   riscv: defconfig: enable spi nor on Hifive Unleashed A00
>   spi: nor: update page program settings for is25wp256 using post bfpt
>     fixup
> 
>  arch/riscv/Kconfig.socs      |  1 +
>  arch/riscv/configs/defconfig |  3 +-
>  drivers/mtd/spi-nor/issi.c   | 72
> ++++++++++++++++++++++++++++++++++++--------
>  3 files changed, 63 insertions(+), 13 deletions(-)
> 
> --
> 2.7.4


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

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

end of thread, other threads:[~2020-05-25  5:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19 10:46 [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities Sagar Shrikant Kadam
2020-05-19 10:46 ` [PATCH v2 1/2] riscv: defconfig: enable spi nor on Hifive Unleashed A00 Sagar Shrikant Kadam
2020-05-19 10:46 ` [PATCH v2 2/2] spi: nor: update page program settings for is25wp256 using post bfpt fixup Sagar Shrikant Kadam
2020-05-25  5:45 ` [PATCH v2 0/2] enable spi flash and update is25wp256d page write capabilities Sagar Kadam

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).