diff mbox

[v1,3/3] mtd: nand: introduce a READMODE command

Message ID 1396100184-7110-4-git-send-email-gsi@denx.de
State Superseded
Headers show

Commit Message

Gerhard Sittig March 29, 2014, 1:36 p.m. UTC
the nand_command_lp() implementation derives a "READPAGE" sequence from
a passed in READ0 opcode, i.e. emits a sequence of READ0 _and_ READSTART
commands in this case

introduce a "READMODE" command which sends the READ0 opcode to the chip
exclusively and doesn't send the READSTART opcode

such a "READMODE" command is useful in the context of on-die-ECC support
where a sequence of READ0, READSTART, STATUS, READ0 is required; having
support for READMODE in the common nand_command_lp() routine avoids the
need for duplication and open coded cmd_ctrl() calls

Signed-off-by: Gerhard Sittig <gsi@denx.de>
---
 drivers/mtd/nand/nand_base.c |    4 +++-
 include/linux/mtd/nand.h     |   11 +++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Comments

David Mosberger-Tang March 31, 2014, 5:50 p.m. UTC | #1
Gerhard,

Thanks for putting these patches together!

Would it be cleaner to define READMODE like this:

#define NAND_CMD_READMODE      (0x100 | NAND_CMD_READ0)

?

I'm updating my patch to take advantage of READMODE.

  --david
Gerhard Sittig March 31, 2014, 7:23 p.m. UTC | #2
On Mon, 2014-03-31 at 11:50 -0600, David Mosberger-Tang wrote:
> 
> Would it be cleaner to define READMODE like this:
> 
> #define NAND_CMD_READMODE      (0x100 | NAND_CMD_READ0)

See 'git show 0be718e5525a' (the comments suggest that I took the
DEPLETE1 command as an inspiration), the code was not constructed
there either.  But I'm open to suggestions, let's see what others
think or whether there already is an established preference for
such aggregates.


> I'm updating my patch to take advantage of READMODE.

Can you identify other stuff that could get built in steps, to
chop the big change into pieces that are a little easier to
review and verify, to help getting your on-die-ECC introduction
accepted?

Will the better mapping to the current flow of command emission,
data fetching, and optional ECC handling become "a byproduct" of
constructing the total support from incremental building blocks?
Like starting with the "supported?" check, adding an "enabled?"
check, adding read/write support with mere boolean error
conditions, then add the re-read and bitflip count dance?

Splitting complex changes into logical groups helps in later
maintenance, too (bisection to identify and isolate problems,
extending or fixing clearly identified spots of restricted
functionality).


virtually yours
Gerhard Sittig
pekon gupta April 1, 2014, 6:56 a.m. UTC | #3
Hi Gerhard,

>From: Gerhard Sittig [mailto:gsi@denx.de]
>
>the nand_command_lp() implementation derives a "READPAGE" sequence from
>a passed in READ0 opcode, i.e. emits a sequence of READ0 _and_ READSTART
>commands in this case
>
>introduce a "READMODE" command which sends the READ0 opcode to the chip
>exclusively and doesn't send the READSTART opcode
>
>such a "READMODE" command is useful in the context of on-die-ECC support
>where a sequence of READ0, READSTART, STATUS, READ0 is required; having
>support for READMODE in the common nand_command_lp() routine avoids the
>need for duplication and open coded cmd_ctrl() calls
>
>Signed-off-by: Gerhard Sittig <gsi@denx.de>
>---
> drivers/mtd/nand/nand_base.c |    4 +++-
> include/linux/mtd/nand.h     |   11 +++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
>index 9ae99c1ba772..9a74bd06004b 100644
>--- a/drivers/mtd/nand/nand_base.c
>+++ b/drivers/mtd/nand/nand_base.c
>@@ -706,7 +706,8 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
>
> 	/*
> 	 * Program and erase have their own busy handlers status, sequential
>-	 * in and status need no delay.
>+	 * in and status need no delay, read mode just reverts back to
>+	 * data output after a status command and needs no read start.
> 	 */
> 	switch (command) {
>
>@@ -717,6 +718,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
> 	case NAND_CMD_SEQIN:
> 	case NAND_CMD_RNDIN:
> 	case NAND_CMD_STATUS:
>+	case NAND_CMD_READMODE:
> 		return;
>

Thanks. This should help 'David Mosberger <davidm@egauge.net>' patches.
I think, NAND_CMD_READMODE should also be added to nand_command(), right ?  
With that please feel free to apply ..
Acked-by: Pekon Gupta <pekon@ti.com>

with regards, pekon
Gerhard Sittig April 1, 2014, 2:10 p.m. UTC | #4
On Tue, 2014-04-01 at 06:56 +0000, Gupta, Pekon wrote:
> 
> Hi Gerhard,
> 
> >From: Gerhard Sittig [mailto:gsi@denx.de]
> >
> >the nand_command_lp() implementation derives a "READPAGE" sequence from
> >a passed in READ0 opcode, i.e. emits a sequence of READ0 _and_ READSTART
> >commands in this case
> >
> >introduce a "READMODE" command which sends the READ0 opcode to the chip
> >exclusively and doesn't send the READSTART opcode
> >
> >such a "READMODE" command is useful in the context of on-die-ECC support
> >where a sequence of READ0, READSTART, STATUS, READ0 is required; having
> >support for READMODE in the common nand_command_lp() routine avoids the
> >need for duplication and open coded cmd_ctrl() calls
> >
> >[ ... ]
> 
> Thanks. This should help 'David Mosberger <davidm@egauge.net>' patches.
> I think, NAND_CMD_READMODE should also be added to nand_command(), right ?  

Oh, that has slipped my attention.  I'll wait a few more days for
feedback, and update the series to support READMODE in both the
nand_command() as well as nand_command_lp() variants.  Callers
should not mind which one is the registered cmdfunc() callback.

> With that please feel free to apply ..
> Acked-by: Pekon Gupta <pekon@ti.com>

thank you, both for looking and for the ACK


virtually yours
Gerhard Sittig
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 9ae99c1ba772..9a74bd06004b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -706,7 +706,8 @@  static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
 
 	/*
 	 * Program and erase have their own busy handlers status, sequential
-	 * in and status need no delay.
+	 * in and status need no delay, read mode just reverts back to
+	 * data output after a status command and needs no read start.
 	 */
 	switch (command) {
 
@@ -717,6 +718,7 @@  static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
 	case NAND_CMD_SEQIN:
 	case NAND_CMD_RNDIN:
 	case NAND_CMD_STATUS:
+	case NAND_CMD_READMODE:
 		return;
 
 	case NAND_CMD_RESET:
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 32f8612469d8..234c80c1456a 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -106,6 +106,17 @@  extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 
 #define NAND_CMD_NONE		-1
 
+/*
+ * Pseudo commands, which map to the above "real" commands for the NAND chip
+ * yet involve slightly different behaviour in related software layers
+ *
+ * READMODE switches back from status output to data output after a
+ * previously emitted sequence of READ0, READSTART, and STATUS commands;
+ * actually it's a mere READ0 without the address specs and without the
+ * READSTART command which the READ0 convenience logic would imply
+ */
+#define NAND_CMD_READMODE	0x100
+
 /* Status bits */
 #define NAND_STATUS_FAIL	0x01
 #define NAND_STATUS_FAIL_N1	0x02