devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.aribaud@3adev.fr>
To: Stefan Agner <stefan@agner.ch>, sebastian@breakpoint.cc
Cc: dwmw2@infradead.org, computersforpeace@gmail.com,
	robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	shawn.guo@linaro.org, kernel@pengutronix.de,
	boris.brezillon@free-electrons.com, marb@ixxat.de,
	aaron@tastycactus.com, bpringlemeir@gmail.com,
	linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Bill Pringlemeir <bpringlemeir@nbsps.com>
Subject: Re: [PATCH v8 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
Date: Thu, 30 Jul 2015 22:11:25 +0200	[thread overview]
Message-ID: <20150730221125.08b5b2cf.albert.aribaud@3adev.fr> (raw)
In-Reply-To: <36ffdc45494ab888ba375ff8478864ad@agner.ch>

Hi Stefan,

Le Thu, 30 Jul 2015 19:00:38 +0200, Stefan Agner <stefan@agner.ch> a
écrit :

> Hi Albert,
> 
> On 2015-07-30 18:13, Albert ARIBAUD wrote:
> > Hi Stefan,
> > 
> > Le Mon, 27 Jul 2015 18:42:41 +0200, Stefan Agner <stefan@agner.ch> a
> > écrit :
> > 
> >> This driver supports Freescale NFC (NAND flash controller) found on
> >> Vybrid (VF610), MPC5125, MCF54418 and Kinetis K70. The driver has
> >> been tested on 8-bit and 16-bit NAND interface and supports ONFI
> >> parameter page reading.
> >>
> >> [...]
> >>
> >> diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
> >> new file mode 100644
> >> index 0000000..0da500e
> >> --- /dev/null
> >> +++ b/drivers/mtd/nand/vf610_nfc.c
> >> @@ -0,0 +1,640 @@
> >> [...]
> > 
> > ... about line 708:
> > 
> >> +	err = devm_request_irq(nfc->dev, irq, vf610_nfc_irq, 0, DRV_NAME, mtd);
> >> +	if (err) {
> >> +		dev_err(nfc->dev, "Error requesting IRQ!\n");
> >> +		goto error;
> >> +	}
> >> +
> >> +	vf610_nfc_init_controller(nfc);
> > 
> > The call above is too early: vf610_nfc_init_controller() will test
> > for (nfc->chip.options & NAND_BUSWIDTH_16) but this option bit is only
> > set once nand_scan_ident() below has been run.
> > 
> > This has the effect that even when the DT node specifies a 16-bit wide
> > bus, the controller is configured for 8-bit mode at this point, which of
> > course causes read failures. I've experienced this with a Vybrid SoC
> > and a Micron MT29F4G16ABADAH4 16-bit NAND.
> > 
> >> +	/* first scan to find the device and get the page size */
> >> +	if (nand_scan_ident(mtd, 1, NULL)) {
> >> +		err = -ENXIO;
> >> +		goto error;
> >> +	}
> > 
> > Placing the call to vf610_nfc_init_controller() here, after the call
> > to nand_scan_ident() rather than before it, fixed the issue for me.
> 
> Hm, since nand_scan_ident access the devices we actually want the
> controller initialized before we access it the first time. In most
> cases, the boot loader/boot ROM probably initialized the controller in a
> way that identifying the chip should work non the less. However, the
> safe way would be to initialize it before calling nand_scan_ident.

Correct -- there is a mutual dependency here between nand_scan_ident()
and vf610_nfc_init_controller(). Anyway, my call order switch was only
a hack to get things working.

> However, I see your point regarding bus width: With the change to
> nand_dt_init, we have that information after nand_scan_ident. There is
> actually more: Also the HW ECC settings are not yet parsed at that
> point, hence the ECC status and offset will not be initialized right. 
> 
> We could call the whole initialization twice. This would configure 8-Bit
> mode for the 16-Bit devices, but during initialization this is anyway
> the required default (ONFI). Or we split it up and call it something
> like vf610_nfc_preinit_controller and vf610_nfc_init_controller.
> 
> What do you think?

I think creating a vf610_nfc_preinit_controller() function with no
dependency on the DT is the cleaner option.

> --
> Stefan

Cordialement,
Albert ARIBAUD
3ADEV

  reply	other threads:[~2015-07-30 20:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 16:42 [PATCH v8 0/5] mtd: nand: vf610_nfc: Freescale NFC for VF610 Stefan Agner
2015-07-27 16:42 ` [PATCH v8 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others Stefan Agner
2015-07-30 16:13   ` Albert ARIBAUD
     [not found]     ` <20150730181321.3bd38db7.albert.aribaud-iEu9NFBzPZE@public.gmane.org>
2015-07-30 17:00       ` Stefan Agner
2015-07-30 20:11         ` Albert ARIBAUD [this message]
2015-07-27 16:42 ` [PATCH v8 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support Stefan Agner
     [not found] ` <1438015365-15685-1-git-send-email-stefan-XLVq0VzYD2Y@public.gmane.org>
2015-07-27 16:42   ` [PATCH v8 3/5] mtd: nand: vf610_nfc: add device tree bindings Stefan Agner
2015-07-28  1:05     ` Shawn Guo
2015-07-27 16:42   ` [PATCH v8 4/5] ARM: dts: vf610twr: add NAND flash controller peripherial Stefan Agner
2015-07-27 16:42 ` [PATCH v8 5/5] ARM: dts: vf-colibri: enable NAND flash controller Stefan Agner
2015-07-28  1:07 ` [PATCH v8 0/5] mtd: nand: vf610_nfc: Freescale NFC for VF610 Shawn Guo

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=20150730221125.08b5b2cf.albert.aribaud@3adev.fr \
    --to=albert.aribaud@3adev.fr \
    --cc=aaron@tastycactus.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=bpringlemeir@gmail.com \
    --cc=bpringlemeir@nbsps.com \
    --cc=computersforpeace@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marb@ixxat.de \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sebastian@breakpoint.cc \
    --cc=shawn.guo@linaro.org \
    --cc=stefan@agner.ch \
    /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).