From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Arnaud Mouiche <arnaud.mouiche@gmail.com>
Cc: Peter Pan <peterpansjtu@gmail.com>,
Peter Pan <peterpandong@micron.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:50:59 +0100 [thread overview]
Message-ID: <20170221115059.7908939a@bbrezillon> (raw)
In-Reply-To: <434dfc69-1358-3e51-9ff4-d8e07deb0161@gmail.com>
On Tue, 21 Feb 2017 11:22:52 +0100
Arnaud Mouiche <arnaud.mouiche@gmail.com> wrote:
> 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).
I'm not against the idea, but I'd prefer to see these operations in a
separate struct:
struct spinand_manufacturer_ops {
int (*read_from_cache)();
/* ... */
};
struct spinand_device {
/* ... */
struct {
struct spinand_manufacturer_ops *ops;
void *priv;
/* ... */
} manufacturer;
};
> 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.
Well, for the generic case, you could either provide generic helpers
that could be used by NAND manufacturer drivers in their
spinand_manufacturer_ops definition, or you could let the core do
if (!nand->manufacturer->ops || !nand->manufacturer->ops->func)
default_func();
next prev parent reply other threads:[~2017-02-21 10:51 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 [this message]
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=20170221115059.7908939a@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=arnaud.mouiche@gmail.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