Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754655AbdLFDMk (ORCPT ); Tue, 5 Dec 2017 22:12:40 -0500 Received: from mail-bl2nam02on0058.outbound.protection.outlook.com ([104.47.38.58]:26043 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754448AbdLFDMd (ORCPT ); Tue, 5 Dec 2017 22:12:33 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Zhiqiang Hou To: , , , , , , , CC: Hou Zhiqiang Subject: [PATCHv3 1/2] mtd: spi-nor: add an API to restore the status of SPI flash chip Date: Wed, 6 Dec 2017 10:53:41 +0800 Message-ID: <20171206025342.7266-2-Zhiqiang.Hou@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171206025342.7266-1-Zhiqiang.Hou@nxp.com> References: <20171206025342.7266-1-Zhiqiang.Hou@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131570035517095353;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(336005)(39860400002)(346002)(39380400002)(376002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(76176011)(2950100002)(6666003)(498600001)(305945005)(5660300001)(356003)(104016004)(2906002)(106466001)(105606002)(72206003)(316002)(16586007)(50226002)(110136005)(68736007)(81166006)(81156014)(4326008)(8676002)(8936002)(97736004)(50466002)(2201001)(85426001)(8656006)(47776003)(1076002)(51416003)(86362001)(48376002)(77096006)(575784001)(53936002)(39060400002)(36756003)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB2700;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD008;1:/SraOGp0zn7kCj3BgMlLc7UR0yZBz5gsL1KMecWH9iJAY3Wbq4+bSrRYZZb1jDM3PIds2ePuxXCAbDB5iJHwhRwD4SXqWnZ36K6DTX6zWsymvKk90T855S7KNbIYIzKm MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 948b09d6-584d-4d8f-f2b1-08d53c573078 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4628075)(201703131517081)(2017052603286);SRVR:DM5PR03MB2700; X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB2700;3:chI+lhJQjqyoJ22SpyRNwZC95K2C+a4VKcQli3Swpaeae7S3IgOGAubisvpyTUafOTiZ/0YHUyigJiRg3vU4oBRa9niERF5uQ00WsTaRvKEC3DC1NdTtm2+YTK/dWMhoYH2T8Sr+kHHSirYSjF3daEH4Cwl9f0ZYmJWB+b3735qxzwuMmUihI3/Ica2nW2RoY2HuXliL8x9//vgC5+pe86fjx2jN9J7D860rjS4ujuRyIzyzPAQdS6yukGCQAakZWhPCO366kmxghMO/q60YLZMbPAtvMcjXAVbdbgQZcacqTjg4fnBF3U5bZSf/0h1tiCB+OyU8d2H85SkrHfBFNKat92MvEamMUF8mZgGlhtw=;25:xRHQiEtTfFA94tuljrQhdkrWhNuvni6zPrKENzs+uI8N1tYr13qep5nXyXB8i0lJnA9fXB1hXK5Pjc3A4K1Pk36lyNLhb0u1bzuQ5SVt/ficQ9MvP1QKwvzAnNpdJR/qqc0sNz/otPIjYrNYJ6g+fMy1fctYbycv0L3yiMQtQQlscXQfDfmbKYYiFzMn9dhNQq+rMJXzPPeXIF2IvVEXjPEnXk8+CzvoKsRNP460Ea9XmBcJYcUK4YFXzTN78QoackhgirqRrRwjYwWvwnAbqrCP29QyuN03JVjTOq0PzowoHLQekp9FAVLD9f4IqPnNa98qOHzshHqMPYKilWQrTA== X-MS-TrafficTypeDiagnostic: DM5PR03MB2700: X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB2700;31:QCYswAGcihdafm/nispX2u9OQAdJscZzvuH2iRuxTGwYWTz2kTg9qKVAN7O5BmAxSSUwv9KNGv2DQUFeGnbEL5noHjXvz9NFRpSSMP9fI2MhFeac06AcHyrRlAJP1G7OwALRMvaQqL0lllcH+HMciEw5VGYREY2SZg3oIpLE1o+ksYkZptZfG8Nt511W55ls2RvNd8Ue9Jq0lKLKZxUQhYi6ibtiZRLdPTviYq1uGdo=;4:ejUge1E9bzDJVywR7qUM1Pj2WHisAeJZaHwuFgn+Ns6NfSP6R8wkHNK0b3wisQif3ikcoXS+/GWmzB1lJXSovyrxEpItotBC5jyxobpiE+sA/7/bUlgLAFvbyUwuGmtq/XpmY+Lp+SdfL7OzU8Z6blrqgCKWBNka+29IM3+H0XxYqj3TEcPHXmPd64RJk3arT5TG0yNgJfXLMghYXHzt9a9fZh1v41tIuY1uq54jUCB8uYXw1fp05tBU4fbTsQX5KdDthUVGtcvDZ5DUlA/7Fbhu4X1CHg+HOeiZZsDOowuAITixQLIxdYuSPIwAGLJh X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231022)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123556025)(20161123563025)(20161123559100)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123561025)(201708071742011);SRVR:DM5PR03MB2700;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:DM5PR03MB2700; X-Forefront-PRVS: 05134F8B4F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM5PR03MB2700;23:81V/BO1pQU+S697KpVm9KbO5BzuEh+KzQBsWTfeM1?= =?us-ascii?Q?cBkGqhQ7GJ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8iHfrhwky0S5USR27WiFykTqVPbe76WgUDNWrl06cvTGNTW25HovB6lklHReqBuWqQeyOMynxRJ2c3iCFiyPlbevEitegEqOCG1QLXtk4COAVzUSmKAh70f4Ht6F9S9nVx00yR9kgfVVC09zeFBXItIpkhTn+pWbFUrRXmIHBdEp4w1DOvvtrlZaHcFXJLTSpN SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2017 03:12:31.3975 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 948b09d6-584d-4d8f-f2b1-08d53c573078 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2700 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2289 Lines: 65 From: Hou Zhiqiang Add this API to restore the status of SPI flash chip to the default such as addressing mode, whenever detach the driver from device or reboot the system. Signed-off-by: Hou Zhiqiang --- V3: - no change. Documentation/mtd/spi-nor.txt | 3 +++ drivers/mtd/spi-nor/spi-nor.c | 10 ++++++++++ include/linux/mtd/spi-nor.h | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/Documentation/mtd/spi-nor.txt b/Documentation/mtd/spi-nor.txt index 548d6306ebca..da1fbff5a24c 100644 --- a/Documentation/mtd/spi-nor.txt +++ b/Documentation/mtd/spi-nor.txt @@ -60,3 +60,6 @@ The main API is spi_nor_scan(). Before you call the hook, a driver should initialize the necessary fields for spi_nor{}. Please see drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c when you want to write a new driver for a SPI NOR controller. +Another API is spi_nor_restore(), this is used to restore the status of SPI +flash chip such as addressing mode. Call it whenever detach the driver from +device or reboot the system. diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index bc266f70a15b..4a925378d434 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2713,6 +2713,16 @@ static void spi_nor_resume(struct mtd_info *mtd) dev_err(dev, "resume() failed\n"); } +void spi_nor_restore(struct spi_nor *nor) +{ + /* restore the addressing mode */ + if ((nor->addr_width == 4) && + (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) && + !(nor->info->flags & SPI_NOR_4B_OPCODES)) + set_4byte(nor, nor->info, 0); +} +EXPORT_SYMBOL_GPL(spi_nor_restore); + int spi_nor_scan(struct spi_nor *nor, const char *name, const struct spi_nor_hwcaps *hwcaps) { diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index d0c66a0975cf..0a182c3d0884 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -399,4 +399,10 @@ struct spi_nor_hwcaps { int spi_nor_scan(struct spi_nor *nor, const char *name, const struct spi_nor_hwcaps *hwcaps); +/* + * spi_nor_restore_addr_mode() - restore the status of SPI NOR + * @nor: the spi_nor structure + */ +void spi_nor_restore(struct spi_nor *nor); + #endif -- 2.14.1