Skip to contentSkip to conversation

sf: Make 4K sector support configurable

PATCH New Marek Vasut 2 participants 4 messages Aug 2, 2015 – Aug 5, 2015 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sf: Make 4K sector support configurable

Make the support for 4K subpage I/O on a SPI NOR flash configurable. A board which requires the SPI NOR to be accessed in larger 32KiB or 64KiB pages can disable the 4K subpage support, but by default, the support for 4K subpage I/O is enabled. The functionality of this option is the same as CONFIG_MTD_SPI_NOR_USE_4K_SECTORS in Linux.

This is extremely useful in case one uses UBI on a SPI NOR flash. UBI needs at least 15k EBs and can not work on a flash which uses 4k ones, so disabling the support for 4k subpages lets UBI work on such flash.

---
 drivers/mtd/spi/Kconfig       | 15 +++++++++++++++
 drivers/mtd/spi/sf_internal.h |  4 ++++
 2 files changed, 19 insertions(+)
drivers/mtd/spi/Kconfig +15 -0
index 8b730ff..3f7433c 100644
@@ -86,6 +86,21 @@ config SPI_FLASH_WINBOND
 
 endif
 
+config SPI_FLASH_USE_4K_SECTORS
+	bool "Use small 4096 B erase sectors"
+	depends on SPI_FLASH
+	default y
+	help
+	  Many flash memories support erasing small (4096 B) sectors. Depending
+	  on the usage this feature may provide performance gain in comparison
+	  to erasing whole blocks (32/64 KiB).
+	  Changing a small part of the flash's contents is usually faster with
+	  small sectors. On the other hand erasing should be faster when using
+	  64 KiB block instead of 16 ? 4 KiB sectors.
+
+	  Please note that some tools/drivers/filesystems may not work with
+	  4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
+
 config SPI_FLASH_DATAFLASH
 	bool "AT45xxx DataFlash support"
 	depends on SPI_FLASH && DM_SPI_FLASH
drivers/mtd/spi/sf_internal.h +4 -0
index 9fb5557..9c95d56 100644
@@ -37,7 +37,11 @@ enum spi_read_cmds {
 
 /* sf param flags */
 enum {
+#ifdef CONFIG_SPI_FLASH_USE_4K_SECTORS
 	SECT_4K		= 1 << 0,
+#else
+	SECT_4K		= 0 << 0,
+#endif
 	SECT_32K	= 1 << 1,
 	E_FSR		= 1 << 2,
 	SST_BP		= 1 << 3,
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 sf: Make 4K sector support configurable

Quoted 61 lines · Marek Vasut

Make the support for 4K subpage I/O on a SPI NOR flash configurable. A board which requires the SPI NOR to be accessed in larger 32KiB or 64KiB pages can disable the 4K subpage support, but by default, the support for 4K subpage I/O is enabled. The functionality of this option is the same as CONFIG_MTD_SPI_NOR_USE_4K_SECTORS in Linux.

This is extremely useful in case one uses UBI on a SPI NOR flash. UBI needs at least 15k EBs and can not work on a flash which uses 4k ones, so disabling the support for 4k subpages lets UBI work on such flash.

---
 drivers/mtd/spi/Kconfig       | 15 +++++++++++++++
 drivers/mtd/spi/sf_internal.h |  4 ++++
 2 files changed, 19 insertions(+)
drivers/mtd/spi/Kconfig +15 -0
index 8b730ff..3f7433c 100644
@@ -86,6 +86,21 @@ config SPI_FLASH_WINBOND
 
 endif
 
+config SPI_FLASH_USE_4K_SECTORS
+       bool "Use small 4096 B erase sectors"
+       depends on SPI_FLASH
+       default y
+       help
+         Many flash memories support erasing small (4096 B) sectors. Depending
+         on the usage this feature may provide performance gain in comparison
+         to erasing whole blocks (32/64 KiB).
+         Changing a small part of the flash's contents is usually faster with
+         small sectors. On the other hand erasing should be faster when using
+         64 KiB block instead of 16 ? 4 KiB sectors.
+
+         Please note that some tools/drivers/filesystems may not work with
+         4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
+
 config SPI_FLASH_DATAFLASH
        bool "AT45xxx DataFlash support"
        depends on SPI_FLASH && DM_SPI_FLASH
drivers/mtd/spi/sf_internal.h +4 -1
index 9fb5557..9c95d56 100644
@@ -37,7 +37,11 @@ enum spi_read_cmds {
 
 /* sf param flags */
 enum {
+#ifdef CONFIG_SPI_FLASH_USE_4K_SECTORS
        SECT_4K         = 1 << 0,
+#else
+       SECT_4K         = 0 << 0,
+#endif
        SECT_32K        = 1 << 1,
        E_FSR           = 1 << 2,
        SST_BP          = 1 << 3,
--
Quoted 1 line

2.1.4

thanks!

Signature · 1 line
Jagan | openedev.
#2 lore raw

PATCH 1/1 sf: Make 4K sector support configurable

Quoted 51 lines · Jagan Teki
Quoted 50 lines · Marek Vasut

Make the support for 4K subpage I/O on a SPI NOR flash configurable. A board which requires the SPI NOR to be accessed in larger 32KiB or 64KiB pages can disable the 4K subpage support, but by default, the support for 4K subpage I/O is enabled. The functionality of this option is the same as CONFIG_MTD_SPI_NOR_USE_4K_SECTORS in Linux.

This is extremely useful in case one uses UBI on a SPI NOR flash. UBI needs at least 15k EBs and can not work on a flash which uses 4k ones, so disabling the support for 4k subpages lets UBI work on such flash.

---
 drivers/mtd/spi/Kconfig       | 15 +++++++++++++++
 drivers/mtd/spi/sf_internal.h |  4 ++++
 2 files changed, 19 insertions(+)
drivers/mtd/spi/Kconfig +15 -0
index 8b730ff..3f7433c 100644
@@ -86,6 +86,21 @@ config SPI_FLASH_WINBOND
 
 endif
 
+config SPI_FLASH_USE_4K_SECTORS
+       bool "Use small 4096 B erase sectors"
+       depends on SPI_FLASH
+       default y
+       help
+         Many flash memories support erasing small (4096 B) sectors. Depending
+         on the usage this feature may provide performance gain in comparison
+         to erasing whole blocks (32/64 KiB).
+         Changing a small part of the flash's contents is usually faster with
+         small sectors. On the other hand erasing should be faster when using
+         64 KiB block instead of 16 ? 4 KiB sectors.
+
+         Please note that some tools/drivers/filesystems may not work with
+         4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
+
 config SPI_FLASH_DATAFLASH
        bool "AT45xxx DataFlash support"
        depends on SPI_FLASH && DM_SPI_FLASH
drivers/mtd/spi/sf_internal.h +0 -0
index 9fb5557..9c95d56 100644
@@ -37,7 +37,11 @@ enum spi_read_cmds {
 
Quoted 14 lines
Quoted 11 lines
drivers/mtd/spi/sf_internal.h +4 -1
 /* sf param flags */
 enum {
+#ifdef CONFIG_SPI_FLASH_USE_4K_SECTORS
        SECT_4K         = 1 << 0,
+#else
+       SECT_4K         = 0 << 0,
+#endif
        SECT_32K        = 1 << 1,
        E_FSR           = 1 << 2,
        SST_BP          = 1 << 3,
--
Quoted 1 line

2.1.4

Applied to u-boot-spi/master

thanks!

Signature · 1 line
Jagan | openedev.
#3 lore raw

PATCH 1/1 sf: Make 4K sector support configurable

Quoted 72 lines · Jagan Teki
Quoted 71 lines · Jagan Teki
Quoted 70 lines · Marek Vasut

Make the support for 4K subpage I/O on a SPI NOR flash configurable. A board which requires the SPI NOR to be accessed in larger 32KiB or 64KiB pages can disable the 4K subpage support, but by default, the support for 4K subpage I/O is enabled. The functionality of this option is the same as CONFIG_MTD_SPI_NOR_USE_4K_SECTORS in Linux.

This is extremely useful in case one uses UBI on a SPI NOR flash. UBI needs at least 15k EBs and can not work on a flash which uses 4k ones, so disabling the support for 4k subpages lets UBI work on such flash.

---

 drivers/mtd/spi/Kconfig       | 15 +++++++++++++++
 drivers/mtd/spi/sf_internal.h |  4 ++++
 2 files changed, 19 insertions(+)
drivers/mtd/spi/Kconfig +6 -0
index 8b730ff..3f7433c 100644
@@ -86,6 +86,21 @@ config SPI_FLASH_WINBOND
 
 endif
 
+config SPI_FLASH_USE_4K_SECTORS
+       bool "Use small 4096 B erase sectors"
+       depends on SPI_FLASH
+       default y
+       help
+         Many flash memories support erasing small (4096 B) sectors.

Depending + on the usage this feature may provide performance
gain in comparison + to erasing whole blocks (32/64 KiB).
+ Changing a small part of the flash's contents is usually
faster with + small sectors. On the other hand erasing should
be faster when using + 64 KiB block instead of 16 ? 4 KiB
sectors.

drivers/mtd/spi/Kconfig +2 -0
+
+         Please note that some tools/drivers/filesystems may not work

with + 4096 B erase size (e.g. UBIFS requires 15 KiB as a
minimum). +

config SPI_FLASH_DATAFLASH

bool "AT45xxx DataFlash support"
depends on SPI_FLASH && DM_SPI_FLASH

(quoted diff) +0 -0

b/drivers/mtd/spi/sf_internal.h index 9fb5557..9c95d56 100644

drivers/mtd/spi/sf_internal.h +4 -0
@@ -37,7 +37,11 @@ enum spi_read_cmds {
 
 /* sf param flags */
 enum {
 
+#ifdef CONFIG_SPI_FLASH_USE_4K_SECTORS
 
        SECT_4K         = 1 << 0,
 
+#else
+       SECT_4K         = 0 << 0,
+#endif
        SECT_32K        = 1 << 1,
        E_FSR           = 1 << 2,
        SST_BP          = 1 << 3,
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

--
2.1.4

Applied to u-boot-spi/master

Excellent, thanks!