From: Arnaud Mouiche <arnaud.mouiche@gmail.com>
To: Peter Pan <peterpandong@micron.com>,
boris.brezillon@free-electrons.com, richard@nod.at,
computersforpeace@gmail.com, linux-mtd@lists.infradead.org
Cc: peterpansjtu@gmail.com, linshunquan1@hisilicon.com
Subject: Re: [PATCH 10/11] nand: spi: Add generic SPI controller support
Date: Tue, 21 Feb 2017 10:25:36 +0100 [thread overview]
Message-ID: <b9e88910-c883-394d-09eb-0e29d0f297aa@gmail.com> (raw)
In-Reply-To: <1487664010-25926-11-git-send-email-peterpandong@micron.com>
On 21/02/2017 09:00, Peter Pan wrote:
> This commit supports to use generic spi controller
> as SPI NAND controller.
>
> Signed-off-by: Peter Pan <peterpandong@micron.com>
> ---
> drivers/mtd/nand/spi/Kconfig | 2 +
> drivers/mtd/nand/spi/Makefile | 1 +
> drivers/mtd/nand/spi/chips/Kconfig | 5 +
> drivers/mtd/nand/spi/chips/Makefile | 1 +
> drivers/mtd/nand/spi/chips/generic_spi.c | 269 +++++++++++++++++++++++++++++++
> 5 files changed, 278 insertions(+)
> create mode 100644 drivers/mtd/nand/spi/chips/Kconfig
> create mode 100644 drivers/mtd/nand/spi/chips/Makefile
> create mode 100644 drivers/mtd/nand/spi/chips/generic_spi.c
[...]
> +/*
> + * generic_spi_nand_cmd_fn - to process a command to send to the SPI-NAND
> + * by generic SPI bus
> + * @chip: SPI-NAND device structure
> + * @cmd: command structure
> + * Description:
> + * Set up the command buffer to send to the SPI controller.
> + * The command buffer has to initialized to 0.
> + */
> +static int generic_spi_nand_cmd_fn(struct spi_nand_chip *chip,
> + struct spi_nand_cmd *cmd)
> +{
> + struct spi_nand_cmd_cfg *cmd_cfg = spi_nand_get_cmd_cfg(cmd->cmd);
> + struct spi_message message;
> + struct spi_transfer x[3];
> + struct spi_device *spi = chip->priv;
> + u8 buf[SPINAND_MAX_ADDR_LEN];
> +
> + spi_message_init(&message);
> + memset(x, 0, sizeof(x));
> + x[0].len = 1;
> + x[0].tx_nbits = 1;
> + x[0].tx_buf = &cmd->cmd;
> + spi_message_add_tail(&x[0], &message);
> +
> + if (cmd_cfg->addr_bytes || cmd_cfg->dummy_bytes) {
> + if (cmd_cfg->addr_bytes > cmd->n_addr) {
> + memcpy(buf, cmd->addr, cmd->n_addr);
> + memset(cmd->addr, 0, cmd->n_addr);
> + memcpy(cmd->addr + cmd_cfg->addr_bytes - cmd->n_addr,
> + buf, cmd->n_addr);
> + }
> + x[1].len = cmd_cfg->addr_bytes + cmd_cfg->dummy_bytes;
> + x[1].tx_nbits = cmd_cfg->addr_bits;
> + x[1].tx_buf = cmd->addr;
> + spi_message_add_tail(&x[1], &message);
> + }
> + if (cmd->n_tx) {
> + x[2].len = cmd->n_tx;
> + x[2].tx_nbits = cmd_cfg->data_bits;
> + x[2].tx_buf = cmd->tx_buf;
> + spi_message_add_tail(&x[2], &message);
> + } else if (cmd->n_rx) {
> + x[2].len = cmd->n_rx;
> + x[2].rx_nbits = cmd_cfg->data_bits;
> + x[2].rx_buf = cmd->rx_buf;
> + spi_message_add_tail(&x[2], &message);
> + }
> + return spi_sync(spi, &message);
> +}
> +
>
Just a spi speed consideration.
All the spi drivers I've work with are not very good for scatter/gather,
and performance are dropping especially when you gather only 1 to 3
bytes parts.
But we can manage this optimization later anyway, with proper speed
figures, once the spinand framework will be merged.
Arnaud
next prev parent reply other threads:[~2017-02-21 9:26 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-21 7:59 [PATCH 00/11] Introduction to SPI NAND framework Peter Pan
2017-02-21 8:00 ` [PATCH 01/11] nand: Add SPI NAND cmd set and register definition Peter Pan
2017-02-21 8:44 ` Boris Brezillon
2017-02-21 9:16 ` Peter Pan
2017-02-21 8:00 ` [PATCH 02/11] nand: spi: create spi_nand_chip struct Peter Pan
2017-02-21 8:34 ` Boris Brezillon
2017-02-21 9:08 ` Peter Pan
2017-02-21 8:00 ` [PATCH 03/11] nand: spi: Abstract SPI NAND cmd set to functions Peter Pan
2017-02-21 9:01 ` Arnaud Mouiche
2017-02-21 9:40 ` Peter Pan
2017-02-21 10:22 ` Arnaud Mouiche
2017-02-21 10:50 ` Boris Brezillon
2017-02-21 9:06 ` Boris Brezillon
2017-02-21 9:27 ` Peter Pan
2017-02-21 8:00 ` [PATCH 04/11] nand: spi: Add read function support Peter Pan
2017-02-21 9:51 ` Boris Brezillon
2017-02-21 10:06 ` Peter Pan
2017-02-21 10:39 ` Boris Brezillon
2017-02-21 11:02 ` Boris Brezillon
2017-02-21 8:00 ` [PATCH 05/11] nand: spi: Add write " Peter Pan
2017-02-21 8:00 ` [PATCH 06/11] nand: spi: Add erase " Peter Pan
2017-02-21 8:00 ` [PATCH 07/11] nand: spi: Add init/release function Peter Pan
2017-02-21 8:00 ` [PATCH 08/11] nand: spi: Add bad block support Peter Pan
2017-02-21 8:00 ` [PATCH 09/11] nand: spi: Add BBT support Peter Pan
2017-02-21 8:00 ` [PATCH 10/11] nand: spi: Add generic SPI controller support Peter Pan
2017-02-21 8:03 ` Richard Weinberger
2017-02-21 8:17 ` Peter Pan
2017-02-21 9:25 ` Arnaud Mouiche [this message]
2017-02-21 9:37 ` Peter Pan
2017-02-21 8:00 ` [PATCH 11/11] nand: spi: Add arguments check for read/write Peter Pan
2017-02-21 8:05 ` [PATCH 00/11] Introduction to SPI NAND framework Richard Weinberger
2017-02-21 8:11 ` Peter Pan
2017-02-21 8:18 ` Peter Pan
2017-02-21 8:43 ` Boris Brezillon
2017-02-21 9:15 ` Peter Pan
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=b9e88910-c883-394d-09eb-0e29d0f297aa@gmail.com \
--to=arnaud.mouiche@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=linshunquan1@hisilicon.com \
--cc=linux-mtd@lists.infradead.org \
--cc=peterpandong@micron.com \
--cc=peterpansjtu@gmail.com \
--cc=richard@nod.at \
/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