linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [NAND] driver extension to support NAND on TQM85xx modules
@ 2008-05-30  6:36 Wolfgang Grandegger
  2008-05-30 12:50 ` Anton Vorontsov
  2008-05-30 13:07 ` Kumar Gala
  0 siblings, 2 replies; 6+ messages in thread
From: Wolfgang Grandegger @ 2008-05-30  6:36 UTC (permalink / raw)
  To: Linuxppc-dev

This patch extends the FSL UPM NAND driver from Anton Vorontsov to
support for the TQM85xx modules. Unfortunately, the hardware does
not support the R/B pins of the NAND chip and therefore the specified
maximum delay time must used. It therefore re-introduces the chip-delay
property.

Note: this patch is based on a patch Anton Vorontsov posted to this list:
      See http://ozlabs.org/pipermail/linuxppc-dev/2008-April/055587.html.
      It should show up mainstream soon. 

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 drivers/mtd/nand/Kconfig   |    2 +-
 drivers/mtd/nand/fsl_upm.c |   30 +++++++++++++++++++++---------
 include/linux/of_gpio.h    |    2 +-
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 5076faf..3a665c8 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -380,7 +380,7 @@ config MTD_NAND_FSL_ELBC
 
 config MTD_NAND_FSL_UPM
 	tristate "Support for NAND on Freescale UPM"
-	depends on MTD_NAND && OF_GPIO && (PPC_83xx || PPC_85xx)
+	depends on MTD_NAND && (PPC_83xx || PPC_85xx)
 	select FSL_LBC
 	help
 	  Enables support for NAND Flash chips wired onto Freescale PowerPC
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index f91c950..3694837 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -36,6 +36,7 @@ struct fsl_upm_nand {
 	uint8_t upm_cmd_offset;
 	void __iomem *io_base;
 	int rnb_gpio;
+	int chip_delay;
 };
 
 #define to_fsl_upm_nand(mtd) container_of(mtd, struct fsl_upm_nand, mtd)
@@ -44,11 +45,15 @@ static int fun_chip_ready(struct mtd_info *mtd)
 {
 	struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
 
-	if (gpio_get_value(fun->rnb_gpio))
-		return 1;
-
-	dev_vdbg(fun->dev, "busy\n");
-	return 0;
+	if (fun->rnb_gpio >= 0) {
+		if (!gpio_get_value(fun->rnb_gpio)) {
+			dev_vdbg(fun->dev, "busy\n");
+			return 0;
+		}
+	} else {
+		udelay(fun->chip_delay);
+	}
+	return 1;
 }
 
 static void fun_wait_rnb(struct fsl_upm_nand *fun)
@@ -58,10 +63,11 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun)
 	if (fun->rnb_gpio >= 0) {
 		while (--cnt && !fun_chip_ready(&fun->mtd))
 			cpu_relax();
+		if (!cnt)
+			dev_err(fun->dev, "tired waiting for RNB\n");
+	} else {
+		fun_chip_ready(&fun->mtd);
 	}
-
-	if (!cnt)
-		dev_err(fun->dev, "tired waiting for RNB\n");
 }
 
 static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
@@ -129,7 +135,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
 	fun->chip.IO_ADDR_R = fun->io_base;
 	fun->chip.IO_ADDR_W = fun->io_base;
 	fun->chip.cmd_ctrl = fun_cmd_ctrl;
-	fun->chip.chip_delay = 50;
+	fun->chip.chip_delay = fun->chip_delay;
 	fun->chip.read_byte = fun_read_byte;
 	fun->chip.read_buf = fun_read_buf;
 	fun->chip.write_buf = fun_write_buf;
@@ -233,6 +239,12 @@ static int __devinit fun_probe(struct of_device *ofdev,
 		goto err2;
 	}
 
+	prop = of_get_property(ofdev->node, "chip-delay", NULL);
+	if (prop)
+		fun->chip_delay = *prop;
+	else
+		fun->chip_delay = 50;
+
 	fun->io_base = devm_ioremap_nocache(&ofdev->dev, io_res.start,
 					  io_res.end - io_res.start + 1);
 	if (!fun->io_base) {
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 2ee97e9..67db101 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -15,7 +15,7 @@
 #define __LINUX_OF_GPIO_H
 
 #include <linux/errno.h>
-#include <asm/gpio.h>
+#include <linux/gpio.h>
 
 #ifdef CONFIG_OF_GPIO
 
-- 
1.5.4.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] [NAND] driver extension to support NAND on TQM85xx modules
  2008-05-30  6:36 [PATCH] [NAND] driver extension to support NAND on TQM85xx modules Wolfgang Grandegger
@ 2008-05-30 12:50 ` Anton Vorontsov
  2008-06-04  9:52   ` Wolfgang Grandegger
  2008-05-30 13:07 ` Kumar Gala
  1 sibling, 1 reply; 6+ messages in thread
From: Anton Vorontsov @ 2008-05-30 12:50 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: Linuxppc-dev

On Fri, May 30, 2008 at 08:36:32AM +0200, Wolfgang Grandegger wrote:
> This patch extends the FSL UPM NAND driver from Anton Vorontsov to
> support for the TQM85xx modules. Unfortunately, the hardware does
> not support the R/B pins of the NAND chip and therefore the specified
> maximum delay time must used. It therefore re-introduces the chip-delay
> property.
> 
> Note: this patch is based on a patch Anton Vorontsov posted to this list:
>       See http://ozlabs.org/pipermail/linuxppc-dev/2008-April/055587.html.
>       It should show up mainstream soon. 

Personally, I like this patch. But OF people should approve "chip-delay"
property. Though, the whole UPM NAND bindings are in the air still.

> --- a/include/linux/of_gpio.h
> +++ b/include/linux/of_gpio.h
> @@ -15,7 +15,7 @@
>  #define __LINUX_OF_GPIO_H
>  
>  #include <linux/errno.h>
> -#include <asm/gpio.h>
> +#include <linux/gpio.h>

This should be done separately.

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [NAND] driver extension to support NAND on TQM85xx modules
  2008-05-30  6:36 [PATCH] [NAND] driver extension to support NAND on TQM85xx modules Wolfgang Grandegger
  2008-05-30 12:50 ` Anton Vorontsov
@ 2008-05-30 13:07 ` Kumar Gala
  2008-05-30 13:57   ` Wolfgang Grandegger
  1 sibling, 1 reply; 6+ messages in thread
From: Kumar Gala @ 2008-05-30 13:07 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: Linuxppc-dev


On May 30, 2008, at 1:36 AM, Wolfgang Grandegger wrote:

> This patch extends the FSL UPM NAND driver from Anton Vorontsov to
> support for the TQM85xx modules. Unfortunately, the hardware does
> not support the R/B pins of the NAND chip and therefore the specified
> maximum delay time must used. It therefore re-introduces the chip- 
> delay
> property.
>
> Note: this patch is based on a patch Anton Vorontsov posted to this  
> list:
>      See http://ozlabs.org/pipermail/linuxppc-dev/2008-April/055587.html 
> .
>      It should show up mainstream soon.
>
> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
> ---
> drivers/mtd/nand/Kconfig   |    2 +-
> drivers/mtd/nand/fsl_upm.c |   30 +++++++++++++++++++++---------
> include/linux/of_gpio.h    |    2 +-
> 3 files changed, 23 insertions(+), 11 deletions(-)

You really need to CC the MTD list as this should go via them.  Also  
you're adding a new property and there should be updates to booting-w- 
o-f for it.

- k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [NAND] driver extension to support NAND on TQM85xx modules
  2008-05-30 13:07 ` Kumar Gala
@ 2008-05-30 13:57   ` Wolfgang Grandegger
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Grandegger @ 2008-05-30 13:57 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Linuxppc-dev

Kumar Gala wrote:
> 
> On May 30, 2008, at 1:36 AM, Wolfgang Grandegger wrote:
> 
>> This patch extends the FSL UPM NAND driver from Anton Vorontsov to
>> support for the TQM85xx modules. Unfortunately, the hardware does
>> not support the R/B pins of the NAND chip and therefore the specified
>> maximum delay time must used. It therefore re-introduces the chip-delay
>> property.
>>
>> Note: this patch is based on a patch Anton Vorontsov posted to this list:
>>      See http://ozlabs.org/pipermail/linuxppc-dev/2008-April/055587.html.
>>      It should show up mainstream soon.
>>
>> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
>> ---
>> drivers/mtd/nand/Kconfig   |    2 +-
>> drivers/mtd/nand/fsl_upm.c |   30 +++++++++++++++++++++---------
>> include/linux/of_gpio.h    |    2 +-
>> 3 files changed, 23 insertions(+), 11 deletions(-)
> 
> You really need to CC the MTD list as this should go via them.  Also
> you're adding a new property and there should be updates to
> booting-w-o-f for it.

OK. There are various patches pending for booting-w-o-f including
"[PATCH 6/7] [POWERPC] booting-without-of: add FHCI USB, FSL MCU,
FSL UPM and GPIO LEDs bindings" from Anton. What tree should the patches
for NAND and 85xx be based on for kernel inclusion?

Wolfgang.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [NAND] driver extension to support NAND on TQM85xx modules
  2008-05-30 12:50 ` Anton Vorontsov
@ 2008-06-04  9:52   ` Wolfgang Grandegger
  2008-06-04 11:58     ` Anton Vorontsov
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Grandegger @ 2008-06-04  9:52 UTC (permalink / raw)
  To: avorontsov; +Cc: Linuxppc-dev

Hi Anton,

Anton Vorontsov wrote:
> On Fri, May 30, 2008 at 08:36:32AM +0200, Wolfgang Grandegger wrote:
>> This patch extends the FSL UPM NAND driver from Anton Vorontsov to
>> support for the TQM85xx modules. Unfortunately, the hardware does
>> not support the R/B pins of the NAND chip and therefore the specified
>> maximum delay time must used. It therefore re-introduces the chip-delay
>> property.
>>
>> Note: this patch is based on a patch Anton Vorontsov posted to this list:
>>       See http://ozlabs.org/pipermail/linuxppc-dev/2008-April/055587.html.
>>       It should show up mainstream soon. 
> 
> Personally, I like this patch. But OF people should approve "chip-delay"
> property. Though, the whole UPM NAND bindings are in the air still.
> 
>> --- a/include/linux/of_gpio.h
>> +++ b/include/linux/of_gpio.h
>> @@ -15,7 +15,7 @@
>>  #define __LINUX_OF_GPIO_H
>>  
>>  #include <linux/errno.h>
>> -#include <asm/gpio.h>
>> +#include <linux/gpio.h>
> 
> This should be done separately.

I have a technical question. Do you understand why the Linux NAND FSL UPM 
driver needs polling the R/B pin when writing out a sequence of bytes:

static void fun_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
{
	struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
	int i;

	for (i = 0; i < len; i++) {
		out_8(fun->chip.IO_ADDR_W, buf[i]);
		fun_wait_rnb(fun);
	}
}

We do not need that in the corresponding U-Boot driver. On my board (not 
having the R/B pin connected) I need a small delay of approx. 100 ns
instead to get it working properly.

Wolfgang.

 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [NAND] driver extension to support NAND on TQM85xx modules
  2008-06-04  9:52   ` Wolfgang Grandegger
@ 2008-06-04 11:58     ` Anton Vorontsov
  0 siblings, 0 replies; 6+ messages in thread
From: Anton Vorontsov @ 2008-06-04 11:58 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: Linuxppc-dev

On Wed, Jun 04, 2008 at 11:52:44AM +0200, Wolfgang Grandegger wrote:
> Hi Anton,
> 
> Anton Vorontsov wrote:
> > On Fri, May 30, 2008 at 08:36:32AM +0200, Wolfgang Grandegger wrote:
> >> This patch extends the FSL UPM NAND driver from Anton Vorontsov to
> >> support for the TQM85xx modules. Unfortunately, the hardware does
> >> not support the R/B pins of the NAND chip and therefore the specified
> >> maximum delay time must used. It therefore re-introduces the chip-delay
> >> property.
> >>
> >> Note: this patch is based on a patch Anton Vorontsov posted to this list:
> >>       See http://ozlabs.org/pipermail/linuxppc-dev/2008-April/055587.html.
> >>       It should show up mainstream soon. 
> > 
> > Personally, I like this patch. But OF people should approve "chip-delay"
> > property. Though, the whole UPM NAND bindings are in the air still.
> > 
> >> --- a/include/linux/of_gpio.h
> >> +++ b/include/linux/of_gpio.h
> >> @@ -15,7 +15,7 @@
> >>  #define __LINUX_OF_GPIO_H
> >>  
> >>  #include <linux/errno.h>
> >> -#include <asm/gpio.h>
> >> +#include <linux/gpio.h>
> > 
> > This should be done separately.
> 
> I have a technical question. 

> Do you understand

Nope. According to NAND specs (Samsung and HYNIX), NAND should not
assert "busy" when we're sending seq data. We should poll the R/B pin
only after final "programm command".

But I saw a chip that was asserting it in seqinput phase anyway, and not
polling R/B did cause write errors. I can't recall if it was Samsung or
HYNIX chip, surely not ST Micro though.

> why the Linux NAND FSL UPM 
> driver needs polling the R/B pin when writing out a sequence of bytes:
> 
> static void fun_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
> {
> 	struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
> 	int i;
> 
> 	for (i = 0; i < len; i++) {
> 		out_8(fun->chip.IO_ADDR_W, buf[i]);
> 		fun_wait_rnb(fun);
> 	}
> }
> 
> We do not need that in the corresponding U-Boot driver. 

This is probably because I "optimized" the driver without further
testing it on other NAND chips.

> On my board (not 
> having the R/B pin connected) I need a small delay of approx. 100 ns
> instead to get it working properly.

This proves that we indeed need some R/B waiting (or delays in case of
no R/B pin) in the write_buf.

p.s. Other possibility though is that MTD subsystem issues some
commands inbetween seqinput, for example, "read status" command is
permitted, but NAND should not assert R/B pin for this command anyway.
:-/

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-06-04 11:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-30  6:36 [PATCH] [NAND] driver extension to support NAND on TQM85xx modules Wolfgang Grandegger
2008-05-30 12:50 ` Anton Vorontsov
2008-06-04  9:52   ` Wolfgang Grandegger
2008-06-04 11:58     ` Anton Vorontsov
2008-05-30 13:07 ` Kumar Gala
2008-05-30 13:57   ` Wolfgang Grandegger

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).