mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] MX21: Fix nand booting
@ 2010-03-22 14:57 Ivo Clarysse
  2010-03-23  7:48 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Ivo Clarysse @ 2010-03-22 14:57 UTC (permalink / raw)
  To: barebox

Fixes booting from NAND on i.MX21-based systems.

Signed-off-by: Ivo Clarysse <ivo.clarysse@gmail.com>
---
diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
index afd5637..2eac6fe 100644
--- a/drivers/nand/nand_imx.c
+++ b/drivers/nand/nand_imx.c
@@ -1085,12 +1085,18 @@ void __nand_boot_init imx_nand_load_image(void
*dest, int size)
 	writew(0x4, host.regs + NFC_WRPROT);

 	tmp = readw(host.regs + NFC_CONFIG1);
+#ifdef CONFIG_ARCH_IMX21
+	tmp |= NFC_ECC_EN;
+	tmp &= ~NFC_INT_MSK;
+	writew(tmp, host.regs + NFC_CONFIG1);
+#else
 	tmp |= NFC_ECC_EN | NFC_INT_MSK;
 	if (nfc_is_v21())
 		/* currently no support for 218 byte OOB with stronger ECC */
 		tmp |= NFC_ECC_MODE;
 	tmp &= ~NFC_SP_EN;
 	writew(tmp, host.regs + NFC_CONFIG1);
+#endif /* CONFIG_ARCH_IMX21 */

 	if (nfc_is_v21()) {
 		if (host.pagesize_2k) {

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] MX21: Fix nand booting
  2010-03-22 14:57 [PATCH] MX21: Fix nand booting Ivo Clarysse
@ 2010-03-23  7:48 ` Sascha Hauer
       [not found]   ` <ba216b431003240217k4348191fn5b651bb36c9dbf47@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2010-03-23  7:48 UTC (permalink / raw)
  To: Ivo Clarysse; +Cc: barebox

Hi Ivo,

On Mon, Mar 22, 2010 at 03:57:47PM +0100, Ivo Clarysse wrote:
> Fixes booting from NAND on i.MX21-based systems.
> 
> Signed-off-by: Ivo Clarysse <ivo.clarysse@gmail.com>
> ---
> diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
> index afd5637..2eac6fe 100644
> --- a/drivers/nand/nand_imx.c
> +++ b/drivers/nand/nand_imx.c
> @@ -1085,12 +1085,18 @@ void __nand_boot_init imx_nand_load_image(void
> *dest, int size)
>  	writew(0x4, host.regs + NFC_WRPROT);
> 
>  	tmp = readw(host.regs + NFC_CONFIG1);
> +#ifdef CONFIG_ARCH_IMX21
> +	tmp |= NFC_ECC_EN;
> +	tmp &= ~NFC_INT_MSK;
> +	writew(tmp, host.regs + NFC_CONFIG1);
> +#else

I wonder that this patch helps you. Does your NAND work properly after
starting? I ask because in imxnd_probe() NFC_INT_MSK gets set again.

I tested on i.MX27 that clearing this bit doesn't harm, so I think we do
not need the ifdef but can clear it on every SoC, like this:

diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
index afd5637..5c910d8 100644
--- a/drivers/nand/nand_imx.c
+++ b/drivers/nand/nand_imx.c
@@ -1085,11 +1085,11 @@ void __nand_boot_init imx_nand_load_image(void *dest, int size)
 	writew(0x4, host.regs + NFC_WRPROT);
 
 	tmp = readw(host.regs + NFC_CONFIG1);
-	tmp |= NFC_ECC_EN | NFC_INT_MSK;
+	tmp |= NFC_ECC_EN;
 	if (nfc_is_v21())
 		/* currently no support for 218 byte OOB with stronger ECC */
 		tmp |= NFC_ECC_MODE;
-	tmp &= ~NFC_SP_EN;
+	tmp &= ~(NFC_SP_EN | NFC_INT_MSK);
 	writew(tmp, host.regs + NFC_CONFIG1);
 
 	if (nfc_is_v21()) {
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] MX21: Fix nand booting
       [not found]   ` <ba216b431003240217k4348191fn5b651bb36c9dbf47@mail.gmail.com>
@ 2010-03-24  9:19     ` Ivo Clarysse
  0 siblings, 0 replies; 3+ messages in thread
From: Ivo Clarysse @ 2010-03-24  9:19 UTC (permalink / raw)
  To: barebox

On Tue, Mar 23, 2010 at 8:48 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
[...]
> I wonder that this patch helps you. Does your NAND work properly after
> starting? I ask because in imxnd_probe() NFC_INT_MSK gets set again.

I agree that it's weird.  But it does help.  Apparantly, on i.MX21, NFC_INT_MSK
must not be set for the first (non-reset) command, otherwise NFC_INT in
NFC_CONFIG2 will never get set.

After booting, other NAND accesses do work, for instance the NAND
device ID readout and the scanning for bad blocks:

barebox 2010.03.0-00094-gc6f4ea0-dirty (Mar 22 2010 - 10:02:13)

Board: Freescale i.MX21 ADS
cfi_probe: cfi_flash base: 0xc8000000 size: 0x02000000
NAND device: Manufacturer ID: 0xec, Chip ID: 0x36 (Samsung NAND 64MiB
1,8V 8-bit)
Scanning device for bad blocks
Bad eraseblock 2133 at 0x02154000
Malloc space: 0xc0c00000 -> 0xc1000000 (size  4 MB)
Stack space : 0xc0bf8000 -> 0xc0c00000 (size 32 kB)
Open /dev/env0 No such file or directory
no valid environment found on /dev/env0. Using default environment
running /env/bin/init...
barebox:/

> I tested on i.MX27 that clearing this bit doesn't harm, so I think we do
> not need the ifdef but can clear it on every SoC, like this:
>
> diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
> index afd5637..5c910d8 100644
> --- a/drivers/nand/nand_imx.c
> +++ b/drivers/nand/nand_imx.c
> @@ -1085,11 +1085,11 @@ void __nand_boot_init imx_nand_load_image(void *dest, int size)
>        writew(0x4, host.regs + NFC_WRPROT);
>
>        tmp = readw(host.regs + NFC_CONFIG1);
> -       tmp |= NFC_ECC_EN | NFC_INT_MSK;
> +       tmp |= NFC_ECC_EN;
>        if (nfc_is_v21())
>                /* currently no support for 218 byte OOB with stronger ECC */
>                tmp |= NFC_ECC_MODE;
> -       tmp &= ~NFC_SP_EN;
> +       tmp &= ~(NFC_SP_EN | NFC_INT_MSK);
>        writew(tmp, host.regs + NFC_CONFIG1);
>
>        if (nfc_is_v21()) {
> --

Tested this patch on an MX21ADS, and this is sufficient.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2010-03-24  9:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-22 14:57 [PATCH] MX21: Fix nand booting Ivo Clarysse
2010-03-23  7:48 ` Sascha Hauer
     [not found]   ` <ba216b431003240217k4348191fn5b651bb36c9dbf47@mail.gmail.com>
2010-03-24  9:19     ` Ivo Clarysse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox