[U-Boot] [PATCH v2 3/6] sf: spi_flash: use dma to copy data from mmap region if platform supports

Mugunthan V N mugunthanvnm at ti.com
Wed Dec 23 17:43:00 CET 2015


Add dma memcpy api to the default spi_flash_copy_mmap(), so that
dma will be used to copy data when CONFIG_DMA is defined for the
platform.

Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
 drivers/mtd/spi/spi_flash.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index f300b07..6da8bdb 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -16,6 +16,7 @@
 #include <spi.h>
 #include <spi_flash.h>
 #include <linux/log2.h>
+#include <dma.h>
 
 #include "sf_internal.h"
 
@@ -454,8 +455,16 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
 	return ret;
 }
 
+/*
+ * TODO: remove the weak after all the other spi_flash_copy_mmap
+ * implementations removed from drivers
+ */
 void __weak spi_flash_copy_mmap(void *data, void *offset, size_t len)
 {
+#ifdef CONFIG_DMA
+	if (!dma_memcpy(data, offset, len))
+		return;
+#endif
 	memcpy(data, offset, len);
 }
 
-- 
2.7.0.rc1.5.gf3adf45



More information about the U-Boot mailing list