From: Zhiqiang Hou <Zhiqiang.Hou@nxp.com>
To: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<computersforpeace@gmail.com>, <dwmw2@infradead.org>,
<boris.brezillon@free-electrons.com>, <marek.vasut@gmail.com>,
<richard@nod.at>, <cyrille.pitchen@wedev4u.fr>
Cc: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Subject: [PATCH 1/2] mtd: spi-nor: add a API to restore the addressing mode
Date: Fri, 24 Nov 2017 18:08:47 +0800 [thread overview]
Message-ID: <20171124100848.1828-2-Zhiqiang.Hou@nxp.com> (raw)
In-Reply-To: <20171124100848.1828-1-Zhiqiang.Hou@nxp.com>
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
It's better to restore the addressing mode of the SPI flash
whenever remove the driver or reboot the system.
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
---
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 bc266f70a15b..801cbe99b059 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2713,6 +2713,14 @@ static void spi_nor_resume(struct mtd_info *mtd)
dev_err(dev, "resume() failed\n");
}
+void spi_nor_restore_addr_mode(struct spi_nor *nor)
+{
+ 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);
+}
+
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..fe9357da2049 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -398,5 +398,6 @@ struct spi_nor_hwcaps {
*/
int spi_nor_scan(struct spi_nor *nor, const char *name,
const struct spi_nor_hwcaps *hwcaps);
+void spi_nor_restore_addr_mode(struct spi_nor *nor);
#endif
--
2.14.1
next prev parent reply other threads:[~2017-11-24 10:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-24 10:08 [PATCH 0/2] mtd: m25p80: restore the addressing mode when stop using the flash Zhiqiang Hou
2017-11-24 10:08 ` Zhiqiang Hou [this message]
2017-12-01 8:52 ` [PATCH 1/2] mtd: spi-nor: add a API to restore the addressing mode Cyrille Pitchen
2017-12-01 10:06 ` Z.q. Hou
2017-11-24 10:08 ` [PATCH 2/2] mtd: m25p80: restore the addressing mode when stop using the flash Zhiqiang Hou
2017-12-01 8:57 ` Cyrille Pitchen
2017-12-01 10:06 ` Z.q. Hou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171124100848.1828-2-Zhiqiang.Hou@nxp.com \
--to=zhiqiang.hou@nxp.com \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).