linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Ladislav Michl <ladis@linux-mips.org>
Cc: linux-mtd@lists.infradead.org,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Nicolas Ferre <nicolas.ferre@microchip.com>
Subject: Re: atmel-nand-controller: NAND chip selects?
Date: Mon, 11 Jun 2018 22:30:51 +0200	[thread overview]
Message-ID: <20180611223051.09129302@bbrezillon> (raw)
In-Reply-To: <20180611144214.GA19449@lenoch>

On Mon, 11 Jun 2018 16:42:14 +0200
Ladislav Michl <ladis@linux-mips.org> wrote:

> On Mon, Jun 11, 2018 at 01:21:31PM +0200, Boris Brezillon wrote:
> > On Mon, 11 Jun 2018 13:04:25 +0200
> > Ladislav Michl <ladis@linux-mips.org> wrote:
> >   
> > > Consider there are more NAND chips connected to the same lines and only nCE
> > > (connected to GPIO line one per each chip) is used to select them.
> > > How is driver supposed to work in such situation?
> > > Common memory region cannot be requested multiple times as well as the
> > > same gpio for R/B cannot be requested.  
> > 
> > I thought you could request several times the same GPIO if it's in input
> > mode, but maybe I'm wrong.  
> 
> Well, it does not seem to work:
> atmel-nand-controller 10000000.ebi:nand-controller: Failed to get R/B gpio (err = -16)
> 
> > > Something as davinci_nand for
> > > memory region? Use 'ranges' property? How should one express in DT gpio
> > > is shared between child nodes?  
> > 
> > For both problems, the solution is to reserve the resources at the NAND
> > controller level instead of the NAND level. It's pretty easy for the CS
> > memory range, because the driver can easily detect when the same CS is
> > used by different NAND chips. It's a bit more complicated for the R/B
> > pins.  
> 
> Do you mean something like this?
> 
> 		ebi: ebi@10000000 {
> 			status = "okay";
> 			pinctrl-0 = <&pinctrl_nand_cs &pinctrl_nand_cs1 &pinctrl_nand_rb>;
> 			pinctrl-names = "default";
> 
> 			nand_controller: nand-controller {
> 				status = "okay";
> /*				reg = <0x3 0x0 0x800000>; */
> 				nand@3,0 {
> 					reg = <0x3 0x0 0x800000>;
> 					rb-gpios = <&pioC 13 GPIO_ACTIVE_HIGH>;
> 					cs-gpios = <&pioC 8 GPIO_ACTIVE_HIGH>;
> 					nand-bus-width = <8>;
> 					nand-ecc-mode = "soft";
> 					nand-ecc-algo = "bch";
> 					nand-ecc-strength = <8>;
> 					nand-on-flash-bbt;
> 					label = "atmel_nand";
> 				};
> 				nand@3,1 {
> 					reg = <0x3 0x0 0x800000>;
> 					rb-gpios = <&pioC 13 GPIO_ACTIVE_HIGH>;
> 					cs-gpios = <&pioC 14 GPIO_ACTIVE_HIGH>;
> 					nand-bus-width = <8>;
> 					nand-ecc-mode = "soft";
> 					nand-ecc-algo = "bch";
> 					nand-ecc-strength = <8>;
> 					nand-on-flash-bbt;
> 					label = "atmel_nand";
> 				};
> 			};
> 		};

I thought a bit more about your problem, and maybe we should have this
kind of representation:

	ebi: ebi@10000000 {
		status = "okay";
		pinctrl-0 = <&pinctrl_nand_cs &pinctrl_nand_cs1 &pinctrl_nand_rb>;
		pinctrl-names = "default";

		nand_controller: nand-controller {
			status = "okay";
			reg = <0x3 0x0 0x800000>;
			rb-gpios = <&pioC 13 GPIO_ACTIVE_HIGH>;
			cs-gpios = <&pioC 8 GPIO_ACTIVE_HIGH>,
				   <&pioC 14 GPIO_ACTIVE_HIGH>;

			#address-cells = <1>;
			#size-cells = <0>;

			cs0-ebi-id = <3>;
			cs0-cs-gpio = <0>;
			cs0-rb-gpio = <0>;
			cs1-ebi-id = <3>;
			cs1-cs-gpio = <1>;
			cs1-rb-gpio = <0>;

			nand@0 {
				reg = <0>;
				nand-bus-width = <8>;
				nand-ecc-mode = "soft";
				nand-ecc-algo = "bch";
				nand-ecc-strength = <8>;
				nand-on-flash-bbt;
				label = "mynand0";
			};

			nand@1 {
				reg = <1>;
				nand-bus-width = <8>;
				nand-ecc-mode = "soft";
				nand-ecc-algo = "bch";
				nand-ecc-strength = <8>;
				nand-on-flash-bbt;
				label = "mynand1";
			};
 		};
	};

This way we have all resources attached to the NAND controller, and a
translation from virutal CS-ids to physical resources done through the
csY-xxx props.

Of course, that means patching the DT bindings doc and the EBI + NAND
controller drivers to support this new representation.

  parent reply	other threads:[~2018-06-11 20:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-11 11:04 atmel-nand-controller: NAND chip selects? Ladislav Michl
2018-06-11 11:21 ` Boris Brezillon
2018-06-11 14:42   ` Ladislav Michl
2018-06-11 18:22     ` Boris Brezillon
2018-06-11 20:30     ` Boris Brezillon [this message]
2018-06-11 21:31       ` Ladislav Michl

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=20180611223051.09129302@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=ladis@linux-mips.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=nicolas.ferre@microchip.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).