[U-Boot] [PATCH 11/11] fsl_dma: Break out common memory initialization function
Peter Tyser
ptyser at xes-inc.com
Thu May 21 19:10:09 CEST 2009
Signed-off-by: Peter Tyser <ptyser at xes-inc.com>
---
board/mpc8540eval/mpc8540eval.c | 33 +--------------------------------
board/sbc8560/sbc8560.c | 33 +--------------------------------
cpu/mpc85xx/ddr-gen1.c | 27 +--------------------------
drivers/dma/fsl_dma.c | 32 ++++++++++++++++++++++++++++++++
include/asm-ppc/fsl_dma.h | 3 +++
5 files changed, 38 insertions(+), 90 deletions(-)
diff --git a/board/mpc8540eval/mpc8540eval.c b/board/mpc8540eval/mpc8540eval.c
index 27d7a3d..7c27233 100644
--- a/board/mpc8540eval/mpc8540eval.c
+++ b/board/mpc8540eval/mpc8540eval.c
@@ -137,40 +137,9 @@ phys_size_t initdram (int board_type)
{
/* Initialize all of memory for ECC, then
* enable errors */
- uint *p = 0;
- uint i = 0;
volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
- for (*p = 0; p < (uint *)(8 * 1024); p++) {
- if (((unsigned int)p & 0x1f) == 0) { dcbz(p); }
- *p = (unsigned int)0xdeadbeef;
- if (((unsigned int)p & 0x1c) == 0x1c) { dcbf(p); }
- }
-
- /* 8K */
- dmacpy((uint *)0x2000, (uint *)0, 0x2000);
- /* 16K */
- dmacpy((uint *)0x4000, (uint *)0, 0x4000);
- /* 32K */
- dmacpy((uint *)0x8000, (uint *)0, 0x8000);
- /* 64K */
- dmacpy((uint *)0x10000, (uint *)0, 0x10000);
- /* 128k */
- dmacpy((uint *)0x20000, (uint *)0, 0x20000);
- /* 256k */
- dmacpy((uint *)0x40000, (uint *)0, 0x40000);
- /* 512k */
- dmacpy((uint *)0x80000, (uint *)0, 0x80000);
- /* 1M */
- dmacpy((uint *)0x100000, (uint *)0, 0x100000);
- /* 2M */
- dmacpy((uint *)0x200000, (uint *)0, 0x200000);
- /* 4M */
- dmacpy((uint *)0x400000, (uint *)0, 0x400000);
-
- for (i = 1; i < dram_size / 0x800000; i++) {
- dmacpy((uint *)(0x800000*i), (uint *)0, 0x800000);
- }
+ dma_meminit(CONFIG_MEM_INIT_VALUE, dram_size);
/* Enable errors for ECC */
ddr->err_disable = 0x00000000;
diff --git a/board/sbc8560/sbc8560.c b/board/sbc8560/sbc8560.c
index 64d4154..c40b5e3 100644
--- a/board/sbc8560/sbc8560.c
+++ b/board/sbc8560/sbc8560.c
@@ -338,40 +338,9 @@ phys_size_t initdram (int board_type)
{
/* Initialize all of memory for ECC, then
* enable errors */
- uint *p = 0;
- uint i = 0;
volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
- for (*p = 0; p < (uint *)(8 * 1024); p++) {
- if (((unsigned int)p & 0x1f) == 0) { dcbz(p); }
- *p = (unsigned int)0xdeadbeef;
- if (((unsigned int)p & 0x1c) == 0x1c) { dcbf(p); }
- }
-
- /* 8K */
- dmacpy((uint *)0x2000, (uint *)0, 0x2000);
- /* 16K */
- dmacpy((uint *)0x4000, (uint *)0, 0x4000);
- /* 32K */
- dmacpy((uint *)0x8000, (uint *)0, 0x8000);
- /* 64K */
- dmacpy((uint *)0x10000, (uint *)0, 0x10000);
- /* 128k */
- dmacpy((uint *)0x20000, (uint *)0, 0x20000);
- /* 256k */
- dmacpy((uint *)0x40000, (uint *)0, 0x40000);
- /* 512k */
- dmacpy((uint *)0x80000, (uint *)0, 0x80000);
- /* 1M */
- dmacpy((uint *)0x100000, (uint *)0, 0x100000);
- /* 2M */
- dmacpy((uint *)0x200000, (uint *)0, 0x200000);
- /* 4M */
- dmacpy((uint *)0x400000, (uint *)0, 0x400000);
-
- for (i = 1; i < dram_size / 0x800000; i++) {
- dmacpy((uint *)(0x800000*i), (uint *)0, 0x800000);
- }
+ dma_meminit(CONFIG_MEM_INIT_VALUE, dram_size);
/* Enable errors for ECC */
ddr->err_disable = 0x00000000;
diff --git a/cpu/mpc85xx/ddr-gen1.c b/cpu/mpc85xx/ddr-gen1.c
index 5529021..54437dd 100644
--- a/cpu/mpc85xx/ddr-gen1.c
+++ b/cpu/mpc85xx/ddr-gen1.c
@@ -73,34 +73,9 @@ void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
void
ddr_enable_ecc(unsigned int dram_size)
{
- uint *p = 0;
- uint i = 0;
volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
- for (*p = 0; p < (uint *)(8 * 1024); p++) {
- if (((unsigned int)p & 0x1f) == 0) {
- ppcDcbz((unsigned long) p);
- }
- *p = (unsigned int)CONFIG_MEM_INIT_VALUE;
- if (((unsigned int)p & 0x1c) == 0x1c) {
- ppcDcbf((unsigned long) p);
- }
- }
-
- dmacpy((uint *)0x002000, (uint *)0, 0x2000); /* 8K */
- dmacpy((uint *)0x004000, (uint *)0, 0x4000); /* 16K */
- dmacpy((uint *)0x008000, (uint *)0, 0x8000); /* 32K */
- dmacpy((uint *)0x010000, (uint *)0, 0x10000); /* 64K */
- dmacpy((uint *)0x020000, (uint *)0, 0x20000); /* 128K */
- dmacpy((uint *)0x040000, (uint *)0, 0x40000); /* 256K */
- dmacpy((uint *)0x080000, (uint *)0, 0x80000); /* 512K */
- dmacpy((uint *)0x100000, (uint *)0, 0x100000); /* 1M */
- dmacpy((uint *)0x200000, (uint *)0, 0x200000); /* 2M */
- dmacpy((uint *)0x400000, (uint *)0, 0x400000); /* 4M */
-
- for (i = 1; i < dram_size / 0x800000; i++) {
- dmacpy((uint *)(0x800000*i), (uint *)0, 0x800000);
- }
+ dma_meminit(CONFIG_MEM_INIT_VALUE, dram_size);
/*
* Enable errors for ECC.
diff --git a/drivers/dma/fsl_dma.c b/drivers/dma/fsl_dma.c
index 90eeef7..b7497b5 100644
--- a/drivers/dma/fsl_dma.c
+++ b/drivers/dma/fsl_dma.c
@@ -112,3 +112,35 @@ int dmacpy(void *dest, const void *src, size_t n) {
return 0;
}
+
+#if (defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER))
+void dma_meminit(uint val, uint size)
+{
+ uint *p = 0;
+ uint i = 0;
+
+ for (*p = 0; p < (uint *)(8 * 1024); p++) {
+ if (((uint)p & 0x1f) == 0)
+ ppcDcbz((ulong)p);
+
+ *p = (uint)CONFIG_MEM_INIT_VALUE;
+
+ if (((uint)p & 0x1c) == 0x1c)
+ ppcDcbf((ulong)p);
+ }
+
+ dmacpy((uint *)0x002000, (uint *)0, 0x002000); /* 8K */
+ dmacpy((uint *)0x004000, (uint *)0, 0x004000); /* 16K */
+ dmacpy((uint *)0x008000, (uint *)0, 0x008000); /* 32K */
+ dmacpy((uint *)0x010000, (uint *)0, 0x010000); /* 64K */
+ dmacpy((uint *)0x020000, (uint *)0, 0x020000); /* 128K */
+ dmacpy((uint *)0x040000, (uint *)0, 0x040000); /* 256K */
+ dmacpy((uint *)0x080000, (uint *)0, 0x080000); /* 512K */
+ dmacpy((uint *)0x100000, (uint *)0, 0x100000); /* 1M */
+ dmacpy((uint *)0x200000, (uint *)0, 0x200000); /* 2M */
+ dmacpy((uint *)0x400000, (uint *)0, 0x400000); /* 4M */
+
+ for (i = 1; i < size / 0x800000; i++)
+ dmacpy((uint *)(0x800000 * i), (uint *)0, 0x800000);
+}
+#endif
diff --git a/include/asm-ppc/fsl_dma.h b/include/asm-ppc/fsl_dma.h
index 06ecdcd..dd92343 100644
--- a/include/asm-ppc/fsl_dma.h
+++ b/include/asm-ppc/fsl_dma.h
@@ -97,6 +97,9 @@ typedef struct fsl_dma {
#ifdef CONFIG_FSL_DMA
void dma_init(void);
int dmacpy(void *dest, const void *src, size_t n);
+#if (defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER))
+void dma_meminit(uint val, uint size);
+#endif
#endif
#endif /* _ASM_DMA_H_ */
--
1.6.2.1
More information about the U-Boot
mailing list