mtd: nand: introduce a READMODE command
Subsystems (2)
cover mtd: nand: introduce a READMODE command
this series does some minor cleanup in nand_command_lp() and then introduces a NAND_CMD_READMODE opcode which is similar to the existing NAND_CMD_READ0 but does not imply NAND_CMD_READSTART
such a READMODE command is useful in preparation of the pending introduction of on-die-ECC support
I'd happily squash all the parts into a single patch if you feel that the preparatory steps are too tiny to stand alone
while the code changes are straight forward, the respective comments might be worth improving -- though I would not know how exactly, so feedback on this aspect is very welcome
Gerhard Sittig (3):
mtd: nand: comment update, the DEPLETE1 command has gone
mtd: nand: re-introduce command bits masking
mtd: nand: introduce a READMODE command
drivers/mtd/nand/nand_base.c | 14 +++++++++++--- include/linux/mtd/nand.h | 11 +++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/3 mtd: nand: comment update, the DEPLETE1 command has gone
update a comment in nand_command_lp() about specific requirements of individual commands, the DEPLETE1 command was removed in the past and the comment no longer applied
--- drivers/mtd/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/nand_base.c +1 -1
@@ -700,7 +700,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,/* * Program and erase have their own busy handlers status, sequential -* in, and deplete1 need no delay. +* in and status need no delay. */ switch (command) {
Signature · 1 line
1.7.10.4
PATCH 2/3 mtd: nand: re-introduce command bits masking
In reply to Gerhard Sittigre-introduce the mask operation which was removed in fb066adadd22 "mtd: nand_base: Removed unnecessary command masking" after the DEPLETE1 command has gone and the masking no longer was strictly required
keeping the operation here is cheap and does not influence behaviour as long as all passed in command opcodes are within a byte's range
pending introduction of on-die-ECC support needs a "READMODE" command, which shares a lot of the READ0 code path, yet would require duplication or open coding if "READMODE" aka "READ0 exclusively" cannot be told from "READPAGE" aka "the READ0 and READSTART sequence"
(the "READPAGE" and "READMODE" terms are coined in Micron datasheets)
--- drivers/mtd/nand/nand_base.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_base.c +8 -2
@@ -671,8 +671,14 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, command =NAND_CMD_READ0 ; } -/* Command latch cycle */ - chip->cmd_ctrl (mtd, command,NAND_NCE |NAND_CLE |NAND_CTRL_CHANGE ); +/* +* Command latch cycle, send the command's lower bits to the chip, +* followed by optional address specs and subsequent commands, +* while the command's higher bits might modify the below +* post-processing and delay logic +*/ + chip->cmd_ctrl (mtd, command &0xff , +NAND_NCE |NAND_CLE |NAND_CTRL_CHANGE );if (column !=-1 || page_addr !=-1 ) {int ctrl =NAND_CTRL_CHANGE |NAND_NCE |NAND_ALE ;
Signature · 1 line
1.7.10.4
PATCH 3/3 mtd: nand: introduce a READMODE command
In reply to Gerhard Sittigthe 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
--- drivers/mtd/nand/nand_base.c | 4 +++- include/linux/mtd/nand.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/mtd/nand/nand_base.c +3 -1
@@ -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 :
include/linux/mtd/nand.h +11 -0
@@ -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
Signature · 1 line
1.7.10.4
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
Quoted 4 lines · David Mosberger-Tang
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.
Quoted 1 line
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
Signature · 3 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [email protected]
Hi Gerhard,
Quoted 35 lines
From: Gerhard Sittig [mailto:[email protected]]
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 caseintroduce 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 codedcmd_ctrl()callsSigned-off-by Gerhard Sittig <[email protected]>---
drivers/mtd/nand/nand_base.c| 4 +++-include/linux/mtd/nand.h| 11 +++++++++++2 files changed, 14 insertions(+), 1 deletion(-)drivers/mtd/nand/nand_base.c +2
-1@@ -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) {
drivers/mtd/nand/nand_base.c static void nand_command_lp(struct mtd_info *mtd, unsigned int command, · line 723
Quoted 6 lines
drivers/mtd/nand/nand_base.c +1
-0@@ -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 <[email protected]>' patches. I think, NAND_CMD_READMODE should also be added to nand_command(), right ? With that please feel free to apply ..
with regards, pekon
Quoted 17 lines · Pekon
Hi Gerhard,
Quoted 14 lines
From: Gerhard Sittig [mailto:[email protected]]
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 caseintroduce 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 codedcmd_ctrl()calls
Quoted 4 lines
Quoted 1 line
[ ... ]
Thanks. This should help 'David Mosberger <[email protected]>' patches. I think,
NAND_CMD_READMODEshould also be added tonand_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.
Quoted 2 lines
With that please feel free to apply ..
Acked-by Pekon Gupta <[email protected]>
thank you, both for looking and for the ACK
virtually yours
Gerhard Sittig
Signature · 3 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [email protected]