linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <bbrezillon@kernel.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>,
	linux-mtd <linux-mtd@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [Question] setup_data_interface() hook when switching to a different type of NAND chip
Date: Fri, 1 Feb 2019 16:53:13 +0100	[thread overview]
Message-ID: <20190201165218.22a0ac21@bbrezillon> (raw)
In-Reply-To: <CAK7LNAQLzvW-zDaR8qkDaxEXxmiCj7XQDK-G57sPhvZu1_eBdA@mail.gmail.com>

Hi Masahiro,

On Fri, 1 Feb 2019 19:27:46 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> Hi.
> 
> 
> When I was looking into the NAND controller/chips separation,
> this question popped up in my mind.
> 
> 
> Commit 2d472aba15ff169 provides us a more flexibility
> about the controller/chips connection.
> The connected NAND chips do not need to be homogeneous
> any more.
> 
> 
> My question is about the ->setup_data_interface() hook
> when switching between NAND chips with different speed (timing mode).
> 
> 
> Think about the case below:
> 
> {
>         compatible = "foo-nand-controller";
>         reg = <...>;
>         #address-cells = <1>;
>         #size-cells = <0>;
> 
>         nand@0 {
>                   reg = <0>;
>                   /* Slow NAND chip */
>         }
> 
>         nand@1 {
>                   reg = <1>;
>                   /* Fast NAND chip */
>         }
> 
> }
> 
> 
> 
> In this case, two devices /dev/mtdblock0 and /dev/mtdblock1
> will appear.
> 
> If a user gets access to those two devices in turns,
> I think ->setup_data_interface() should be invoked somehow
> in order to update the timing registers on the controller side.
> 
> Currently, ->setup_data_interface() is invoked in nand_scan_tail()
> and that's it.
> 
> So, both nand@0 and nand@1 are accessed by the timing mode of nand@1
> (assuming nand@0 and nand@1 are initialized in this order)
> 
> 
> Of course, it depends on the controller.
> 
> If a controller has a register set for every chip select,
> the hardware will be able to change the access speed automatically.
> 
> 
> I think most of controllers just have a single set of timing registers.
> So, when switching between different types of chips,
> the driver must update the timing registers.
> 
> 
> If this is a worthwhile usecase,
> should it be taken care of by the NAND framework,
> or by drivers ?
> 
> 
> I just thought we could do something in
> nand_get_device() / nand_release_device().
> 
> 
> If this should be done per driver,
> drivers can update registers in select_target or select_chip.
> 
> 
> Thought?

It should be done by the driver in its select_target() handler.
Actually, it's already done like that in several drivers (marvell,
sunxi, ...).
->setup_data_interface() is not required to apply timings right away.
What it should do is convert the NAND timings into controller timings.
Of course, if the controller has one set of timing regs per CS, the
driver can apply timings right away, but when that's not the case,
controller timings should be stored in the private nand data and
applied when the chip is selected.

Feel free to enhance the ->setup_data_interface() doc if you think it's
not clear enough.

Regards,

Boris

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2019-02-01 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 10:27 [Question] setup_data_interface() hook when switching to a different type of NAND chip Masahiro Yamada
2019-02-01 15:53 ` Boris Brezillon [this message]
2019-02-02  7:43   ` Masahiro Yamada

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=20190201165218.22a0ac21@bbrezillon \
    --to=bbrezillon@kernel.org \
    --cc=boris.brezillon@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=yamada.masahiro@socionext.com \
    /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).