From: Matthieu CASTET <matthieu.castet@parrot.com>
To: linux-mtd@lists.infradead.org, linux-omap@vger.kernel.org
Cc: dedekind1@gmail.com, Matthieu CASTET <matthieu.castet@parrot.com>
Subject: [PATCH 2/3] mtd nand : add NAND_BUSWIDTH_AUTO to autodetect bus width
Date: Tue, 6 Nov 2012 11:51:44 +0100 [thread overview]
Message-ID: <1352199105-30215-2-git-send-email-matthieu.castet@parrot.com> (raw)
In-Reply-To: <1352199105-30215-1-git-send-email-matthieu.castet@parrot.com>
The driver call nand_scan_ident in 8 bit mode, then
readid or onfi detection are done (and detect bus width).
The driver should update its bus width before calling nand_scan_tail.
This work because readid and onfi are read work 8 byte mode.
Note that nand_scan_ident send command (NAND_CMD_RESET, NAND_CMD_READID, NAND_CMD_PARAM), address and read data
The ONFI specificication is not very clear for x16 device if high byte of address should be driven to 0,
but according to [1] it should be ok to not drive it during autodetection.
[1]
3.3.2. Target Initialization
[...]
The Read ID and Read Parameter Page commands only use the lower 8-bits of the data bus.
The host shall not issue commands that use a word data width on x16 devices until the host
determines the device supports a 16-bit data bus width in the parameter page.
Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
---
drivers/mtd/nand/nand_base.c | 14 +++++++++-----
include/linux/mtd/nand.h | 7 +++++++
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index abeb8e9..c90ef66 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3245,11 +3245,15 @@ ident_done:
break;
}
- /*
- * Check, if buswidth is correct. Hardware drivers should set
- * chip correct!
- */
- if (busw != (chip->options & NAND_BUSWIDTH_16)) {
+ if (chip->options & NAND_BUSWIDTH_AUTO) {
+ WARN_ON(chip->options & NAND_BUSWIDTH_16);
+ chip->options |= busw;
+ nand_set_defaults(chip, busw);
+ } else if (busw != (chip->options & NAND_BUSWIDTH_16)) {
+ /*
+ * Check, if buswidth is correct. Hardware drivers should set
+ * chip correct!
+ */
pr_info("NAND device: Manufacturer ID:"
" 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id,
*dev_id, nand_manuf_ids[maf_idx].name, mtd->name);
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 24e9159..c8518d4 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -219,6 +219,13 @@ typedef enum {
#define NAND_OWN_BUFFERS 0x00020000
/* Chip may not exist, so silence any errors in scan */
#define NAND_SCAN_SILENT_NODEV 0x00040000
+/*
+ * Autodetect nand buswidth with readid/onfi.
+ * This suppose the driver will configure the hardware in 8 bits mode
+ * when calling nand_scan_ident, and update its configuration
+ * before calling nand_scan_tail.
+ */
+#define NAND_BUSWIDTH_AUTO 0x00080000
/* Options set by nand scan */
/* Nand scan has allocated controller struct */
--
1.7.10.4
next prev parent reply other threads:[~2012-11-06 10:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-06 10:51 [PATCH 1/3] mtd nand : onfi need to be probed in 8 bits mode Matthieu CASTET
2012-11-06 10:51 ` Matthieu CASTET [this message]
2012-11-30 13:21 ` [PATCH 2/3] mtd nand : add NAND_BUSWIDTH_AUTO to autodetect bus width Artem Bityutskiy
2012-11-06 10:51 ` [PATCH 3/3] omap3 nand : use NAND_BUSWIDTH_AUTO Matthieu CASTET
2012-11-06 12:37 ` Igor Grinberg
2012-11-06 16:47 ` Matthieu CASTET
2012-11-06 18:40 ` Tony Lindgren
2012-11-16 8:22 ` Artem Bityutskiy
2012-11-22 17:48 ` Matthieu CASTET
2012-12-03 10:20 ` [PATCH 1/3] mtd nand : onfi need to be probed in 8 bits mode Artem Bityutskiy
2012-12-24 0:29 ` Paul Walmsley
2013-01-02 9:51 ` Matthieu CASTET
2013-01-03 17:10 ` Paul Walmsley
2013-01-16 14:28 ` Matthieu CASTET
2013-01-16 17:15 ` Paul Walmsley
2013-01-22 2:27 ` Paul Walmsley
2013-02-06 23:21 ` Paul Walmsley
2013-02-07 9:47 ` Matthieu CASTET
2013-03-01 14:02 ` Matthieu CASTET
2013-04-02 18:28 ` Paul Walmsley
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=1352199105-30215-2-git-send-email-matthieu.castet@parrot.com \
--to=matthieu.castet@parrot.com \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
/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).