Add buffer reading code, should make the IO a little faster.

Signed-off-by: Marek Vasut <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Lukasz Majewski <[email protected]>
Cc: Minkyu Kang <[email protected]>
Cc: Scott Wood <[email protected]>
Cc: Vladimir Zapolskiy <[email protected]>
---
 drivers/mtd/nand/s3c2410_nand.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/mtd/nand/s3c2410_nand.c b/drivers/mtd/nand/s3c2410_nand.c
index a358be4..c71f874 100644
--- a/drivers/mtd/nand/s3c2410_nand.c
+++ b/drivers/mtd/nand/s3c2410_nand.c
@@ -10,6 +10,7 @@
 #include <nand.h>
 #include <asm/arch/s3c24x0_cpu.h>
 #include <asm/io.h>
+#include <asm/unaligned.h>
 
 #define S3C2410_NFCONF_EN          (1<<15)
 #define S3C2440_NFCONT_EN          (1<<0)
@@ -45,6 +46,39 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, 
int len)
        for (i = 0; i < len; i++)
                buf[i] = readb(this->IO_ADDR_R);
 }
+#elif !defined(CONFIG_S3C2410)
+static void s3c2440_read_buf(struct mtd_info *mtd, u_char *buf, int len)
+{
+       struct s3c24x0_nand *nand = s3c24x0_get_base_nand();
+       uint32_t data;
+
+       while (len >= 4) {
+               data = readl(&nand->nfdata);
+               put_unaligned_le32(data, buf);
+               buf += 4;
+               len -= 4;
+       }
+
+       for (; len & 3; len--)
+               *buf++ = readb(&nand->nfdata);
+}
+
+static void s3c2440_write_buf(struct mtd_info *mtd, const u_char *buf,
+                             int len)
+{
+       struct s3c24x0_nand *nand = s3c24x0_get_base_nand();
+       uint32_t data;
+
+       while (len >= 4) {
+               data = get_unaligned_le32(buf);
+               writel(data, &nand->nfdata);
+               buf += 4;
+               len -= 4;
+       }
+
+       for (; len & 3; len--, buf++)
+               writeb(*buf, &nand->nfdata);
+}
 #endif
 
 static void s3c24x0_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
@@ -177,6 +211,9 @@ int board_nand_init(struct nand_chip *nand)
        /* read_byte and write_byte are default */
 #ifdef CONFIG_NAND_SPL
        nand->read_buf = nand_read_buf;
+#elif !defined(CONFIG_S3C2410)
+       nand->read_buf = s3c2440_read_buf;
+       nand->write_buf = s3c2440_write_buf;
 #endif
 
        /* hwcontrol always must be implemented */
-- 
2.0.0.rc2

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to