]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
mtd: spi-nor: Add Global Block-Protection Unlock support for SST flash parts
authorAnurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Fri, 30 Oct 2015 06:32:29 +0000 (12:02 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 10 Nov 2015 09:01:52 +0000 (10:01 +0100)
This patch adds Global block protection unlock support for SST flash parts

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Reviewed-by: Harini Katakam <harinik@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/mtd/spi-nor/spi-nor.c
include/linux/mtd/spi-nor.h

index 1dd91f11682ee6133002e7a2af94fbcab603f044..c348de7d9035a048224b6c2aaa77bdd7ace3b0c2 100644 (file)
@@ -58,6 +58,8 @@ struct flash_info {
 #define        USE_FSR                 0x80    /* use flag status register */
 #define        SPI_NOR_FLASH_LOCK      0x100   /* Flash protection support */
 #define        SPI_NOR_QUAD_IO_READ    0x200   /* Flash supports Quad IO read */
+/* Unlock the Global protection for sst flashes */
+#define        SST_GLOBAL_PROT_UNLK    0x400
 };
 
 #define JEDEC_MFR(info)        ((info)->id[0])
@@ -1514,6 +1516,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
            JEDEC_MFR(info) == CFI_MFR_SST) {
                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, 0);
+               }
        }
 
        if (!mtd->name)
index 22e328bdeaed018362f0f9aface303e7d95eb57f..d752c5cb4215fa06d124a25413cddb4b5e4f7900 100644 (file)
@@ -53,6 +53,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 */