Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754669AbdLFDMq (ORCPT ); Tue, 5 Dec 2017 22:12:46 -0500 Received: from mail-bl2nam02on0061.outbound.protection.outlook.com ([104.47.38.61]:12320 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754509AbdLFDMg (ORCPT ); Tue, 5 Dec 2017 22:12:36 -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 2/2] mtd: m25p80: restore the status of SPI flash when exiting Date: Wed, 6 Dec 2017 10:53:42 +0800 Message-ID: <20171206025342.7266-3-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: 131570035531489963;(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)(346002)(39860400002)(39380400002)(376002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(356003)(106466001)(16586007)(8656006)(105606002)(316002)(5660300001)(68736007)(305945005)(53936002)(2906002)(81166006)(110136005)(81156014)(2201001)(8676002)(1076002)(50226002)(85426001)(47776003)(86362001)(50466002)(8936002)(6666003)(104016004)(2950100002)(48376002)(51416003)(39060400002)(72206003)(76176011)(498600001)(36756003)(97736004)(4326008)(77096006)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2690;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD034;1:x6FfgH8iH8tM4GoByAAhqPWUQsKO/s4pGcFnkFuy2WI2ozHSof6o/KRxhc8n2/EXaZ/k8krFjfCyEc0IFBUG/NHa30jd5N99soNIbLseviRu0RA3QKIIkJuxV/mSrWZX MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df04ed84-4a93-4f95-bbc9-08d53c57315b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603286);SRVR:BN6PR03MB2690; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2690;3:pkwV0hMgKloC4UVXrG+T2PfIp3mWeUytH3ZsOGCjqcGu8uB86av4wLpeKMrdP+n9uiNIKD9OTLAtfm7RUW8p2jNjpuQNlPcqwTIBmq4HzIc7JDnoANQgz9i6AT/vedvvg7biHLJjYUZ2FLgBsJO4jQ02b2Av0WZ5cxIsiEhofKyL9WCjppa+qo7ai5NUUBiNcPQxkY104k+3zbna3zLyELniJaWWb0V0INd6Skc+SZi0D1Q8cCZrbVK2S5ftx3QKmEFOMKIag/oLAYtm/GTRGDIQwvCSol6/NxKU7M4YPQHKu2zWsZJ2+6MK/6jjORuhgZGUMwG8fkPiGEuWBHjATmmC40Y9kzoAh9YI9/i3oa4=;25:wPqfrOzN6Ed7lOzalAFFNSvfZapLtinqGQDrRlrE56Vpcxg11Yx8PomEaeNnOklJTulzmjcl5M0+GQMcj8/CaxU3c1cq79Q3x2gUsOplFHsp0XiW95xdK4H9tzuTYq+KyIoMvHJTOh9ZJf2EQ6ZD0zbSS873UJA+MpBG90AcIbXP3ME+bz1LbaWV2TSExqDL0Wjg+Bh//iuXqNvG7qcyUEuCRuWVzGe3tlDMSG++lydCOZ5DtpX4qKPdXkAXz4z03RKuV2FBVbCUc1jK2v2BDiVqe94WMI9OPZvOrDZJjgFAoBb2jCED7Fn8lqayNchpZfEv6PhIEK9JjjV8v9KTjA== X-MS-TrafficTypeDiagnostic: BN6PR03MB2690: X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2690;31:mm+H2EwlTindbABPmefUWZMth7eppMAs60dDpjHmo/murPtxTY6pGqO8EWh8anmXheoPOpTZSmiiXiF96vrm6J8Uj26nAoS8s2ImDu8VEU1+XOmcczfORyl/o3X5xTsvB+ISIglT540UAv246KB84ok4zSjJEgmK6tgXFYmiMkVfGugf6lEb9+w4nAYE2iTmXHE7/y0nGnEvlFk4ltfHSEHErMRgP8x32yeeDJsoRTc=;4:bTeL4yL99sB1L3bl+m+MWwq8m2nLJAVj3WFj1zn1apl1jhLjP2PIwbIfz1Dk70qYS1uWeTFlV6y/w/+tiarixpTwj7ueO8VPCs/MdOt4mkKYJDrIPgXLY+Vg8pkkSWsMJz4FQHzgHTrhoN1fDfYJsOomlxB4SJdqh6D73RpA1yEvkQ6kpaG/zRy6cz2beKPGnQikqofuTN8UA5Qv+xMEak61mbQBTAex7SE3+jyQYuUTx+kpZZE66VpN2fo0LOdBeqIMbyWaUtUs23Z9KeW90L4ppLJlrmK2oZ0BJmbay7276xtQUBbEbCMhn9yJJFD8 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)(3231022)(3002001)(10201501046)(93006095)(93001095)(6055026)(6096035)(20161123563025)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123559100)(20161123565025)(20161123561025)(20161123556025)(201708071742011);SRVR:BN6PR03MB2690;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:BN6PR03MB2690; X-Forefront-PRVS: 05134F8B4F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR03MB2690;23:4D1M80ywQdi4CzSbxHgZKBSCPoAwPgStOBmACidxM?= =?us-ascii?Q?SqJzP7M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Iu1ODp52yx5tBc0pxfQdwdlsknlcwYawqISSxNeMJAOfVErK46lD4cRbeMElFSe99fHgscEhHpog9hFMSvUFmNt86vxXt8aKtthubN0lNjEoEkAvdHfftEAmhPOVmKmEFOal0pPY38IvFzERBMER+bR8oumuiiiR SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2017 03:12:32.9149 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df04ed84-4a93-4f95-bbc9-08d53c57315b 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: BN6PR03MB2690 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1616 Lines: 52 From: Hou Zhiqiang Restore the status to be compatible with legacy devices. Take Freescale eSPI boot for example, it copies (in 3 Byte addressing mode) the RCW and bootloader images from SPI flash without firing a reset signal previously, so the reboot command will fail without reseting the addressing mode of SPI flash. This patch implement .shutdown function to restore the status in reboot process, and add the same operation to the .remove function. Signed-off-by: Hou Zhiqiang --- V3: - Modified the commit to make this patch specific. drivers/mtd/devices/m25p80.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index dbe6a1de2bb8..a4e18f6aaa33 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -307,10 +307,18 @@ static int m25p_remove(struct spi_device *spi) { struct m25p *flash = spi_get_drvdata(spi); + spi_nor_restore(&flash->spi_nor); + /* Clean up MTD stuff. */ return mtd_device_unregister(&flash->spi_nor.mtd); } +static void m25p_shutdown(struct spi_device *spi) +{ + struct m25p *flash = spi_get_drvdata(spi); + + spi_nor_restore(&flash->spi_nor); +} /* * Do NOT add to this array without reading the following: * @@ -386,6 +394,7 @@ static struct spi_driver m25p80_driver = { .id_table = m25p_ids, .probe = m25p_probe, .remove = m25p_remove, + .shutdown = m25p_shutdown, /* REVISIT: many of these chips have deep power-down modes, which * should clearly be entered on suspend() to minimize power use. -- 2.14.1