From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Sat, 11 Oct 2014 18:42:54 +0200 Subject: [U-Boot] [PATCH 06/10] mtd: nand: s3c: Add S3C2440 buffer reading In-Reply-To: <1413045778-5690-1-git-send-email-marex@denx.de> References: <1413045778-5690-1-git-send-email-marex@denx.de> Message-ID: <1413045778-5690-6-git-send-email-marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Add buffer reading code, should make the IO a little faster. Signed-off-by: Marek Vasut Cc: Kyungmin Park Cc: Lukasz Majewski Cc: Minkyu Kang Cc: Scott Wood Cc: Vladimir Zapolskiy --- 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 4971342..91db6ca 100644 --- a/drivers/mtd/nand/s3c2410_nand.c +++ b/drivers/mtd/nand/s3c2410_nand.c @@ -10,6 +10,7 @@ #include #include #include +#include #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.1.1