[PATCH 02/12] nand_imx: use optimized memcpy

Sascha Hauer s.hauer at pengutronix.de
Mon Mar 29 05:36:13 EDT 2010


The internal SRAM buffer of the i.MX NAND controller does not
allow byte accesses. We use the memcpy32 function to handle this.
If we have assembler optimized string functions we can do better
because they won't do byte accesses when source and target are word
aligned.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/nand/nand_imx.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
index afd5637..da9b2d5 100644
--- a/drivers/nand/nand_imx.c
+++ b/drivers/nand/nand_imx.c
@@ -200,12 +200,17 @@ static struct nand_ecclayout nandv2_hw_eccoob_largepage = {
 	}
 };
 
-static void __nand_boot_init memcpy32(void *trg, const void *src, int size)
+static void memcpy32(void *trg, const void *src, int size)
 {
 	int i;
 	unsigned int *t = trg;
 	unsigned const int *s = src;
 
+#ifdef CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS
+	if (!((unsigned long)trg & 0x3) && !((unsigned long)src & 0x3))
+		memcpy(trg, src, size);
+	else
+#endif
 	for (i = 0; i < (size >> 2); i++)
 		*t++ = *s++;
 }
@@ -1025,6 +1030,16 @@ static void __nand_boot_init nfc_addr(struct imx_nand_host *host, u32 offs)
 	}
 }
 
+static void __nand_boot_init __memcpy32(void *trg, const void *src, int size)
+{
+	int i;
+	unsigned int *t = trg;
+	unsigned const int *s = src;
+
+	for (i = 0; i < (size >> 2); i++)
+		*t++ = *s++;
+}
+
 void __nand_boot_init imx_nand_load_image(void *dest, int size)
 {
 	struct imx_nand_host host;
@@ -1135,7 +1150,7 @@ void __nand_boot_init imx_nand_load_image(void *dest, int size)
 					continue;
 			}
 
-			memcpy32(dest, host.base, pagesize);
+			__memcpy32(dest, host.base, pagesize);
 			dest += pagesize;
 			size -= pagesize;
 
-- 
1.7.0




More information about the barebox mailing list