From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Cc: linux-mtd <linux-mtd@lists.infradead.org>,
Richard Weinberger <richard@nod.at>, Mason <slash.tmp@free.fr>,
Sebastian Frias <sf84@laposte.net>
Subject: Re: [RFC] Special handling for NAND_CMD_PAGEPROG and NAND_CMD_READ0
Date: Wed, 9 Nov 2016 19:49:03 +0100 [thread overview]
Message-ID: <20161109194903.1c4ee5a3@bbrezillon> (raw)
In-Reply-To: <58236370.1050105@sigmadesigns.com>
On Wed, 9 Nov 2016 18:57:04 +0100
Marc Gonzalez <marc_gonzalez@sigmadesigns.com> wrote:
> Sample code to generate some discussion around having the framework
> send I/O commands (for read_page and write_page) when it is dealing
> with "high-level" NFCs that send the commands themselves.
> ---
> drivers/mtd/nand/nand_base.c | 6 ++++--
> drivers/mtd/nand/tango_nand.c | 7 ++++++-
> include/linux/mtd/nand.h | 6 ++++++
> 3 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 50cdf37cb8e4..b4149101342c 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -1970,7 +1970,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
> __func__, buf);
>
> read_retry:
> - chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
> + if (!(chip->options & NAND_FOO))
> + chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
>
You'll have to patch the standard implementations provided by the core
(nand_read/write_page_xx()) to send these READ0/SEQIN/PAGEPROG commands
when the NAND_FOO flag is set.
> /*
> * Now read the page into the buffer. Absent an error,
> @@ -2681,7 +2682,8 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
>
> if (!cached || !NAND_HAS_CACHEPROG(chip)) {
>
> - chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
> + if (!(chip->options & NAND_FOO))
> + chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
If you ask the core to not send NAND_CMD_PAGEPROG, it should also not
send the SEQIN command.
> status = chip->waitfunc(mtd, chip);
> /*
> * See if operation failed and additional status checks are
> diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
> index 74e39a92771c..d3679fdf2020 100644
> --- a/drivers/mtd/nand/tango_nand.c
> +++ b/drivers/mtd/nand/tango_nand.c
> @@ -401,13 +401,17 @@ static int raw_write(struct nand_chip *chip, const u8 *buf, const u8 *oob)
> static int tango_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
> uint8_t *buf, int oob_required, int page)
> {
> + chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
> return raw_read(chip, buf, chip->oob_poi);
> }
>
> static int tango_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
> const uint8_t *buf, int oob_required, int page)
> {
> - return raw_write(chip, buf, chip->oob_poi);
> + /* what about NAND_CMD_SEQIN ? */
You should send SEQIN as well, and patch the core to not send it when
NAND_FOO is set.
> + raw_write(chip, buf, chip->oob_poi);
> + chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
> + return 0;
> }
>
> static int tango_read_oob(struct mtd_info *mtd, struct nand_chip *chip, int page)
> @@ -527,6 +531,7 @@ static int chip_init(struct device *dev, struct device_node *np)
> chip->setup_data_interface = tango_set_timings;
> chip->options = NAND_USE_BOUNCE_BUFFER
> | NAND_NO_SUBPAGE_WRITE
> + | NAND_FOO
> | NAND_WAIT_TCCS;
> chip->controller = &nfc->hw;
> tchip->base = nfc->pbus_base + (cs * 256);
> diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
> index 06d0c9d740f7..fd8968f3ccca 100644
> --- a/include/linux/mtd/nand.h
> +++ b/include/linux/mtd/nand.h
> @@ -220,6 +220,12 @@ enum nand_ecc_algo {
> */
> #define NAND_WAIT_TCCS 0x00200000
>
> +/*
> + * Controller sends NAND_CMD_PAGEPROG (write_page) and NAND_CMD_READ0 (read_page)
> + * therefore the framework should not send these commands.
> + */
> +#define NAND_FOO 0x00400000
> +
Nice name :-).
> /* Options set by nand scan */
> /* Nand scan has allocated controller struct */
> #define NAND_CONTROLLER_ALLOC 0x80000000
next prev parent reply other threads:[~2016-11-09 18:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 17:57 [RFC] Special handling for NAND_CMD_PAGEPROG and NAND_CMD_READ0 Marc Gonzalez
2016-11-09 18:02 ` Marc Gonzalez
2016-11-09 18:49 ` Boris Brezillon [this message]
2016-11-09 20:18 ` Mason
[not found] ` <58248886.9080906@sigmadesigns.com>
2016-11-10 15:29 ` [RFC v2] " Boris Brezillon
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=20161109194903.1c4ee5a3@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=linux-mtd@lists.infradead.org \
--cc=marc_gonzalez@sigmadesigns.com \
--cc=richard@nod.at \
--cc=sf84@laposte.net \
--cc=slash.tmp@free.fr \
/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).