summaryrefslogtreecommitdiffstats
path: root/drivers/dma
diff options
context:
space:
mode:
authorPeter Tyser <ptyser@xes-inc.com>2009-06-30 17:15:40 -0500
committerKumar Gala <galak@kernel.crashing.org>2009-07-01 23:01:51 -0500
commit017f11f68ef543e866be033bcb7b8058a8a380d8 (patch)
treef8a0fd3db0b2436db79df427267149f0d4e5b416 /drivers/dma
parent29c35182462feea09f322e51913759a53359a3e0 (diff)
downloadblackbird-obmc-uboot-017f11f68ef543e866be033bcb7b8058a8a380d8.tar.gz
blackbird-obmc-uboot-017f11f68ef543e866be033bcb7b8058a8a380d8.zip
8xxx: Break out DMA code to a common file
DMA support is now enabled via the CONFIG_FSL_DMA define instead of the previous CONFIG_DDR_ECC Signed-off-by: Peter Tyser <ptyser@xes-inc.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/Makefile1
-rw-r--r--drivers/dma/fsl_dma.c92
2 files changed, 93 insertions, 0 deletions
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index cf29efa027..36d99f9b11 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk
LIB := $(obj)libdma.a
COBJS-$(CONFIG_FSLDMAFEC) += MCD_tasksInit.o MCD_dmaApi.o MCD_tasks.o
+COBJS-$(CONFIG_FSL_DMA) += fsl_dma.o
COBJS := $(COBJS-y)
SRCS := $(COBJS:.o=.c)
diff --git a/drivers/dma/fsl_dma.c b/drivers/dma/fsl_dma.c
new file mode 100644
index 0000000000..a9989ee5cb
--- /dev/null
+++ b/drivers/dma/fsl_dma.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004,2007,2008 Freescale Semiconductor, Inc.
+ * (C) Copyright 2002, 2003 Motorola Inc.
+ * Xianghua Xiao (X.Xiao@motorola.com)
+ *
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <config.h>
+#include <common.h>
+#include <asm/fsl_dma.h>
+
+#if defined(CONFIG_MPC85xx)
+volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
+#elif defined(CONFIG_MPC86xx)
+volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR);
+#else
+#error "Freescale DMA engine not supported on your processor"
+#endif
+
+static void dma_sync(void)
+{
+#if defined(CONFIG_MPC85xx)
+ asm("sync; isync; msync");
+#elif defined(CONFIG_MPC86xx)
+ asm("sync; isync");
+#endif
+}
+
+static uint dma_check(void) {
+ volatile fsl_dma_t *dma = &dma_base->dma[0];
+ volatile uint status = dma->sr;
+
+ /* While the channel is busy, spin */
+ while (status & 4)
+ status = dma->sr;
+
+ /* clear MR[CS] channel start bit */
+ dma->mr &= 1;
+ dma_sync();
+
+ if (status != 0)
+ printf ("DMA Error: status = %x\n", status);
+
+ return status;
+}
+
+void dma_init(void) {
+ volatile fsl_dma_t *dma = &dma_base->dma[0];
+
+ dma->satr = 0x00040000;
+ dma->datr = 0x00040000;
+ dma->sr = 0xffffffff; /* clear any errors */
+ dma_sync();
+}
+
+int dma_xfer(void *dest, uint count, void *src) {
+ volatile fsl_dma_t *dma = &dma_base->dma[0];
+
+ dma->dar = (uint) dest;
+ dma->sar = (uint) src;
+ dma->bcr = count;
+
+ /* Disable bandwidth control, use direct transfer mode */
+ dma->mr = 0xf000004;
+ dma_sync();
+
+ /* Start the transfer */
+ dma->mr = 0xf000005;
+ dma_sync();
+
+ return dma_check();
+}
OpenPOWER on IntegriCloud