From bb6fd2eef9359aff90f78b8791967a37e3284784 Mon Sep 17 00:00:00 2001
From: Jason Jin <jason.jin@freescale.com>
Date: Thu, 4 Aug 2011 09:59:55 +0800
Subject: [PATCH 49/52] Update FEC driver for MCF5445x and MCF54418

This patch fixed the bug that FEC could not support 10Mbps
for MCF5445x.
This patch also improved FEC performance.

Signed-off-by: Alison Wang <b18965@freescale.com>
Signed-off-by: Jason Jin <jason.jin@freescale.com>
---
 arch/m68k/coldfire/m5441x/fec.c |    4 ++--
 arch/m68k/coldfire/m5445x/fec.c |   17 +++++++++++++++--
 drivers/net/fec.c               |    9 +++++----
 3 files changed, 22 insertions(+), 8 deletions(-)

--- a/arch/m68k/coldfire/m5441x/fec.c
+++ b/arch/m68k/coldfire/m5441x/fec.c
@@ -98,7 +98,7 @@ static struct fec_platform_data m54418_f
 };
 
 static struct platform_device fec0_coldfire_device = {
-	.name = "m54418-fec",
+	.name = "coldfire-fec",
 	.id = 0,
 	.resource = fec0_resources,
 	.num_resources = ARRAY_SIZE(fec0_resources),
@@ -109,7 +109,7 @@ static struct platform_device fec0_coldf
 
 #if defined(CONFIG_FEC2)
 static struct platform_device fec1_coldfire_device = {
-	.name = "m54418-fec",
+	.name = "coldfire-fec",
 	.id = 1,
 	.resource = fec1_resources,
 	.num_resources = ARRAY_SIZE(fec1_resources),
--- a/arch/m68k/coldfire/m5445x/fec.c
+++ b/arch/m68k/coldfire/m5445x/fec.c
@@ -34,6 +34,10 @@
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
+#include <linux/platform_device.h>
+#include <linux/fec.h>
+#include <linux/io.h>
+
 #include <asm/pgtable.h>
 
 #include <asm/traps.h>
@@ -89,19 +93,28 @@ static struct resource fec1_resources[]
 };
 #endif
 
+static struct fec_platform_data m5445x_fec_pdata = {
+	.phy = PHY_INTERFACE_MODE_RMII,
+};
 static struct platform_device fec0_coldfire_device = {
-	.name = "fec",
+	.name = "coldfire-fec",
 	.id = 0,
 	.resource = fec0_resources,
 	.num_resources = ARRAY_SIZE(fec0_resources),
+	.dev = {
+		.platform_data = &m5445x_fec_pdata,
+	}
 };
 
 #if defined(CONFIG_FEC2)
 static struct platform_device fec1_coldfire_device = {
-	.name = "fec",
+	.name = "coldfire-fec",
 	.id = 1,
 	.resource = fec1_resources,
 	.num_resources = ARRAY_SIZE(fec1_resources),
+	.dev = {
+		.platform_data = &m5445x_fec_pdata,
+	}
 };
 #endif
 
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -76,7 +76,7 @@ static struct platform_device_id fec_dev
 		.name = "imx28-fec",
 		.driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME,
 	}, {
-		.name = "m54418-fec",
+		.name = "coldfire-fec",
 		.driver_data = FEC_QUIRK_ENET_MAC,
 	},
 	{ }
@@ -341,8 +341,9 @@ fec_enet_start_xmit(struct sk_buff *skb,
 	/* Push the data cache so the CPM does not get stale memory
 	 * data.
 	 */
-	bdp->cbd_bufaddr = dma_map_single(&dev->dev, bufaddr,
-			FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
+	bdp->cbd_bufaddr = __pa(bufaddr);
+	flush_dcache_range((unsigned long)skb->data,
+			(unsigned long)skb->data + skb->len);
 
 	/* Send it on its way.  Tell FEC it's ready, interrupt when done,
 	 * it's the last BD of the frame, and to put the CRC on the end.
@@ -1074,7 +1075,7 @@ static int fec_enet_alloc_buffers(struct
 
 	bdp = fep->tx_bd_base;
 	for (i = 0; i < TX_RING_SIZE; i++) {
-		fep->tx_bounce[i] = kmalloc(FEC_ENET_TX_FRSIZE, GFP_KERNEL);
+		fep->tx_bounce[i] = kmalloc(FEC_ENET_TX_FRSIZE, GFP_DMA);
 
 		bdp->cbd_sc = 0;
 		bdp->cbd_bufaddr = 0;
