Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932826AbbKMMc5 (ORCPT ); Fri, 13 Nov 2015 07:32:57 -0500 Received: from mail-bl2nam02on0048.outbound.protection.outlook.com ([104.47.38.48]:14592 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932800AbbKMMcy (ORCPT ); Fri, 13 Nov 2015 07:32:54 -0500 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; denx.de; dkim=none (message not signed) header.d=none;denx.de; dmarc=bestguesspass action=none header.from=xilinx.com; From: Anurag Kumar Vulisha To: , , , , , , , , CC: , , , , , , , Anurag Kumar Vulisha Subject: [PATCH] mtd: spi-nor: Add Global Block-Protection Unlock support for SST flash parts Date: Fri, 13 Nov 2015 18:02:38 +0530 Message-ID: <1447417958-20896-1-git-send-email-anuragku@xilinx.com> X-Mailer: git-send-email 2.1.2 X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21938.006 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(87936001)(86362001)(2201001)(36756003)(229853001)(45336002)(50986999)(52956003)(46386002)(19580395003)(50466002)(48376002)(47776003)(50226001)(19580405001)(4001430100002)(5001770100001)(107886002)(189998001)(92566002)(5001960100002)(33646002)(5001920100001)(81156007)(11100500001)(6806005)(5007970100001)(90966002)(5008740100001)(5003940100001)(42186005)(63266004)(103686003)(106466001)(36386004)(107986001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2NAM02HT059;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501001);SRVR:BL2NAM02HT059; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046);SRVR:BL2NAM02HT059;BCL:0;PCL:0;RULEID:;SRVR:BL2NAM02HT059; X-Forefront-PRVS: 0759F7A50A X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2015 12:32:52.1733 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT059 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1969 Lines: 54 This patch adds Global block protection unlock support for SST flash parts Signed-off-by: Anurag Kumar Vulisha --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/