Patchwork [U-Boot,2/2] u-boot/drivers/net/designware with cache support.

login
register
mail settings
Submitter Frank Dols
Date Jan. 22, 2013, 2:10 p.m.
Message ID <1358863821-31956-3-git-send-email-frank.dols@synopsys.com>
Download mbox | patch
Permalink /patch/214565/
State Changes Requested
Delegated to: Joe Hershberger
Headers show

Comments

Frank Dols - Jan. 22, 2013, 2:10 p.m.
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
---
 drivers/net/designware.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 2f235d5..8e0508e 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -32,6 +32,9 @@ 
 #include <linux/err.h>
 #include <asm/io.h>
 #include "designware.h"
+#ifdef CONFIG_SYS_DCACHE_ON
+#include <asm/cache.h>
+#endif
 
 static int configure_phy(struct eth_device *dev);
 
@@ -227,6 +230,10 @@  static int dw_eth_send(struct eth_device *dev, void *packet, int length)
 
 	memcpy((void *)readl(&desc_p->dmamac_addr), packet, length);
 
+#ifdef CONFIG_SYS_DCACHE_ON
+	flush_dcache_range((void *)readl(&desc_p->dmamac_addr), length);
+#endif
+
 #if defined(CONFIG_DW_ALTDESCRIPTOR)
 	writel(readl(&desc_p->txrx_status) | DESC_TXSTS_TXFIRST |
 		DESC_TXSTS_TXLAST, &desc_p->txrx_status);
@@ -277,8 +284,17 @@  static int dw_eth_recv(struct eth_device *dev)
 		length = (status & DESC_RXSTS_FRMLENMSK) >>
 			 DESC_RXSTS_FRMLENSHFT;
 
+#ifdef CONFIG_SYS_DCACHE_ON
+		invalidate_dcache_range((void *)readl(&desc_p->dmamac_addr),
+			length);
+#endif
+
 		NetReceive(readl(&desc_p->dmamac_addr), length);
 
+#ifdef CONFIG_SYS_DCACHE_ON
+		flush_dcache_range((void *)readl(&desc_p->dmamac_addr), length);
+#endif
+
 		/*
 		 * Make the current descriptor valid again and go to
 		 * the next one
@@ -584,6 +600,10 @@  int designware_initialize(u32 id, ulong base_addr, u32 phy_addr, u32 interface)
 	dev->halt = dw_eth_halt;
 	dev->write_hwaddr = dw_write_hwaddr;
 
+#ifdef CONFIG_SYS_DCACHE_ON
+	flush_dcache_range(priv, sizeof(struct dw_eth_dev));
+#endif
+
 	eth_register(dev);
 
 #if defined(CONFIG_MII)