Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754927AbcCCHTL (ORCPT ); Thu, 3 Mar 2016 02:19:11 -0500 Received: from mail-bn1bon0118.outbound.protection.outlook.com ([157.56.111.118]:46304 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751306AbcCCHTJ (ORCPT ); Thu, 3 Mar 2016 02:19:09 -0500 Authentication-Results: spf=neutral (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=freescale.com; From: Yunhui Cui To: , , CC: , , , , Yunhui Cui Subject: [PATCH v3 4/4] mtd: spi-nor: Disable Micron flash HW protection Date: Thu, 3 Mar 2016 14:54:04 +0800 Message-ID: <1456988044-37061-4-git-send-email-B56489@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1456988044-37061-1-git-send-email-B56489@freescale.com> References: <1456988044-37061-1-git-send-email-B56489@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CPI:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(189002)(199003)(586003)(2906002)(50226001)(1096002)(1220700001)(4326007)(76176999)(50986999)(48376002)(5001770100001)(36756003)(6806005)(5001960100004)(104016004)(50466002)(2950100001)(5008740100001)(77096005)(5003940100001)(92566002)(4001450100002)(11100500001)(47776003)(575784001)(86362001)(105586002)(229853001)(189998001)(87936001)(19580405001)(19580395003)(2201001)(106466001)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB068;H:tx30smr01.am.freescale.net;FPR:;SPF:Neutral;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD018;1:xsTM1cjCP4fZZst6pvJilFKryo238Qor3ACZruZSNhNU2s4sDPbKHfxUkjFMZq4H7WT0hjNxI4+Y9O0/R3vNayF02kFXbCQtEq122eEIltgI0YaFJziNKdfQNV8fW/0m6C5hG8jXtbcniWKqsNlP1i/ijoUxOgHkFDLkVBpjG8AM/9090XzMDQdPyetCjFz8pLOnJU8XVVYGmmUlwAGWAqLGoRrQDS6iFINoO/NOwV7V3WA77oJnAJBY7mTsUcybiH+4lQPeyUsHmXvn0S/r37UXWSQkz0rmpczZVEeRLc02IoCMmel46O3Zl0a/XdblRR/w1QP0pUuOZC5nTjfZheWlA8Nvk/VCzpMe1siKLQd359kUpw3HFSbQvxRn9QIf0kCBWSEFLymRL8r/Q9Mz/cyF3i92kt5WLIiGNOCtewTFmoOW5DGLxdZcukhTuLA0B0Q3V53qswxV/+JOOYzWI1A8bf+jWL0J11NLdIe9NqzA6p3wtnPEYucIM05eeq1R MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5175a9e2-bf6f-4f0a-bcd5-08d34331dfe7 X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB068;2:inlg+Wq6yOwUirIljW35yxKtP3TV3XA2OqQCJTChiQzD2Um66NT8BVfiGOKSSqt/hqf4uTzswJEpO/jrfnxyBPD7AmiIztijOkWoW4gt+1vpko8mj5o7MmIUeOY5EzrDgRE+yhLaWQ60ogJPVfx71BbQJE5SiHsqJdroNHXCpTBedai7ro34zIDFAXQRWbI4;3:ha2XSKERM1wKOuyrn0IKfbMzksWusbqDSLCBvwweeDwl5cHJuS9rT6F75GyZsJ1/HjM37UQ/IGVQvyuMhNiXezUDSaB3a/vJ0MyWXaJ04Qf/ip8ZdZ7J9HwIZ8H8b3LdsIXEZESOhFHDTkdGCdsIKlPoy/+Zh3/WzLF6Ldkm/Cfk6Ni08jnhnrQYCk2NBd89;25:lOcE8D/Nt0IbHkNZ9Exnlt2pBk8EkL24UHlRXTTXYpKaPkcHQD6qCzxns8R/L+dIBR7lkl4c2TDyD15JTWhdtuVBUf8h+ZXELlKZyG10Y/sTqDF5r0jf7xOVwu1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gw7wTUPf9BEEiSksHCB2ytuwcxEBrGPxzrTyPlQAPyhtsfLxutLJ5U/HMtXiyGh/cjw/HWZZgMVkyJNJlfYUsd8lVdd1uYoaVAQkZdFRXCO/zSwzFFFo2M9yE1HKDjUXceuhK4rYGEBgQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(5005006)(8121501046)(13018025)(3002001)(10201501046);SRVR:BLUPR03MB068;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB068; X-Forefront-PRVS: 0870212862 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR03MB068;23:2x5vSkypnaLBysU8mjIQliEK3cg1yCBeuvq33j+A6F?= =?us-ascii?Q?Wt7iXJEwYw1Zup3gdrndg+4ba7ijTPdMNdjoqVaGEGzRidMJZoC/3JKBUj96?= =?us-ascii?Q?rzXYAkiip6i/XdQY+au4BmMi90X8nnNAPucbW1F23X7JOdUjBMCWbztqqmuu?= =?us-ascii?Q?1bLnGxwaNeFnmfLyLdK8QUCzGWqxrkxvNHNI/gzw4YsJKGBpkQzGpcuYYnyS?= =?us-ascii?Q?g8kPrpbd+txq9W7/PIHB9TQtHEm61e52T0OCUKZ+M8iM5+OiP/uye1Zuh3NH?= =?us-ascii?Q?z92v5wk+cw+oe6iQb6BPreh6p1Ga/703vZnXq355pqv0rDWgnPqjmNdieVh4?= =?us-ascii?Q?3vYOlEmvjsjWNhVSzxVuib168nsW0UUujmEo/oz3Vrl4qeHaSibwGAvDZpC9?= =?us-ascii?Q?33Y5LfpvUyly3OqvJzy0JAZBNN7E1nNPcoMr1S3ugS+2a888vOmpepV+0Bkg?= =?us-ascii?Q?hzuwzlQHXGt+FOfhjEfSoLAxRecYw2zp27rt/U6qKG/CH57B9foyFyO7EJ6u?= =?us-ascii?Q?IuJSTnPpgrRtRFIPmklI2wZhkVo3jsV5S7OjDHC2mMRX8Uqgdh9DG2yu/EBC?= =?us-ascii?Q?jo91WKYCqn0hr+fg6y7VG9kIYHmPkRISMWzMABrOfN295z2p+HPEPe8oSH0l?= =?us-ascii?Q?EIME8+FD1c4SodToqcDS2Qt4UW/g2WgL5seX6YfazlpRU4dqy8iac4gZAJSe?= =?us-ascii?Q?RCwOYgriA5EQDQko1KPJ8GNuypbq1/Uh9SDLIVFzBFwga8C6jgaCKxRL6hIg?= =?us-ascii?Q?T3Zq2+fIkhXdFpF1qSjs0NBmrojqKe0wmrQtDiqsW5ibte30a5h5TXR5o7nu?= =?us-ascii?Q?UUCsIrHZTxCq8lGXfBSTlsEKuu62yjOzkL3Mk8cmtjZ/1O7QAltaFtnEq/43?= =?us-ascii?Q?0lVberzSSWpTEjBGeYfrSd54TDd6NHkISJKIUQaMB7YKAwDPh42cFMNZXMk9?= =?us-ascii?Q?RgKG3ntjQb/wjoIiDoNvldAhhWzl/nLtyhqEQ2STDMpu878G919FwD10+fl+?= =?us-ascii?Q?zdGlzk1R2bxx705JNrDAGI18bI68deRExjntzS9Q5v/Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB068;5:DFdexfOdZZmD6CUDWAKiIDFdRSVfuqyxPEgbvexw4HGCZJ5AvzDtPPqaZvpSb1fdg5M6dRVnNYne/VYniVVXbKJP0Gx4dig09J03YeJtM6aQJc9yDnwVmxDMtVq1b0KgEladRF5g9FCGd978KxDpqg==;24:QlKIssawLa/Wf+9KGW7MtAoRm9yuJxe1ldPwkfEDkJa11AGcWzbqLhmqwBzf9SBscQLvIKb1B/8AJJjETEitxslPuEax3mzwXM1fLTTdcGk= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2016 07:03:07.6464 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB068 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1154 Lines: 42 From: Yunhui Cui For Micron family ,The status register write enable/disable bit, provides hardware data protection for the device. When the enable/disable bit is set to 1, the status register nonvolatile bits become read-only and the WRITE STATUS REGISTER operation will not execute. Signed-off-by: Yunhui Cui --- drivers/mtd/spi-nor/spi-nor.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index ed0c19c..917f814 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -39,6 +39,7 @@ #define SPI_NOR_MAX_ID_LEN 6 #define SPI_NOR_MAX_ADDR_WIDTH 4 +#define SPI_NOR_MICRON_WRITE_ENABLE 0x7f struct flash_info { char *name; @@ -1238,6 +1239,14 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) write_sr(nor, 0); } + if (JEDEC_MFR(info) == SNOR_MFR_MICRON) { + ret = read_sr(nor); + ret &= SPI_NOR_MICRON_WRITE_ENABLE; + + write_enable(nor); + write_sr(nor, ret); + } + if (!mtd->name) mtd->name = dev_name(dev); mtd->priv = nor; -- 2.1.0.27.g96db324