mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: Add Global Block-Protection Unlock support for SST flash parts
@ 2015-11-13 12:32 Anurag Kumar Vulisha
  0 siblings, 0 replies; only message in thread
From: Anurag Kumar Vulisha @ 2015-11-13 12:32 UTC (permalink / raw)
  To: dwmw2, computersforpeace, zajec5, shijie.huang, juhosg, marex,
	mika.westerberg, beanhuo, furquan
  Cc: linux-mtd, linux-kernel, michals, harinik, punnaia, anirudh,
	svemula, Anurag Kumar Vulisha

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-13 12:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 12:32 [PATCH] mtd: spi-nor: Add Global Block-Protection Unlock support for SST flash parts Anurag Kumar Vulisha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®