lkml.org 
[lkml]   [2015]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mtd: spi-nor: Add Global Block-Protection Unlock support for SST flash parts
Date
This patch adds Global block protection unlock support for SST flash parts

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
---
drivers/mtd/spi-nor/spi-nor.c | 8 ++++++++
include/linux/mtd/spi-nor.h | 1 +
2 files changed, 9 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 4988390..787ab95 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -68,6 +68,8 @@ struct flash_info {
#define SPI_NOR_DUAL_READ 0x20 /* Flash supports Dual Read */
#define SPI_NOR_QUAD_READ 0x40 /* Flash supports Quad Read */
#define USE_FSR 0x80 /* use flag status register */
+/* Unlock the Global protection for sst flashes */
+#define SST_GLOBAL_PROT_UNLK 0x100
};

#define JEDEC_MFR(info) ((info)->id[0])
@@ -1204,6 +1206,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
write_enable(nor);
write_sr(nor, 0);
+
+ if (info->flags & SST_GLOBAL_PROT_UNLK) {
+ write_enable(nor);
+ /* Unlock global write protection bits */
+ nor->write_reg(nor, GLOBAL_BLKPROT_UNLK, NULL, 0);
+ }
}

if (!mtd->name)
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index c8723b6..37e1abf 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -65,6 +65,7 @@
#define SPINOR_OP_BP 0x02 /* Byte program */
#define SPINOR_OP_WRDI 0x04 /* Write disable */
#define SPINOR_OP_AAI_WP 0xad /* Auto address increment word program */
+#define GLOBAL_BLKPROT_UNLK 0x98 /* Clear global write protection bits */

/* Used for Macronix and Winbond flashes. */
#define SPINOR_OP_EN4B 0xb7 /* Enter 4-byte mode */
--
2.1.2


\
 
 \ /
  Last update: 2015-11-13 14:01    [W:0.673 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site