public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Arnaud Mouiche <arnaud.mouiche@gmail.com>
To: Peter Pan <peterpansjtu@gmail.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: 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 v2 2/6] nand: spi: add basic operations support
Date: Fri, 10 Mar 2017 08:50:55 +0100	[thread overview]
Message-ID: <a132543b-59c5-7397-7261-47fca2a39583@gmail.com> (raw)
In-Reply-To: <CAAyFORKO3ZRXORiTKjBEnmBx4NCbnQa5dKdM7ANg8tvX92NEYw@mail.gmail.com>



On 10/03/2017 02:58, Peter Pan wrote:
> On Fri, Mar 10, 2017 at 1:09 AM, Arnaud Mouiche
> <arnaud.mouiche@gmail.com> wrote:
>>
>> On 09/03/2017 07:02, Boris Brezillon wrote:
>>> [...]
>>>>>
>>>>>> diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
>>>>>> index f3d0351..ee447c1 100644
>>>>>> --- a/include/linux/mtd/spinand.h
>>>>>> +++ b/include/linux/mtd/spinand.h
>>>>>> @@ -135,6 +135,8 @@ struct spinand_manufacturer_ops {
>>>>>>         bool(*detect)(struct spinand_device *chip);
>>>>>>         int (*init)(struct spinand_device *chip);
>>>>>>         void (*cleanup)(struct spinand_device *chip);
>>>>>> +     void (*build_column_addr)(struct spinand_device *chip,
>>>>>> +                               struct spinand_op *op, u32 page, u32
>>>>>> column);
>>>>> Okay, I think Arnaud was right, maybe we should have vendor specific
>>>>> ops for basic operations like ->prepare_read/write_op(), instead of
>>>>> having these ->get_dummy() and ->build_column_addr() hooks.
>>>>> Or maybe just a ->prepare_op() hook that can prepare things for any
>>>>> basic operation (read, write, ...).
>>>> I prefer ->prepare_read_op() and ->prepare_write_op. Fix this in v3
>>> I'd like to have Arnaud's feedback on this. Can you wait a bit before
>>> sending a new version?
>>
>> ->prepare_read_op() and ->prepare_write_op
>> looks fine to me.
> Arnaud and Boris,
>
> For prepare_read/write_op, should we put common code in
> spinand_read_from_cache(), spinand_program_data_to_cache() of spinandbase.c
> and then prepare_read/write_op hook just do some fixing ? Code likes this:
>        static int spinand_read_from_cache(struct spinand_device *chip,
>                    u32 page_addr, u32 column, size_t len, u8 *rbuf)
>       {
>             struct spinand_op cmd;
>
>             spinand_op_init(&cmd);
>             cmd.cmd = chip->read_cache_op;
>             cmd.n_addr = 2;
>             cmd.addr[0] = (u8)(column >> 8);
>             cmd.addr[1] = (u8)column;
>             cmd.addr_nbits = spinand_get_address_bits(chip->read_cache_op);
>             cmd.n_rx = len;
>             cmd.rx_buf = rbuf;
>             cmd.data_nbits = spinand_get_data_bits(chip->read_cache_op);
>             if (chip->manufacturer.manu->ops->prepare_op)
>                    chip->manufacturer.manu->ops->prepare_op(chip, &cmd,
>
>        page_addr, column);
>
>            return spinand_exec_cmd(chip, &cmd);
>      }

Personally, I would let ops->prepare_op do all the

            cmd.n_addr = 2;
            cmd.addr[0] = (u8)(column >> 8);
            cmd.addr[1] = (u8)column;
            cmd.addr_nbits = spinand_get_address_bits(chip->read_cache_op);

part unconditionally.
But it is a matter of taste. I would not cost a lot to change the 
behavior if a 2 byte address would not be the main case with future devices.

Arnaud
>
>> FYI: I have prepared a imx6sl board which can run vanilla mtd/master
>> kernels.
>> On this board, I can swap the various spinand samples I have:
>> - Micron (the one supported by those patches)
>> - winbond
>> - macronix
>> - ESMT
>>
>> Looking forward to test v3 ;)
> Arnaud,
>
> Thanks for your help in advance!
>
>
>> Arnaud
>>

  reply	other threads:[~2017-03-10  7:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01  8:52 [PATCH v2 0/6] Introduction to SPI NAND framework Peter Pan
2017-03-01  8:52 ` [PATCH v2 1/6] nand: spi: Add init/release function Peter Pan
2017-03-01  9:58   ` Boris Brezillon
2017-03-03  8:37     ` Peter Pan
2017-03-03  9:28       ` Boris Brezillon
2017-03-03  9:37         ` Arnaud Mouiche
2017-03-03 10:00           ` Boris Brezillon
2017-03-03 10:12             ` Arnaud Mouiche
2017-03-03 10:17               ` Boris Brezillon
2017-03-10  7:50     ` Peter Pan
2017-03-10  9:13       ` Arnaud Mouiche
2017-03-01 13:21   ` Thomas Petazzoni
2017-03-03  8:40     ` Peter Pan
2017-03-01  8:52 ` [PATCH v2 2/6] nand: spi: add basic operations support Peter Pan
2017-03-07 17:57   ` Boris Brezillon
2017-03-09  1:43     ` Peter Pan
2017-03-09  6:02       ` Boris Brezillon
2017-03-09 17:09         ` Arnaud Mouiche
2017-03-10  1:58           ` Peter Pan
2017-03-10  7:50             ` Arnaud Mouiche [this message]
2017-03-01  8:52 ` [PATCH v2 3/6] nand: spi: Add bad block support Peter Pan
2017-03-08  7:23   ` Boris Brezillon
2017-03-08  7:59     ` Peter Pan
2017-03-01  8:52 ` [PATCH v2 4/6] nand: spi: Add BBT support Peter Pan
2017-03-08  8:31   ` Boris Brezillon
2017-03-09  1:58     ` Peter Pan
2017-03-09  6:12       ` Boris Brezillon
2017-03-01  8:52 ` [PATCH v2 5/6] nand: spi: add Micron spi nand support Peter Pan
2017-03-08  8:32   ` Boris Brezillon
2017-03-09  1:59     ` Peter Pan
2017-03-01  8:52 ` [PATCH v2 6/6] nand: spi: Add generic SPI controller support Peter Pan
2017-03-08  8:44   ` Boris Brezillon
2017-03-09  2:02     ` Peter Pan
2017-03-09  6:06       ` 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=a132543b-59c5-7397-7261-47fca2a39583@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