From: Mason Yang <masonccyang@mxic.com.tw>
To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: frieder.schrempf@kontron.de, tglx@linutronix.de, stefan@agner.ch,
juliensu@mxic.com.tw, allison@lohutok.net,
linux-kernel@vger.kernel.org, bbrezillon@kernel.org,
rfontana@redhat.com, linux-mtd@lists.infradead.org,
yuehaibing@huawei.com, s.hauer@pengutronix.de,
Mason Yang <masonccyang@mxic.com.tw>
Subject: [PATCH v3 4/4] mtd: rawnand: Add support Macronix deep power down mode
Date: Tue, 3 Mar 2020 15:21:24 +0800 [thread overview]
Message-ID: <1583220084-10890-5-git-send-email-masonccyang@mxic.com.tw> (raw)
In-Reply-To: <1583220084-10890-1-git-send-email-masonccyang@mxic.com.tw>
Macronix AD series support deep power down mode for a minimum
power consumption state.
Patch nand_suspend() & nand_resume() by Macronix specific deep
power down mode command and exit it.
Signed-off-by: Mason Yang <masonccyang@mxic.com.tw>
---
drivers/mtd/nand/raw/nand_macronix.c | 74 ++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c
index a4cd12c..ca46ec1 100644
--- a/drivers/mtd/nand/raw/nand_macronix.c
+++ b/drivers/mtd/nand/raw/nand_macronix.c
@@ -6,6 +6,7 @@
* Author: Boris Brezillon <boris.brezillon@free-electrons.com>
*/
+#include "linux/delay.h"
#include "internals.h"
#define MACRONIX_READ_RETRY_BIT BIT(0)
@@ -15,6 +16,8 @@
#define MXIC_BLOCK_PROTECTION_ALL_LOCK 0x38
#define MXIC_BLOCK_PROTECTION_ALL_UNLOCK 0x0
+#define MXIC_CMD_POWER_DOWN 0xB9
+
struct nand_onfi_vendor_macronix {
u8 reserved;
u8 reliability_func;
@@ -162,6 +165,76 @@ static void macronix_nand_block_protection_support(struct nand_chip *chip)
chip->unlock_area = mxic_nand_unlock;
}
+static int nand_power_down_op(struct nand_chip *chip)
+{
+ int ret;
+
+ if (nand_has_exec_op(chip)) {
+ struct nand_op_instr instrs[] = {
+ NAND_OP_CMD(MXIC_CMD_POWER_DOWN, 0),
+ };
+
+ struct nand_operation op = NAND_OPERATION(chip->cur_cs, instrs);
+
+ ret = nand_exec_op(chip, &op);
+ if (ret)
+ return ret;
+
+ } else {
+ chip->legacy.cmdfunc(chip, MXIC_CMD_POWER_DOWN, -1, -1);
+ }
+
+ return 0;
+}
+
+static int mxic_nand_suspend(struct nand_chip *chip)
+{
+ int ret;
+
+ nand_select_target(chip, 0);
+ ret = nand_power_down_op(chip);
+ if (ret < 0)
+ pr_err("Suspending MXIC NAND chip failed (%d)\n", ret);
+ nand_deselect_target(chip);
+
+ return ret;
+}
+
+static void mxic_nand_resume(struct nand_chip *chip)
+{
+ /*
+ * Toggle #CS pin to resume NAND device and don't care
+ * of the others CLE, #WE, #RE pins status.
+ * A NAND controller ensure it is able to assert/de-assert #CS
+ * by sending any byte over the NAND bus.
+ * i.e.,
+ * NAND power down command or reset command w/o R/B# status checking.
+ */
+ nand_select_target(chip, 0);
+ nand_power_down_op(chip);
+ /* The minimum of a recovery time tRDP is 35 us */
+ usleep_range(35, 100);
+ nand_deselect_target(chip);
+}
+
+static void macronix_nand_deep_power_down_support(struct nand_chip *chip)
+{
+ int i;
+ static const char * const deep_power_down_dev[] = {
+ "MX30UF1G28AD",
+ "MX30UF2G28AD",
+ "MX30UF4G28AD",
+ };
+
+ i = match_string(deep_power_down_dev, ARRAY_SIZE(deep_power_down_dev),
+ chip->parameters.model);
+ if (i < 0)
+ return;
+
+ chip->_suspend = mxic_nand_suspend;
+ chip->_resume = mxic_nand_resume;
+}
+
static int macronix_nand_init(struct nand_chip *chip)
{
if (nand_is_slc(chip))
@@ -170,6 +243,7 @@ static int macronix_nand_init(struct nand_chip *chip)
macronix_nand_fix_broken_get_timings(chip);
macronix_nand_onfi_init(chip);
macronix_nand_block_protection_support(chip);
+ macronix_nand_deep_power_down_support(chip);
return 0;
}
--
1.9.1
next prev parent reply other threads:[~2020-03-03 7:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 7:21 [PATCH v3 0/4] mtd: rawnand: Add support Macronix Block Portection & Deep Power Down mode Mason Yang
2020-03-03 7:21 ` [PATCH v3 1/4] mtd: rawnand: Add support manufacturer specific lock/unlock operation Mason Yang
2020-03-10 18:30 ` Miquel Raynal
2020-03-10 19:27 ` Boris Brezillon
2020-03-11 2:40 ` masonccyang
2020-03-11 7:25 ` Miquel Raynal
2020-03-03 7:21 ` [PATCH v3 2/4] mtd: rawnand: Add support Macronix Block Protection function Mason Yang
2020-03-03 7:21 ` [PATCH v3 3/4] mtd: rawnand: Add support manufacturer specific suspend/resume operation Mason Yang
2020-03-10 18:30 ` Miquel Raynal
2020-03-10 19:33 ` Boris Brezillon
2020-03-11 5:40 ` masonccyang
2020-03-11 7:43 ` Miquel Raynal
2020-03-11 7:56 ` Boris Brezillon
2020-03-12 1:45 ` masonccyang
2020-03-10 19:39 ` Boris Brezillon
2020-03-10 19:41 ` Boris Brezillon
2020-03-11 6:13 ` masonccyang
2020-03-11 8:01 ` Boris Brezillon
2020-03-12 1:48 ` masonccyang
2020-03-03 7:21 ` Mason Yang [this message]
2020-03-09 13:14 ` [PATCH v3 0/4] mtd: rawnand: Add support Macronix Block Portection & Deep Power Down mode Miquel Raynal
2020-03-10 2:30 ` masonccyang
2020-03-10 7:44 ` Miquel Raynal
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=1583220084-10890-5-git-send-email-masonccyang@mxic.com.tw \
--to=masonccyang@mxic.com.tw \
--cc=allison@lohutok.net \
--cc=bbrezillon@kernel.org \
--cc=frieder.schrempf@kontron.de \
--cc=juliensu@mxic.com.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=rfontana@redhat.com \
--cc=richard@nod.at \
--cc=s.hauer@pengutronix.de \
--cc=stefan@agner.ch \
--cc=tglx@linutronix.de \
--cc=vigneshr@ti.com \
--cc=yuehaibing@huawei.com \
/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).