]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
8xxx: Break out DMA code to a common file
authorPeter Tyser <ptyser@xes-inc.com>
Tue, 30 Jun 2009 22:15:40 +0000 (17:15 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Thu, 2 Jul 2009 04:01:51 +0000 (23:01 -0500)
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>
cpu/mpc85xx/cpu.c
cpu/mpc86xx/cpu.c
drivers/dma/Makefile
drivers/dma/fsl_dma.c [new file with mode: 0644]
include/asm-ppc/config.h
include/configs/PM854.h
include/configs/PM856.h

index d88c56462087c4c9b9da38bc850376909b16b62f..28c6119d3dea9c03abbc7a74ceb4e22ad9d04fa7 100644 (file)
@@ -264,53 +264,6 @@ reset_85xx_watchdog(void)
 }
 #endif /* CONFIG_WATCHDOG */
 
-#if defined(CONFIG_DDR_ECC)
-void dma_init(void) {
-       volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
-       volatile fsl_dma_t *dma = &dma_base->dma[0];
-
-       dma->satr = 0x00040000;
-       dma->datr = 0x00040000;
-       dma->sr = 0xffffffff; /* clear any errors */
-       asm("sync; isync; msync");
-       return;
-}
-
-uint dma_check(void) {
-       volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
-       volatile fsl_dma_t *dma = &dma_base->dma[0];
-       volatile uint status = dma->sr;
-
-       /* While the channel is busy, spin */
-       while((status & 4) == 4) {
-               status = dma->sr;
-       }
-
-       /* clear MR[CS] channel start bit */
-       dma->mr &= 0x00000001;
-       asm("sync;isync;msync");
-
-       if (status != 0) {
-               printf ("DMA Error: status = %x\n", status);
-       }
-       return status;
-}
-
-int dma_xfer(void *dest, uint count, void *src) {
-       volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
-       volatile fsl_dma_t *dma = &dma_base->dma[0];
-
-       dma->dar = (uint) dest;
-       dma->sar = (uint) src;
-       dma->bcr = count;
-       dma->mr = 0xf000004;
-       asm("sync;isync;msync");
-       dma->mr = 0xf000005;
-       asm("sync;isync;msync");
-       return dma_check();
-}
-#endif
-
 /*
  * Configures a UPM. The function requires the respective MxMR to be set
  * before calling this function. "size" is the number or entries, not a sizeof.
index 438d9025f3fcaeb4daaeaa593ebf9f902b90b2cf..bc6428680e571baeac3c7c0ae086452b9ef47742 100644 (file)
@@ -186,61 +186,6 @@ watchdog_reset(void)
 }
 #endif /* CONFIG_WATCHDOG */
 
-
-#if defined(CONFIG_DDR_ECC)
-void
-dma_init(void)
-{
-       volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR);
-       volatile fsl_dma_t *dma = &dma_base->dma[0];
-
-       dma->satr = 0x00040000;
-       dma->datr = 0x00040000;
-       dma->sr = 0xffffffff; /* clear any errors */
-       asm("sync; isync");
-}
-
-uint
-dma_check(void)
-{
-       volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR);
-       volatile fsl_dma_t *dma = &dma_base->dma[0];
-       volatile uint status = dma->sr;
-
-       /* While the channel is busy, spin */
-       while ((status & 4) == 4) {
-               status = dma->sr;
-       }
-
-       /* clear MR[CS] channel start bit */
-       dma->mr &= 0x00000001;
-       asm("sync;isync");
-
-       if (status != 0) {
-               printf("DMA Error: status = %x\n", status);
-       }
-       return status;
-}
-
-int
-dma_xfer(void *dest, uint count, void *src)
-{
-       volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR);
-       volatile fsl_dma_t *dma = &dma_base->dma[0];
-
-       dma->dar = (uint) dest;
-       dma->sar = (uint) src;
-       dma->bcr = count;
-       dma->mr = 0xf000004;
-       asm("sync;isync");
-       dma->mr = 0xf000005;
-       asm("sync;isync");
-       return dma_check();
-}
-
-#endif /* CONFIG_DDR_ECC */
-
-
 /*
  * Print out the state of various machine registers.
  * Currently prints out LAWs, BR0/OR0, and BATs
index cf29efa027296c21e004772976eb5362668c63f2..36d99f9b111f8b7561527c12303353c72bd2b815 100644 (file)
@@ -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 (file)
index 0000000..a9989ee
--- /dev/null
@@ -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();
+}
index 0900f65b96f3c85faa508aae0b030c27e7f81a8f..9c358aa4135aae4f918639ce0b509080c63d13d0 100644 (file)
 #endif
 #endif
 
+#ifndef CONFIG_FSL_DMA
+#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) && \
+       (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx))
+#define CONFIG_FSL_DMA
 #endif
+#endif
+
+#endif /* _ASM_CONFIG_H_ */
index 3f943aa437b6957414ae26a74e9cb58a15fb6c68..4b9bcca79bcd007a833ca46f09d36118863bcc72 100644 (file)
@@ -96,6 +96,7 @@
 #undef CONFIG_DDR_SPD
 #define CONFIG_DDR_DLL                      /* possible DLL fix needed */
 #define CONFIG_DDR_ECC                     /* only for ECC DDR module */
+#define CONFIG_FSL_DMA                     /* use DMA to init DDR ECC  */
 
 #define CONFIG_MEM_INIT_VALUE  0xDeadBeef
 
index 43c2873e3700575f7fb2b67142d00015de81fa45..1db20bcceb5a22619c8f3acac39641faf3303df4 100644 (file)
@@ -98,6 +98,7 @@
 #undef CONFIG_DDR_SPD
 #define CONFIG_DDR_DLL                      /* possible DLL fix needed */
 #define CONFIG_DDR_ECC                     /* only for ECC DDR module */
+#define CONFIG_FSL_DMA                     /* use DMA to init DDR ECC  */
 
 #define CONFIG_MEM_INIT_VALUE  0xDeadBeef