From: Michael Trimarchi <michael@amarulasolutions.com>
To: u-boot@lists.denx.de, Ye Li <ye.li@nxp.com>, Han Xu <han.xu@nxp.com>
Cc: Andrea Scian <andrea.scian@dave.eu>, Stefano Babic <sbabic@denx.de>
Subject: [PATCH] mtd: mxs_nand_spl: fix nand_command protocol violation
Date: Tue, 21 Jun 2022 22:05:10 +0200 [thread overview]
Message-ID: <20220621200510.15988-1-michael@amarulasolutions.com> (raw)
From: Andrea Scian <andrea.scian@dave.eu>
mxs_nand_command() implementation assume that it's working with a
LP NAND, which is a common case nowadays and thus uses two bytes
for column address.
However this is wrong for NAND_CMD_READID and NAND_CMD_PARAM, which
expects only one byte of column address, even for LP NANDs.
This leads to ONFI detection problem with some NAND manufacturer (like
Winbond) but not with others (like Samsung and Spansion)
We fix this with a simple workaround to avoid the 2nd byte column address
for those two commands.
Also align the code with nand_base to support 16 bit devices.
Tested on an iMX6SX device with:
* Winbond W29N04GVSIAA
* Spansion S34ML04G100TF100
* Samsung K9F4G08U00
Tested on imx8mn device with:
* Windbond W29N04GV
Signed-off-by: Andrea Scian <andrea.scian@dave.eu>
CC: Stefano Babic <sbabic@denx.de>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
drivers/mtd/nand/raw/mxs_nand_spl.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c
index 2bfb181007..3daacbb330 100644
--- a/drivers/mtd/nand/raw/mxs_nand_spl.c
+++ b/drivers/mtd/nand/raw/mxs_nand_spl.c
@@ -29,8 +29,20 @@ static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,
/* Serially input address */
if (column != -1) {
+ /* Adjust columns for 16 bit buswidth */
+ if (chip->options & NAND_BUSWIDTH_16 &&
+ !nand_opcode_8bits(command))
+ column >>= 1;
chip->cmd_ctrl(mtd, column, NAND_ALE);
- chip->cmd_ctrl(mtd, column >> 8, NAND_ALE);
+
+ /*
+ * Assume LP NAND here, so use two bytes column address
+ * but not for CMD_READID and CMD_PARAM, which require
+ * only one byte column address
+ */
+ if (command != NAND_CMD_READID &&
+ command != NAND_CMD_PARAM)
+ chip->cmd_ctrl(mtd, column >> 8, NAND_ALE);
}
if (page_addr != -1) {
chip->cmd_ctrl(mtd, page_addr, NAND_ALE);
--
2.25.1
next reply other threads:[~2022-06-21 20:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 20:05 Michael Trimarchi [this message]
2022-06-29 6:49 ` [PATCH] mtd: mxs_nand_spl: fix nand_command protocol violation Michael Nazzareno Trimarchi
2022-06-29 12:28 ` Fabio Estevam
2022-06-29 13:47 ` Tom Rini
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=20220621200510.15988-1-michael@amarulasolutions.com \
--to=michael@amarulasolutions.com \
--cc=andrea.scian@dave.eu \
--cc=han.xu@nxp.com \
--cc=sbabic@denx.de \
--cc=u-boot@lists.denx.de \
--cc=ye.li@nxp.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