Hi!
I haven't had time to test the following patches but currently don't know
when to find time to finish this work. Maybe somebody is interested in
testing them.
When we load the kernel from NAND flash in u-boot, we should also use
better NAND timings in order to get the best possible boot time.
WARNING: Please don't apply the patches to the git tree yet, they're untested.
--
- Harald Welte <[EMAIL PROTECTED]> http://openmoko.org/
============================================================================
Software for the world's first truly open Free Software mobile phone
>From c7f7e92f7d50ab22c6319ef92da1db8d1fc02f99 Mon Sep 17 00:00:00 2001
From: Harald Welte <[EMAIL PROTECTED]>
Date: Tue, 21 Oct 2008 23:48:58 +0200
Subject: [PATCH] [S3C24xx] NAND: allow for board-specific NAND timings
This patch introduces s3c24xx_nand_init() with some arguments
for the NAND chip related timing. __board_nand_init will
use the most conservative timings possible.
If there is a board-defined board_nand_init, it can call
s3c24xx_nand_init() using the board-specific optimal timings.
Signed-off-by: Harald Welte <[EMAIL PROTECTED]>
---
cpu/arm920t/s3c24x0/nand.c | 33 ++++++++++++++++++++++++---------
include/s3c24x0.h | 2 ++
2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/cpu/arm920t/s3c24x0/nand.c b/cpu/arm920t/s3c24x0/nand.c
index 2d76798..94756ba 100644
--- a/cpu/arm920t/s3c24x0/nand.c
+++ b/cpu/arm920t/s3c24x0/nand.c
@@ -213,12 +213,10 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
}
#endif
-int board_nand_init(void) __attribute__((weak, alias("__board_nand_init")));
-
-int __board_nand_init(struct nand_chip *nand)
+int s3c24xx_nand_init(struct nand_chip *nand, u_int8_t tacls,
+ u_int8_t twrph0, u_int8_t twrph1)
{
u_int32_t cfg;
- u_int8_t tacls, twrph0, twrph1;
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
DEBUGN("board_nand_init()\n");
@@ -226,18 +224,15 @@ int __board_nand_init(struct nand_chip *nand)
clk_power->CLKCON |= (1 << 4);
/* initialize hardware */
- twrph0 = 3; twrph1 = 0; tacls = 0;
-
#if defined(CONFIG_S3C2410)
cfg = S3C2410_NFCONF_EN;
- cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
+ cfg |= S3C2410_NFCONF_TACLS(tacls);
cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
NFCONF = cfg;
#elif defined(CONFIG_S3C2440) || defined(CONFIG_S3C2442)
- twrph0 = 7; twrph1 = 7; tacls = 7;
- NFCONF = (tacls<<12)|(twrph0<<8)|(twrph1<<4)|(0<<0);
+ NFCONF = (tacls<<12)|((twrph0-1)<<8)|((twrph1-1)<<4)|(0<<0);
NFCONT = (0<<13)|(0<<12)|(0<<10)|(0<<9)|(0<<8)|(1<<6)|(1<<5)|(1<<4)|(1<<1)|(1<<0);
#endif
@@ -288,6 +283,26 @@ int __board_nand_init(struct nand_chip *nand)
return 0;
}
+int board_nand_init(void) __attribute__((weak, alias("__board_nand_init")));
+
+/* This is the default initialization function in case the board
+ * doesn't provide a board-specific board_nand_init function */
+int __board_nand_init(struct nand_chip *nand)
+{
+ u_int8_t tacls, twrph0, twrph1;
+
+ /* use the most conservative timings possible */
+ twrph0 = 8; twrph1 = 8;
+#if defined(CONFIG_S3C2410)
+ tacls = 7;
+#elif defined(CONFIG_S3C2440) || defined(CONFIG_S3C2442)
+ tacls = 3;
+#endif
+
+ return s3c24xx_nand_init(nand, tacls, twrph0, twrph1);
+}
+
+
#else
#error "U-Boot legacy NAND support not available for S3C24xx"
#endif
diff --git a/include/s3c24x0.h b/include/s3c24x0.h
index 68770bd..fe3b308 100644
--- a/include/s3c24x0.h
+++ b/include/s3c24x0.h
@@ -1207,5 +1207,7 @@ typedef struct {
#endif
int __board_nand_init(struct nand_chip *nand);
+int s3c24xx_nand_init(struct nand_chip *nand, u_int8_t tacls,
+ u_int8_t twrph0, u_int8_t twrph1);
#endif /*__S3C24X0_H__*/
--
1.5.6.5
>From d10734aab42a8e489f821b5f5392a37643da7473 Mon Sep 17 00:00:00 2001
From: Harald Welte <[EMAIL PROTECTED]>
Date: Tue, 21 Oct 2008 23:50:41 +0200
Subject: [PATCH] [S3C24xx] GTA01+GTA02: use best NAND timings
Use the best possible NAND timings for the GTA01
and GTA02 devices
Signed-off-by: Harald Welte <[EMAIL PROTECTED]>
---
board/neo1973/gta01/gta01.c | 11 +++++++++++
board/neo1973/gta02/gta02.c | 13 +++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/board/neo1973/gta01/gta01.c b/board/neo1973/gta01/gta01.c
index 095f080..06eb790 100644
--- a/board/neo1973/gta01/gta01.c
+++ b/board/neo1973/gta01/gta01.c
@@ -563,3 +563,14 @@ char *dynpart_names[] = {
"u-boot", "u-boot_env", "kernel", "splash", "rootfs", NULL };
+/* at 133MHz HCLK, this is 0ns, 30ns and 30ns */
+#define GTA02_NAND_TACLS 0
+#define GTA02_NAND_TWRPH0 4
+#define GTA02_NAND_TWRPH1 4
+
+int board_nand_init(struct nand_chip *nand)
+{
+ return s3c24xx_nand_init(nand, GTA01_NAND_TACLS,
+ GTA01_NAND_TWRPH0,
+ GTA01_NAND_TWRPH1);
+}
diff --git a/board/neo1973/gta02/gta02.c b/board/neo1973/gta02/gta02.c
index a59a513..80caec4 100644
--- a/board/neo1973/gta02/gta02.c
+++ b/board/neo1973/gta02/gta02.c
@@ -34,6 +34,7 @@
#include <s3c2440.h>
#include <i2c.h>
#include <bootmenu.h>
+#include <nand.h>
#include <asm/atomic.h>
#include "../common/neo1973.h"
@@ -864,3 +865,15 @@ int gta02_get_pcb_revision(void)
return n;
}
+
+/* at 100MHz HCLK, this is 0ns, 30ns and 20ns */
+#define GTA02_NAND_TACLS 0
+#define GTA02_NAND_TWRPH0 3
+#define GTA02_NAND_TWRPH1 2
+
+int board_nand_init(struct nand_chip *nand)
+{
+ return s3c24xx_nand_init(nand, GTA02_NAND_TACLS,
+ GTA02_NAND_TWRPH0,
+ GTA02_NAND_TWRPH1);
+}
--
1.5.6.5