summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-02-20 18:13:26 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2009-08-19 10:51:39 +0200
commite471a5fd390247da31c97932d278a01ec035d3b7 (patch)
tree503266482afad2df55d111aa3a32af83b335bc84 /drivers
parente2c8e8a1809aa14b60af88901ed3df85348e2987 (diff)
downloadbarebox-e471a5fd390247da31c97932d278a01ec035d3b7.tar.gz
barebox-e471a5fd390247da31c97932d278a01ec035d3b7.tar.xz
fec imx27: Add MMU support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/fec_imx.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 35ac670767..cbb10bba10 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -26,14 +26,16 @@
#include <driver.h>
#include <miiphy.h>
#include <fec.h>
-#include "fec_imx.h"
+#include <asm/mmu.h>
#include <asm/io.h>
#include <asm/arch/imx-regs.h>
#include <clock.h>
#include <asm/arch/clock.h>
#include <xfuncs.h>
+#include "fec_imx.h"
+
typedef struct {
uint8_t data[1500]; /**< actual data */
int length; /**< actual length */
@@ -165,18 +167,18 @@ static int fec_rbd_init(struct fec_priv *fec, int count, int size)
{
int ix;
static int once = 0;
- uint32_t p=0;
+ unsigned long p = 0;
if (!once) {
/* reserve data memory and consider alignment */
- p = (uint32_t)xzalloc(size * count + DB_DATA_ALIGNMENT) +
- (DB_DATA_ALIGNMENT-1);
- p &= ~(DB_DATA_ALIGNMENT-1);
+ p = (unsigned long)dma_alloc_coherent(size * count + DB_DATA_ALIGNMENT);
+ p += DB_DATA_ALIGNMENT - 1;
+ p &= ~(DB_DATA_ALIGNMENT - 1);
}
for (ix = 0; ix < count; ix++) {
if (!once) {
- writel(p, &fec->rbd_base[ix].data_pointer);
+ writel(dma_to_phys((void *)p), &fec->rbd_base[ix].data_pointer);
p += size;
}
writew(FEC_RBD_EMPTY, &fec->rbd_base[ix].status);
@@ -421,7 +423,9 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length)
* the second will be empty and only used to stop the DMA engine
*/
writew(data_length, &fec->tbd_base[fec->tbd_index].data_length);
- writel((uint32_t)eth_data, &fec->tbd_base[fec->tbd_index].data_pointer);
+
+ writel((uint32_t)(eth_data), &fec->tbd_base[fec->tbd_index].data_pointer);
+ dma_flush_range(eth_data, eth_data + data_length);
/*
* update BD's status now
* This block:
@@ -508,9 +512,8 @@ static int fec_recv(struct eth_device *dev)
/*
* Get buffer address and size
*/
- frame = (NBUF *)readl(&rbd->data_pointer);
+ frame = phys_to_dma(readl(&rbd->data_pointer));
frame_length = readw(&rbd->data_length) - 4;
-
NetReceive(frame->data, frame_length);
len = frame_length;
} else {
@@ -563,8 +566,8 @@ static int fec_probe(struct device_d *dev)
* reserve memory for both buffer descriptor chains at once
* Datasheet forces the startaddress of each chain is 16 byte aligned
*/
- base = (uint32_t)xzalloc((2 + FEC_RBD_NUM) *
- sizeof (struct buffer_descriptor) + 2 * DB_ALIGNMENT );
+ base = (uint32_t)dma_alloc_coherent((2 + FEC_RBD_NUM) *
+ sizeof(struct buffer_descriptor) + 2 * DB_ALIGNMENT);
base += (DB_ALIGNMENT - 1);
base &= ~(DB_ALIGNMENT - 1);
fec->rbd_base = (struct buffer_descriptor *)base;
@@ -573,8 +576,8 @@ static int fec_probe(struct device_d *dev)
base &= ~(DB_ALIGNMENT - 1);
fec->tbd_base = (struct buffer_descriptor *)base;
- writel((uint32_t)fec->tbd_base, fec->regs + FEC_ETDSR);
- writel((uint32_t)fec->rbd_base, fec->regs + FEC_ERDSR);
+ writel((uint32_t)dma_to_phys(fec->tbd_base), fec->regs + FEC_ETDSR);
+ writel((uint32_t)dma_to_phys(fec->rbd_base), fec->regs + FEC_ERDSR);
fec->xcv_type = pdata->xcv_type;