From: Arnaud Mouiche <arnaud.mouiche@gmail.com>
To: Peter Pan <peterpansjtu@gmail.com>
Cc: Peter Pan <peterpandong@micron.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
Richard Weinberger <richard@nod.at>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org,
"linshunquan (A)" <linshunquan1@hisilicon.com>
Subject: Re: [PATCH 03/11] nand: spi: Abstract SPI NAND cmd set to functions
Date: Tue, 21 Feb 2017 11:22:52 +0100 [thread overview]
Message-ID: <434dfc69-1358-3e51-9ff4-d8e07deb0161@gmail.com> (raw)
In-Reply-To: <CAAyFORJtSxNp-yVF0cRz0R1B3Z9xBm72Wv9Ph3boQERHsafGwQ@mail.gmail.com>
On 21/02/2017 10:40, Peter Pan wrote:
> Hi Arnaud,
>
> On Tue, Feb 21, 2017 at 5:01 PM, Arnaud Mouiche
> <arnaud.mouiche@gmail.com> wrote:
>> Hello Peter.
>> First thank you for this effort to finally bring the spinand framework back
>> on stage.
>>
>> On 21/02/2017 09:00, Peter Pan wrote:
>>> This commit abstracts basic SPI NAND commands to
>>> functions in spi-nand-base.c. Because command sets
>>> have difference by vendors, we create spi-nand-cmd.c
>>> to define this difference by command config table.
>>>
>>> [...]
>>> +
>>> +/**
>>> + * spi_nand_read_page_to_cache - send command 13h to read data from Nand
>>> + * to cache
>>> + * @chip: SPI-NAND device structure
>>> + * @page_addr: page to read
>>> + */
>>> +static int spi_nand_read_page_to_cache(struct spi_nand_chip *chip,
>>> + u32 page_addr)
>>> +{
>>> + struct spi_nand_cmd cmd;
>>> +
>>> + memset(&cmd, 0, sizeof(struct spi_nand_cmd));
>>> + cmd.cmd = SPINAND_CMD_PAGE_READ;
>>> + cmd.n_addr = 3;
>>> + cmd.addr[0] = (u8)(page_addr >> 16);
>>> + cmd.addr[1] = (u8)(page_addr >> 8);
>>> + cmd.addr[2] = (u8)page_addr;
>>> +
>>> + return spi_nand_issue_cmd(chip, &cmd);
>>> +}
>>
>> Just a question. Don't you try to map too exactly the spi_nand_cmd to the
>> internal micron SPI command ?
>> Why "cmd.addr" should be a byte array, and not a u32, leaving each chip to
>> details to handle the u32 to SPI byte stream mapping.
>>
>>
>>
>>> +
>>> +/**
>>> + * spi_nand_read_from_cache - read data out from cache register
>>> + * @chip: SPI-NAND device structure
>>> + * @page_addr: page to read
>>> + * @column: the location to read from the cache
>>> + * @len: number of bytes to read
>>> + * @rbuf: buffer held @len bytes
>>> + * Description:
>>> + * Command can be 03h, 0Bh, 3Bh, 6Bh, BBh, EBh
>>> + * The read can specify 1 to (page size + spare size) bytes of data
>>> read at
>>> + * the corresponding locations.
>>> + * No tRd delay.
>>> + */
>>> +static int spi_nand_read_from_cache(struct spi_nand_chip *chip,
>>> + u32 page_addr, u32 column, size_t len, u8 *rbuf)
>>> +{
>>> + struct nand_device *nand = &chip->base;
>>> + struct spi_nand_cmd cmd;
>>> +
>>> + memset(&cmd, 0, sizeof(struct spi_nand_cmd));
>>> + cmd.cmd = chip->read_cache_op;
>>> + cmd.n_addr = 2;
>>> + cmd.addr[0] = (u8)(column >> 8);
>>> + if (chip->options & SPINAND_NEED_PLANE_SELECT)
>>> + cmd.addr[0] |= (u8)((nand_page_to_eraseblock(nand,
>>> page_addr)
>>> + & 0x1) << 4);
>>> + cmd.addr[1] = (u8)column;
>>> + cmd.n_rx = len;
>>> + cmd.rx_buf = rbuf;
>>> +
>>> + return spi_nand_issue_cmd(chip, &cmd);
>>> +}
>>> +
>> Some reasons to handle the plane concept (Micron specific), and even move
>> the fact that it touch the bit 4 of cdm.addr[0], in common code ?
> Let me try to remove this from framework when separate controller and device
> related code. Any suggestion on this?
I know, Micron was the first spinand chipset available, will be the
first chipset supported by this framework, but it is already not so
generic regarding to the page addressing compared with winbond, esmt,
gigadevice or micronix...
But may be this the sign that "generic_spi_nand_cmd_fn" if "too"
straight in your implementation and just try to map the "struct
spi_nand_cmd" into the SPI frame without any more place for chip
specialization.
I guess I would prefer to see multiple 'command primitive' inside each
chip structures (eg. chip->read_from_cache() and so on).
But in the meantime, spinand chipset are made to be generic and behave
mostly the same way, which would make this primitive declaration a
little bit redundant.
The other way is to already have a "Micron_spi_nand_cmd_fn" that will
patch the address fields for "read cache op", and then call the
"generic_spi_nand_cmd_fn" to finalize the job.
Arnaud
>
> Thanks,
> Peter Pan
next prev parent reply other threads:[~2017-02-21 10:23 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 [this message]
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
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=434dfc69-1358-3e51-9ff4-d8e07deb0161@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