leon: R.I.P.
[15.05/openwrt.git] / target / linux / coldfire / patches / 049-Update-FEC-driver-for-MCF5445x-and-MCF54418.patch
1 From bb6fd2eef9359aff90f78b8791967a37e3284784 Mon Sep 17 00:00:00 2001
2 From: Jason Jin <jason.jin@freescale.com>
3 Date: Thu, 4 Aug 2011 09:59:55 +0800
4 Subject: [PATCH 49/52] Update FEC driver for MCF5445x and MCF54418
5
6 This patch fixed the bug that FEC could not support 10Mbps
7 for MCF5445x.
8 This patch also improved FEC performance.
9
10 Signed-off-by: Alison Wang <b18965@freescale.com>
11 Signed-off-by: Jason Jin <jason.jin@freescale.com>
12 ---
13  arch/m68k/coldfire/m5441x/fec.c |    4 ++--
14  arch/m68k/coldfire/m5445x/fec.c |   17 +++++++++++++++--
15  drivers/net/fec.c               |    9 +++++----
16  3 files changed, 22 insertions(+), 8 deletions(-)
17
18 --- a/arch/m68k/coldfire/m5441x/fec.c
19 +++ b/arch/m68k/coldfire/m5441x/fec.c
20 @@ -98,7 +98,7 @@ static struct fec_platform_data m54418_f
21  };
22  
23  static struct platform_device fec0_coldfire_device = {
24 -       .name = "m54418-fec",
25 +       .name = "coldfire-fec",
26         .id = 0,
27         .resource = fec0_resources,
28         .num_resources = ARRAY_SIZE(fec0_resources),
29 @@ -109,7 +109,7 @@ static struct platform_device fec0_coldf
30  
31  #if defined(CONFIG_FEC2)
32  static struct platform_device fec1_coldfire_device = {
33 -       .name = "m54418-fec",
34 +       .name = "coldfire-fec",
35         .id = 1,
36         .resource = fec1_resources,
37         .num_resources = ARRAY_SIZE(fec1_resources),
38 --- a/arch/m68k/coldfire/m5445x/fec.c
39 +++ b/arch/m68k/coldfire/m5445x/fec.c
40 @@ -34,6 +34,10 @@
41  #include <linux/skbuff.h>
42  #include <linux/spinlock.h>
43  #include <linux/workqueue.h>
44 +#include <linux/platform_device.h>
45 +#include <linux/fec.h>
46 +#include <linux/io.h>
47 +
48  #include <asm/pgtable.h>
49  
50  #include <asm/traps.h>
51 @@ -89,19 +93,28 @@ static struct resource fec1_resources[]
52  };
53  #endif
54  
55 +static struct fec_platform_data m5445x_fec_pdata = {
56 +       .phy = PHY_INTERFACE_MODE_RMII,
57 +};
58  static struct platform_device fec0_coldfire_device = {
59 -       .name = "fec",
60 +       .name = "coldfire-fec",
61         .id = 0,
62         .resource = fec0_resources,
63         .num_resources = ARRAY_SIZE(fec0_resources),
64 +       .dev = {
65 +               .platform_data = &m5445x_fec_pdata,
66 +       }
67  };
68  
69  #if defined(CONFIG_FEC2)
70  static struct platform_device fec1_coldfire_device = {
71 -       .name = "fec",
72 +       .name = "coldfire-fec",
73         .id = 1,
74         .resource = fec1_resources,
75         .num_resources = ARRAY_SIZE(fec1_resources),
76 +       .dev = {
77 +               .platform_data = &m5445x_fec_pdata,
78 +       }
79  };
80  #endif
81  
82 --- a/drivers/net/fec.c
83 +++ b/drivers/net/fec.c
84 @@ -76,7 +76,7 @@ static struct platform_device_id fec_dev
85                 .name = "imx28-fec",
86                 .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME,
87         }, {
88 -               .name = "m54418-fec",
89 +               .name = "coldfire-fec",
90                 .driver_data = FEC_QUIRK_ENET_MAC,
91         },
92         { }
93 @@ -341,8 +341,9 @@ fec_enet_start_xmit(struct sk_buff *skb,
94         /* Push the data cache so the CPM does not get stale memory
95          * data.
96          */
97 -       bdp->cbd_bufaddr = dma_map_single(&dev->dev, bufaddr,
98 -                       FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
99 +       bdp->cbd_bufaddr = __pa(bufaddr);
100 +       flush_dcache_range((unsigned long)skb->data,
101 +                       (unsigned long)skb->data + skb->len);
102  
103         /* Send it on its way.  Tell FEC it's ready, interrupt when done,
104          * it's the last BD of the frame, and to put the CRC on the end.
105 @@ -1074,7 +1075,7 @@ static int fec_enet_alloc_buffers(struct
106  
107         bdp = fep->tx_bd_base;
108         for (i = 0; i < TX_RING_SIZE; i++) {
109 -               fep->tx_bounce[i] = kmalloc(FEC_ENET_TX_FRSIZE, GFP_KERNEL);
110 +               fep->tx_bounce[i] = kmalloc(FEC_ENET_TX_FRSIZE, GFP_DMA);
111  
112                 bdp->cbd_sc = 0;
113                 bdp->cbd_bufaddr = 0;