Skip to contentSkip to conversation

85xx/86xx dma updates

PATCH New Peter Tyser 5 participants 25 messages May 21, 2009 – Jun 30, 2009 dmaengine

lore
Share & tools
lore
#0 lore raw

cover 85xx/86xx dma updates

This patch series attempts to clean up the DMA implementation for the 85xx and 86xx architectures. The changes include:
- consolidate 85xx and 86xx structures and code
- add defines for bitfields
- use proper IO accessors
- add support for arbitrarily large transfer sizes
- rename dma_xfer() to dmacpy() and make dmacpy's prototype similar to memcpy()

The patches are based on the mainline "next" branch.

I've tested the code on MPC8572 and MPC8640-based boards.

I'm not initimately familar with the 83xx platform, but at a glance it looked like the fsl_dma driver could be extended to support it with some ifdeffery.

Peter Tyser (11):
fsl: Create common fsl_dma.h for 85xx and 86xx cpus 85xx, 86xx: Sync up DMA code
85xx, 86xx: Break out DMA code to a common file
fsl_dma: Add bitfield definitions for common registers
fsl_dma: Update to use proper I/O accessor functions
fsl_dma: Add support for arbitrarily large transfers
fsl_dma: Fix Channel Start bug in dma_check() 8xxx: Rename dma_xfer() dmacpy()
fsl_dma: Move dma function prototypes to common header file 85xx, 86xx: Move dma_init() call to common code
fsl_dma: Break out common memory initialization function

 board/mpc8540eval/mpc8540eval.c |   35 +---------
 board/sbc8560/sbc8560.c         |   33 +---------
 cpu/mpc83xx/cpu.c               |    4 +-
 cpu/mpc83xx/spd_sdram.c         |   24 +++---
 cpu/mpc85xx/cpu.c               |   44 ------------
 cpu/mpc85xx/cpu_init.c          |    4 +-
 cpu/mpc85xx/ddr-gen1.c          |   33 +---------
 cpu/mpc86xx/cpu.c               |   50 -------------
 cpu/mpc86xx/cpu_init.c          |    3 +
 drivers/dma/Makefile            |    1 +
 drivers/dma/fsl_dma.c           |  146 +++++++++++++++++++++++++++++++++++++++
 include/asm-ppc/fsl_dma.h       |  105 ++++++++++++++++++++++++++++
 include/asm-ppc/immap_85xx.h    |   76 +-------------------
 include/asm-ppc/immap_86xx.h    |   78 ++-------------------
 include/configs/PM854.h         |    1 +
 include/configs/PM856.h         |    1 +
 16 files changed, 286 insertions(+), 352 deletions(-)
 create mode 100644 drivers/dma/fsl_dma.c
 create mode 100644 include/asm-ppc/fsl_dma.h
#1 lore raw

PATCH 1/11 fsl: Create common fsl_dma.h for 85xx and 86xx cpus

Break out DMA structures for the Freescale MPC85xx and MPC86xx cpus to reduce a large amount of code duplication

---
 cpu/mpc85xx/cpu.c            |   31 +++++++++--------
 cpu/mpc86xx/cpu.c            |   27 ++++++++-------
 include/asm-ppc/fsl_dma.h    |   51 ++++++++++++++++++++++++++++
 include/asm-ppc/immap_85xx.h |   76 ++----------------------------------------
 include/asm-ppc/immap_86xx.h |   76 ++----------------------------------------
 5 files changed, 89 insertions(+), 172 deletions(-)
 create mode 100644 include/asm-ppc/fsl_dma.h
cpu/mpc85xx/cpu.c +17 -14
index ef976a4..8c57404 100644
@@ -260,26 +260,28 @@ reset_85xx_watchdog(void)
 
 #if defined(CONFIG_DDR_ECC)
 void dma_init(void) {
-	volatile ccsr_dma_t *dma = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
+	volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
+	volatile fsl_dma_t *dma = &dma_base->dma[0];
 
-	dma->satr0 = 0x02c40000;
-	dma->datr0 = 0x02c40000;
-	dma->sr0 = 0xfffffff; /* clear any errors */
+	dma->satr = 0x02c40000;
+	dma->datr = 0x02c40000;
+	dma->sr = 0xfffffff; /* clear any errors */
 	asm("sync; isync; msync");
 	return;
 }
 
 uint dma_check(void) {
-	volatile ccsr_dma_t *dma = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
-	volatile uint status = dma->sr0;
+	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->sr0;
+		status = dma->sr;
 	}
 
 	/* clear MR0[CS] channel start bit */
-	dma->mr0 &= 0x00000001;
+	dma->mr &= 0x00000001;
 	asm("sync;isync;msync");
 
 	if (status != 0) {
@@ -289,14 +291,15 @@ uint dma_check(void) {
 }
 
 int dma_xfer(void *dest, uint count, void *src) {
-	volatile ccsr_dma_t *dma = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
+	volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
+	volatile fsl_dma_t *dma = &dma_base->dma[0];
 
-	dma->dar0 = (uint) dest;
-	dma->sar0 = (uint) src;
-	dma->bcr0 = count;
-	dma->mr0 = 0xf000004;
+	dma->dar = (uint) dest;
+	dma->sar = (uint) src;
+	dma->bcr = count;
+	dma->mr = 0xf000004;
 	asm("sync;isync;msync");
-	dma->mr0 = 0xf000005;
+	dma->mr = 0xf000005;
 	asm("sync;isync;msync");
 	return dma_check();
 }
cpu/mpc86xx/cpu.c +15 -12
index 653a137..f35323a 100644
@@ -183,10 +183,11 @@ void
 dma_init(void)
 {
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-	volatile ccsr_dma_t *dma = &immap->im_dma;
+	volatile ccsr_dma_t *dma_base = &immap->im_dma;
+	volatile fsl_dma_t *dma = &dma_base->dma[0];
 
-	dma->satr0 = 0x00040000;
-	dma->datr0 = 0x00040000;
+	dma->satr = 0x00040000;
+	dma->datr = 0x00040000;
 	asm("sync; isync");
 }
 
@@ -194,12 +195,13 @@ uint
 dma_check(void)
 {
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-	volatile ccsr_dma_t *dma = &immap->im_dma;
-	volatile uint status = dma->sr0;
+	volatile ccsr_dma_t *dma_base = &immap->im_dma;
+	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->sr0;
+		status = dma->sr;
 	}
 
 	if (status != 0) {
@@ -212,14 +214,15 @@ int
 dma_xfer(void *dest, uint count, void *src)
 {
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-	volatile ccsr_dma_t *dma = &immap->im_dma;
+	volatile ccsr_dma_t *dma_base = &immap->im_dma;
+	volatile fsl_dma_t *dma = &dma_base->dma[0];
 
-	dma->dar0 = (uint) dest;
-	dma->sar0 = (uint) src;
-	dma->bcr0 = count;
-	dma->mr0 = 0xf000004;
+	dma->dar = (uint) dest;
+	dma->sar = (uint) src;
+	dma->bcr = count;
+	dma->mr = 0xf000004;
 	asm("sync;isync");
-	dma->mr0 = 0xf000005;
+	dma->mr = 0xf000005;
 	asm("sync;isync");
 	return dma_check();
 }
include/asm-ppc/fsl_dma.h new file +51 -0

51 lines not on this page · raw message

include/asm-ppc/immap_85xx.h +3 -73

89 lines not on this page · raw message

include/asm-ppc/immap_86xx.h +3 -73

89 lines not on this page · raw message

Signature · 1 line
1.6.2.1
Applied
#2 lore raw

PATCH 1/11 fsl: Create common fsl_dma.h for 85xx and 86xx cpus

Quoted 13 lines · Peter Tyser

Break out DMA structures for the Freescale MPC85xx and MPC86xx cpus to reduce a large amount of code duplication

---

cpu/mpc85xx/cpu.c            |   31 +++++++++--------
cpu/mpc86xx/cpu.c            |   27 ++++++++-------
include/asm-ppc/fsl_dma.h    |   51 ++++++++++++++++++++++++++++
include/asm-ppc/immap_85xx.h |   76 + 
+----------------------------------------
include/asm-ppc/immap_86xx.h |   76 + 
+----------------------------------------
5 files changed, 89 insertions(+), 172 deletions(-)
Quoted 1 line

create mode 100644 include/asm-ppc/fsl_dma.h

applied to next

- k

#3 lore raw

PATCH 2/11 85xx, 86xx: Sync up DMA code

In reply to Peter Tyser

The following changes were made to sync up the DMA code between the 85xx and 86xx architectures which will make it easier to break out common 8xxx DMA code:

85xx:
- Don't set STRANSINT and SPCIORDER fields in SATR register. These bits only have an affect when the SBPATMU bit is set.
- Write 0xffffffff instead of 0xfffffff to clear errors in the DMA status register. We may as well clear all 32 bits of the register...

86xx:
- Add CONFIG_SYS_MPC86xx_DMA_ADDR define to address DMA registers
- Add clearing of errors in the DMA status register when initializing the controller
- Clear the channel start bit in the DMA mode register after a transfer

---
 cpu/mpc85xx/cpu.c            |    8 ++++----
 cpu/mpc86xx/cpu.c            |   14 ++++++++------
 include/asm-ppc/immap_86xx.h |    2 ++
 3 files changed, 14 insertions(+), 10 deletions(-)
cpu/mpc85xx/cpu.c +4 -4
index 8c57404..86b19a6 100644
@@ -263,9 +263,9 @@ 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 = 0x02c40000;
-	dma->datr = 0x02c40000;
-	dma->sr = 0xfffffff; /* clear any errors */
+	dma->satr = 0x00040000;
+	dma->datr = 0x00040000;
+	dma->sr = 0xffffffff; /* clear any errors */
 	asm("sync; isync; msync");
 	return;
 }
@@ -280,7 +280,7 @@ uint dma_check(void) {
 		status = dma->sr;
 	}
 
-	/* clear MR0[CS] channel start bit */
+	/* clear MR[CS] channel start bit */
 	dma->mr &= 0x00000001;
 	asm("sync;isync;msync");
 
cpu/mpc86xx/cpu.c +8 -6
index f35323a..d47cc5e 100644
@@ -182,20 +182,19 @@ watchdog_reset(void)
 void
 dma_init(void)
 {
-	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-	volatile ccsr_dma_t *dma_base = &immap->im_dma;
+	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 immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-	volatile ccsr_dma_t *dma_base = &immap->im_dma;
+	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;
 
@@ -204,6 +203,10 @@ dma_check(void)
 		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);
 	}
@@ -213,8 +216,7 @@ dma_check(void)
 int
 dma_xfer(void *dest, uint count, void *src)
 {
-	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-	volatile ccsr_dma_t *dma_base = &immap->im_dma;
+	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;
include/asm-ppc/immap_86xx.h +2 -0
index 689c720..a839834 100644
@@ -1295,5 +1295,7 @@ extern immap_t  *immr;
 #define CONFIG_SYS_MPC86xx_DDR_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC86xx_DDR_OFFSET)
 #define CONFIG_SYS_MPC86xx_DDR2_OFFSET	(0x6000)
 #define CONFIG_SYS_MPC86xx_DDR2_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC86xx_DDR2_OFFSET)
+#define CONFIG_SYS_MPC86xx_DMA_OFFSET	(0x21000)
+#define CONFIG_SYS_MPC86xx_DMA_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC86xx_DMA_OFFSET)
 
 #endif /*__IMMAP_86xx__*/
Signature · 1 line
1.6.2.1
Applied
#4 lore raw

PATCH 2/11 85xx, 86xx: Sync up DMA code

Quoted 19 lines · Peter Tyser

The following changes were made to sync up the DMA code between the 85xx
and 86xx architectures which will make it easier to break out common 8xxx DMA code:

85xx:
- Don't set STRANSINT and SPCIORDER fields in SATR register. These bits
only have an affect when the SBPATMU bit is set.
- Write 0xffffffff instead of 0xfffffff to clear errors in the DMA status register. We may as well clear all 32 bits of the register...

86xx:
- Add CONFIG_SYS_MPC86xx_DMA_ADDR define to address DMA registers
- Add clearing of errors in the DMA status register when initializing the controller
- Clear the channel start bit in the DMA mode register after a transfer

Quoted 6 lines

---

cpu/mpc85xx/cpu.c            |    8 ++++----
cpu/mpc86xx/cpu.c            |   14 ++++++++------
include/asm-ppc/immap_86xx.h |    2 ++
3 files changed, 14 insertions(+), 10 deletions(-)

applied to next

- k

#5 lore raw

PATCH 3/11 85xx, 86xx: Break out DMA code to a common file

In reply to Peter Tyser

DMA support is now enabled via the CONFIG_FSL_DMA define instead of the previous CONFIG_DDR_ECC

---
 cpu/mpc85xx/cpu.c       |   47 ------------------------
 cpu/mpc86xx/cpu.c       |   55 ----------------------------
 drivers/dma/Makefile    |    1 +
 drivers/dma/fsl_dma.c   |   92 +++++++++++++++++++++++++++++++++++++++++++++++
 include/configs/PM854.h |    1 +
 include/configs/PM856.h |    1 +
 6 files changed, 95 insertions(+), 102 deletions(-)
 create mode 100644 drivers/dma/fsl_dma.c
cpu/mpc85xx/cpu.c +0 -47
index 86b19a6..416ea08 100644
@@ -258,53 +258,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.
cpu/mpc86xx/cpu.c +0 -55

61 lines not on this page · raw message

drivers/dma/Makefile +1 -0
index cf29efa..36d99f9 100644
@@ -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)
drivers/dma/fsl_dma.c new file +92 -0

92 lines not on this page · raw message

include/configs/PM854.h +1 -0
index 3f943aa..4b9bcca 100644
@@ -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
 
include/configs/PM856.h +1 -0
index 43c2873..1db20bc 100644
@@ -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
 
Signature · 1 line
1.6.2.1
#6 lore raw

PATCH 3/11 85xx, 86xx: Break out DMA code to a common file

Quoted 14 lines · Peter Tyser

DMA support is now enabled via the CONFIG_FSL_DMA define instead of the
previous CONFIG_DDR_ECC

---

cpu/mpc85xx/cpu.c       |   47 ------------------------
cpu/mpc86xx/cpu.c       |   55 ----------------------------
drivers/dma/Makefile    |    1 +
drivers/dma/fsl_dma.c   |   92 ++++++++++++++++++++++++++++++++++++++ 
+++++++++
include/configs/PM854.h |    1 +
include/configs/PM856.h |    1 +
6 files changed, 95 insertions(+), 102 deletions(-)
Quoted 1 line

create mode 100644 drivers/dma/fsl_dma.c

We should add something to include/asm-ppc/config.h to ensure CONFIG_FSL_DMA is set if CONFIG_DDR_ECC is.

#if defined(CONFIG_DDR_ECC) && (defined(CONFIG_MPC86xx) || defined(CONFIG_MPC85xx))
#define CONFIG_FSL_DMA
#endif

- k

Quoted 279 lines
cpu/mpc85xx/cpu.c +0 -47
index 86b19a6..416ea08 100644
@@ -258,53 +258,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.

cpu/mpc86xx/cpu.c +0 -55
index d47cc5e..1f26ba1 100644
@@ -177,61 +177,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

drivers/dma/Makefile +0 -0
index cf29efa..36d99f9 100644
@@ -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)

drivers/dma/fsl_dma.c new file +33 -0
new file mode 100644
index 0000000..a9989ee
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004,2007,2008 Freescale Semiconductor, Inc.
+ * (C) Copyright 2002, 2003 Motorola Inc.
+ * Xianghua Xiao (X.Xiao at motorola.com)
+ *
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd at 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);

drivers/dma/fsl_dma.c new file +2 -0
+#elif defined(CONFIG_MPC86xx)
+volatile ccsr_dma_t *dma_base = (void *) 

(CONFIG_SYS_MPC86xx_DMA_ADDR);

drivers/dma/fsl_dma.c new file +57 -0
+#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();
+}
include/configs/PM854.h +0 -0
index 3f943aa..4b9bcca 100644
@@ -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

include/configs/PM856.h +0 -0
index 43c2873..1db20bc 100644
@@ -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

Signature · 6 lines
1.6.2.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#7 lore raw

PATCH 4/11 fsl_dma: Add bitfield definitions for common registers

In reply to Peter Tyser
---
 drivers/dma/fsl_dma.c     |   12 +++++-----
 include/asm-ppc/fsl_dma.h |   46 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 6 deletions(-)
drivers/dma/fsl_dma.c +6 -6
index a9989ee..baf2942 100644
@@ -51,11 +51,11 @@ static uint dma_check(void) {
 	volatile uint status = dma->sr;
 
 	/* While the channel is busy, spin */
-	while (status & 4)
+	while (status & FSL_DMA_SR_CB)
 		status = dma->sr;
 
 	/* clear MR[CS] channel start bit */
-	dma->mr &= 1;
+	dma->mr &= FSL_DMA_MR_CS;
 	dma_sync();
 
 	if (status != 0)
@@ -67,8 +67,8 @@ static uint dma_check(void) {
 void dma_init(void) {
 	volatile fsl_dma_t *dma = &dma_base->dma[0];
 
-	dma->satr = 0x00040000;
-	dma->datr = 0x00040000;
+	dma->satr = FSL_DMA_SATR_SREAD_NO_SNOOP;
+	dma->datr = FSL_DMA_DATR_DWRITE_NO_SNOOP;
 	dma->sr = 0xffffffff; /* clear any errors */
 	dma_sync();
 }
@@ -81,11 +81,11 @@ int dma_xfer(void *dest, uint count, void *src) {
 	dma->bcr = count;
 
 	/* Disable bandwidth control, use direct transfer mode */
-	dma->mr = 0xf000004;
+	dma->mr = FSL_DMA_MR_BWC_DIS | FSL_DMA_MR_CTM_DIRECT;
 	dma_sync();
 
 	/* Start the transfer */
-	dma->mr = 0xf000005;
+	dma->mr = FSL_DMA_MR_BWC_DIS | FSL_DMA_MR_CTM_DIRECT | FSL_DMA_MR_CS;
 	dma_sync();
 
 	return dma_check();
include/asm-ppc/fsl_dma.h +46 -0

58 lines not on this page · raw message

Signature · 1 line
1.6.2.1
#8 lore raw

PATCH 5/11 fsl_dma: Update to use proper I/O accessor functions

In reply to Peter Tyser
---
 drivers/dma/fsl_dma.c |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)
drivers/dma/fsl_dma.c +18 -14
index baf2942..33ea828 100644
@@ -27,12 +27,13 @@
 
 #include <config.h>
 #include <common.h>
+#include <asm/io.h>
 #include <asm/fsl_dma.h>
 
 #if defined(CONFIG_MPC85xx)
-volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
+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);
+ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR);
 #else
 #error "Freescale DMA engine not supported on your processor"
 #endif
@@ -48,14 +49,15 @@ static void dma_sync(void)
 
 static uint dma_check(void) {
 	volatile fsl_dma_t *dma = &dma_base->dma[0];
-	volatile uint status = dma->sr;
+	uint status;
 
 	/* While the channel is busy, spin */
-	while (status & FSL_DMA_SR_CB)
-		status = dma->sr;
+	do {
+		status = in_be32(&dma->sr);
+	} while (status & FSL_DMA_SR_CB);
 
 	/* clear MR[CS] channel start bit */
-	dma->mr &= FSL_DMA_MR_CS;
+	out_be32(&dma->mr, in_be32(&dma->mr) & FSL_DMA_MR_CS);
 	dma_sync();
 
 	if (status != 0)
@@ -67,25 +69,27 @@ static uint dma_check(void) {
 void dma_init(void) {
 	volatile fsl_dma_t *dma = &dma_base->dma[0];
 
-	dma->satr = FSL_DMA_SATR_SREAD_NO_SNOOP;
-	dma->datr = FSL_DMA_DATR_DWRITE_NO_SNOOP;
-	dma->sr = 0xffffffff; /* clear any errors */
+	out_be32(&dma->satr, FSL_DMA_SATR_SREAD_NO_SNOOP);
+	out_be32(&dma->datr, FSL_DMA_DATR_DWRITE_NO_SNOOP);
+	out_be32(&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;
+	out_be32(&dma->dar, (uint) dest);
+	out_be32(&dma->sar, (uint) src);
+	out_be32(&dma->bcr, count);
 
 	/* Disable bandwidth control, use direct transfer mode */
-	dma->mr = FSL_DMA_MR_BWC_DIS | FSL_DMA_MR_CTM_DIRECT;
+	out_be32(&dma->mr, FSL_DMA_MR_BWC_DIS | FSL_DMA_MR_CTM_DIRECT);
 	dma_sync();
 
 	/* Start the transfer */
-	dma->mr = FSL_DMA_MR_BWC_DIS | FSL_DMA_MR_CTM_DIRECT | FSL_DMA_MR_CS;
+	out_be32(&dma->mr, FSL_DMA_MR_BWC_DIS |
+			FSL_DMA_MR_CTM_DIRECT |
+			FSL_DMA_MR_CS);
 	dma_sync();
 
 	return dma_check();
Signature · 1 line
1.6.2.1
#9 lore raw

PATCH 6/11 fsl_dma: Add support for arbitrarily large transfers

In reply to Peter Tyser

Support DMA transfers larger than the DMA controller's limit of (2 ^ 26 - 1) bytes

---
 drivers/dma/fsl_dma.c |   42 ++++++++++++++++++++++++++++++------------
 1 files changed, 30 insertions(+), 12 deletions(-)
drivers/dma/fsl_dma.c +30 -12
index 33ea828..91a6d84 100644
@@ -30,6 +30,9 @@
 #include <asm/io.h>
 #include <asm/fsl_dma.h>
 
+/* Controller can only transfer 2^26 - 1 bytes at a time */
+#define FSL_DMA_MAX_SIZE	(0x3ffffff)
+
 #if defined(CONFIG_MPC85xx)
 ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC85xx_DMA_ADDR);
 #elif defined(CONFIG_MPC86xx)
@@ -77,20 +80,35 @@ void dma_init(void) {
 
 int dma_xfer(void *dest, uint count, void *src) {
 	volatile fsl_dma_t *dma = &dma_base->dma[0];
+	uint xfer_size;
 
-	out_be32(&dma->dar, (uint) dest);
-	out_be32(&dma->sar, (uint) src);
-	out_be32(&dma->bcr, count);
+	while (count) {
+		xfer_size = MIN(FSL_DMA_MAX_SIZE, count);
 
-	/* Disable bandwidth control, use direct transfer mode */
-	out_be32(&dma->mr, FSL_DMA_MR_BWC_DIS | FSL_DMA_MR_CTM_DIRECT);
-	dma_sync();
+		debug("count = 0x%x, xfer_size = 0x%x, src = %p, dest = %p\n",
+			count, xfer_size, src, dest);
+		out_be32(&dma->dar, (uint) dest);
+		out_be32(&dma->sar, (uint) src);
+		out_be32(&dma->bcr, xfer_size);
 
-	/* Start the transfer */
-	out_be32(&dma->mr, FSL_DMA_MR_BWC_DIS |
-			FSL_DMA_MR_CTM_DIRECT |
-			FSL_DMA_MR_CS);
-	dma_sync();
+		/* Disable bandwidth control, use direct transfer mode */
+		out_be32(&dma->mr, FSL_DMA_MR_BWC_DIS | FSL_DMA_MR_CTM_DIRECT);
+		dma_sync();
+
+		/* Start the transfer */
+		out_be32(&dma->mr, FSL_DMA_MR_BWC_DIS |
+				FSL_DMA_MR_CTM_DIRECT |
+				FSL_DMA_MR_CS);
+
+		count -= xfer_size;
+		src += xfer_size;
+		dest += xfer_size;
+
+		dma_sync();
+
+		if (dma_check())
+			return -1;
+	}
 
-	return dma_check();
+	return 0;
 }
Signature · 1 line
1.6.2.1
#10 lore raw

PATCH 7/11 fsl_dma: Fix Channel Start bug in dma_check()

In reply to Peter Tyser

The Channel Start (CS) bit in the Mode Register (MR) should actually be cleared as the comment in the code suggests. Previously, CS was being set, not cleared.

Assuming normal operation of the DMA engine, this change shouldn't have any real affect.

---
 drivers/dma/fsl_dma.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/dma/fsl_dma.c +1 -1
index 91a6d84..d41f04c 100644
@@ -60,7 +60,7 @@ static uint dma_check(void) {
 	} while (status & FSL_DMA_SR_CB);
 
 	/* clear MR[CS] channel start bit */
-	out_be32(&dma->mr, in_be32(&dma->mr) & FSL_DMA_MR_CS);
+	out_be32(&dma->mr, in_be32(&dma->mr) & ~FSL_DMA_MR_CS);
 	dma_sync();
 
 	if (status != 0)
Signature · 1 line
1.6.2.1
#11 lore raw

PATCH 8/11 8xxx: Rename dma_xfer() to dmacpy()

In reply to Peter Tyser

Also update dmacpy()'s argument order and type to match memcpy's for clarity

---
 board/mpc8540eval/mpc8540eval.c |   22 +++++++++++-----------
 board/sbc8560/sbc8560.c         |   22 +++++++++++-----------
 cpu/mpc83xx/cpu.c               |    4 ++--
 cpu/mpc83xx/spd_sdram.c         |   24 ++++++++++++------------
 cpu/mpc85xx/ddr-gen1.c          |   24 ++++++++++++------------
 drivers/dma/fsl_dma.c           |   12 ++++++------
 6 files changed, 54 insertions(+), 54 deletions(-)
board/mpc8540eval/mpc8540eval.c +11 -11
index 72a1ad3..3d395c6 100644
@@ -148,28 +148,28 @@ phys_size_t initdram (int board_type)
 		}
 
 		/* 8K */
-		dma_xfer((uint *)0x2000,0x2000,(uint *)0);
+		dmacpy((uint *)0x2000, (uint *)0, 0x2000);
 		/* 16K */
-		dma_xfer((uint *)0x4000,0x4000,(uint *)0);
+		dmacpy((uint *)0x4000, (uint *)0, 0x4000);
 		/* 32K */
-		dma_xfer((uint *)0x8000,0x8000,(uint *)0);
+		dmacpy((uint *)0x8000, (uint *)0, 0x8000);
 		/* 64K */
-		dma_xfer((uint *)0x10000,0x10000,(uint *)0);
+		dmacpy((uint *)0x10000, (uint *)0, 0x10000);
 		/* 128k */
-		dma_xfer((uint *)0x20000,0x20000,(uint *)0);
+		dmacpy((uint *)0x20000, (uint *)0, 0x20000);
 		/* 256k */
-		dma_xfer((uint *)0x40000,0x40000,(uint *)0);
+		dmacpy((uint *)0x40000, (uint *)0, 0x40000);
 		/* 512k */
-		dma_xfer((uint *)0x80000,0x80000,(uint *)0);
+		dmacpy((uint *)0x80000, (uint *)0, 0x80000);
 		/* 1M */
-		dma_xfer((uint *)0x100000,0x100000,(uint *)0);
+		dmacpy((uint *)0x100000, (uint *)0, 0x100000);
 		/* 2M */
-		dma_xfer((uint *)0x200000,0x200000,(uint *)0);
+		dmacpy((uint *)0x200000, (uint *)0, 0x200000);
 		/* 4M */
-		dma_xfer((uint *)0x400000,0x400000,(uint *)0);
+		dmacpy((uint *)0x400000, (uint *)0, 0x400000);
 
 		for (i = 1; i < dram_size / 0x800000; i++) {
-			dma_xfer((uint *)(0x800000*i),0x800000,(uint *)0);
+			dmacpy((uint *)(0x800000*i), (uint *)0, 0x800000);
 		}
 
 		/* Enable errors for ECC */
board/sbc8560/sbc8560.c +11 -11
index 7f032c8..0b8e3e5 100644
@@ -349,28 +349,28 @@ phys_size_t initdram (int board_type)
 		}
 
 		/* 8K */
-		dma_xfer((uint *)0x2000,0x2000,(uint *)0);
+		dmacpy((uint *)0x2000, (uint *)0, 0x2000);
 		/* 16K */
-		dma_xfer((uint *)0x4000,0x4000,(uint *)0);
+		dmacpy((uint *)0x4000, (uint *)0, 0x4000);
 		/* 32K */
-		dma_xfer((uint *)0x8000,0x8000,(uint *)0);
+		dmacpy((uint *)0x8000, (uint *)0, 0x8000);
 		/* 64K */
-		dma_xfer((uint *)0x10000,0x10000,(uint *)0);
+		dmacpy((uint *)0x10000, (uint *)0, 0x10000);
 		/* 128k */
-		dma_xfer((uint *)0x20000,0x20000,(uint *)0);
+		dmacpy((uint *)0x20000, (uint *)0, 0x20000);
 		/* 256k */
-		dma_xfer((uint *)0x40000,0x40000,(uint *)0);
+		dmacpy((uint *)0x40000, (uint *)0, 0x40000);
 		/* 512k */
-		dma_xfer((uint *)0x80000,0x80000,(uint *)0);
+		dmacpy((uint *)0x80000, (uint *)0, 0x80000);
 		/* 1M */
-		dma_xfer((uint *)0x100000,0x100000,(uint *)0);
+		dmacpy((uint *)0x100000, (uint *)0, 0x100000);
 		/* 2M */
-		dma_xfer((uint *)0x200000,0x200000,(uint *)0);
+		dmacpy((uint *)0x200000, (uint *)0, 0x200000);
 		/* 4M */
-		dma_xfer((uint *)0x400000,0x400000,(uint *)0);
+		dmacpy((uint *)0x400000, (uint *)0, 0x400000);
 
 		for (i = 1; i < dram_size / 0x800000; i++) {
-			dma_xfer((uint *)(0x800000*i),0x800000,(uint *)0);
+			dmacpy((uint *)(0x800000*i), (uint *)0, 0x800000);
 		}
 
 		/* Enable errors for ECC */
cpu/mpc83xx/cpu.c +2 -2
index 876f5c7..3b93a32 100644
@@ -327,7 +327,7 @@ uint dma_check(void)
 	return status;
 }
 
-int dma_xfer(void *dest, u32 count, void *src)
+int dmacpy(void *dest, const void *src, size_t count)
 {
 	volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
 	volatile dma83xx_t *dma = &immap->dma;
@@ -336,7 +336,7 @@ int dma_xfer(void *dest, u32 count, void *src)
 	/* initialize DMASARn, DMADAR and DMAABCRn */
 	dma->dmadar0 = swab32((u32)dest);
 	dma->dmasar0 = swab32((u32)src);
-	dma->dmabcr0 = swab32(count);
+	dma->dmabcr0 = swab32((u32)count);
 
 	__asm__ __volatile__ ("sync");
 	__asm__ __volatile__ ("isync");
cpu/mpc83xx/spd_sdram.c +12 -12
index 4704d20..12dad75 100644
@@ -68,7 +68,7 @@ void board_add_ram_info(int use_default)
 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
 extern void dma_init(void);
 extern uint dma_check(void);
-extern int dma_xfer(void *dest, uint count, void *src);
+extern int dmacpy(void *dest, const void *src, size_t n);
 #endif
 
 #ifndef	CONFIG_SYS_READ_SPD
@@ -898,19 +898,19 @@ void ddr_enable_ecc(unsigned int dram_size)
 	/* Initialise DMA for direct transfer */
 	dma_init();
 	/* Start DMA to transfer */
-	dma_xfer((uint *)0x2000, 0x2000, (uint *)0); /* 8K */
-	dma_xfer((uint *)0x4000, 0x4000, (uint *)0); /* 16K */
-	dma_xfer((uint *)0x8000, 0x8000, (uint *)0); /* 32K */
-	dma_xfer((uint *)0x10000, 0x10000, (uint *)0); /* 64K */
-	dma_xfer((uint *)0x20000, 0x20000, (uint *)0); /* 128K */
-	dma_xfer((uint *)0x40000, 0x40000, (uint *)0); /* 256K */
-	dma_xfer((uint *)0x80000, 0x80000, (uint *)0); /* 512K */
-	dma_xfer((uint *)0x100000, 0x100000, (uint *)0); /* 1M */
-	dma_xfer((uint *)0x200000, 0x200000, (uint *)0); /* 2M */
-	dma_xfer((uint *)0x400000, 0x400000, (uint *)0); /* 4M */
+	dmacpy((uint *)0x2000, (uint *)0, 0x2000); /* 8K */
+	dmacpy((uint *)0x4000, (uint *)0, 0x4000); /* 16K */
+	dmacpy((uint *)0x8000, (uint *)0, 0x8000); /* 32K */
+	dmacpy((uint *)0x10000, (uint *)0, 0x10000); /* 64K */
+	dmacpy((uint *)0x20000, (uint *)0, 0x20000); /* 128K */
+	dmacpy((uint *)0x40000, (uint *)0, 0x40000); /* 256K */
+	dmacpy((uint *)0x80000, (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++) {
-		dma_xfer((uint *)(0x800000*i), 0x800000, (uint *)0);
+		dmacpy((uint *)(0x800000*i), (uint *)0, 0x800000);
 	}
 #endif
 
cpu/mpc85xx/ddr-gen1.c +12 -12
index e24c9af..7c7a458 100644
@@ -68,7 +68,7 @@ void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
 extern void dma_init(void);
 extern uint dma_check(void);
-extern int dma_xfer(void *dest, uint count, void *src);
+extern int dmacpy(void *dest, const void *src, size_t n);
 
 /*
  * Initialize all of memory for ECC, then enable errors.
@@ -93,19 +93,19 @@ ddr_enable_ecc(unsigned int dram_size)
 		}
 	}
 
-	dma_xfer((uint *)0x002000, 0x002000, (uint *)0); /* 8K */
-	dma_xfer((uint *)0x004000, 0x004000, (uint *)0); /* 16K */
-	dma_xfer((uint *)0x008000, 0x008000, (uint *)0); /* 32K */
-	dma_xfer((uint *)0x010000, 0x010000, (uint *)0); /* 64K */
-	dma_xfer((uint *)0x020000, 0x020000, (uint *)0); /* 128k */
-	dma_xfer((uint *)0x040000, 0x040000, (uint *)0); /* 256k */
-	dma_xfer((uint *)0x080000, 0x080000, (uint *)0); /* 512k */
-	dma_xfer((uint *)0x100000, 0x100000, (uint *)0); /* 1M */
-	dma_xfer((uint *)0x200000, 0x200000, (uint *)0); /* 2M */
-	dma_xfer((uint *)0x400000, 0x400000, (uint *)0); /* 4M */
+	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++) {
-		dma_xfer((uint *)(0x800000*i), 0x800000, (uint *)0);
+		dmacpy((uint *)(0x800000*i), (uint *)0, 0x800000);
 	}
 
 	/*
drivers/dma/fsl_dma.c +6 -6
index d41f04c..90eeef7 100644
@@ -78,15 +78,15 @@ void dma_init(void) {
 	dma_sync();
 }
 
-int dma_xfer(void *dest, uint count, void *src) {
+int dmacpy(void *dest, const void *src, size_t n) {
 	volatile fsl_dma_t *dma = &dma_base->dma[0];
 	uint xfer_size;
 
-	while (count) {
-		xfer_size = MIN(FSL_DMA_MAX_SIZE, count);
+	while (n) {
+		xfer_size = MIN(FSL_DMA_MAX_SIZE, n);
 
-		debug("count = 0x%x, xfer_size = 0x%x, src = %p, dest = %p\n",
-			count, xfer_size, src, dest);
+		debug("size = 0x%x, xfer_size = 0x%x, src = %p, dest = %p\n",
+			n, xfer_size, src, dest);
 		out_be32(&dma->dar, (uint) dest);
 		out_be32(&dma->sar, (uint) src);
 		out_be32(&dma->bcr, xfer_size);
@@ -100,7 +100,7 @@ int dma_xfer(void *dest, uint count, void *src) {
 				FSL_DMA_MR_CTM_DIRECT |
 				FSL_DMA_MR_CS);
 
-		count -= xfer_size;
+		n -= xfer_size;
 		src += xfer_size;
 		dest += xfer_size;
 
Signature · 1 line
1.6.2.1
#12 lore raw

PATCH 8/11 8xxx: Rename dma_xfer() to dmacpy()

drivers/dma/fsl_dma.c void dma_init(void) { · line 81

Quoted 2 lines · Peter Tyser
drivers/dma/fsl_dma.c +1 -1
-int dma_xfer(void *dest, uint count, void *src) {
+int dmacpy(void *dest, const void *src, size_t n) {

While we're changing this, perhaps it should take phys_addr_t rather than pointers?

-Scott

#13 lore raw

PATCH 8/11 8xxx: Rename dma_xfer() to dmacpy()

Quoted 6 lines · Scott Wood

drivers/dma/fsl_dma.c void dma_init(void) { · line 81

Quoted 2 lines · Peter Tyser
drivers/dma/fsl_dma.c +1 -1
-int dma_xfer(void *dest, uint count, void *src) {
+int dmacpy(void *dest, const void *src, size_t n) {

While we're changing this, perhaps it should take phys_addr_t rather than pointers?

It looks like addresses > 32bits can be used by using a few bits in the SATR/DATR so you're right, using phys_addr_t/phys_size_t makes sense.

Thanks,
Peter

#14 lore raw

PATCH 9/11 fsl_dma: Move dma function prototypes to common header file

In reply to Peter Tyser
---
 cpu/mpc85xx/ddr-gen1.c    |    4 ----
 include/asm-ppc/fsl_dma.h |    5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
cpu/mpc85xx/ddr-gen1.c +0 -4
index 7c7a458..6e628bd 100644
@@ -66,10 +66,6 @@ void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
 }
 
 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-extern void dma_init(void);
-extern uint dma_check(void);
-extern int dmacpy(void *dest, const void *src, size_t n);
-
 /*
  * Initialize all of memory for ECC, then enable errors.
  */
include/asm-ppc/fsl_dma.h +5 -0
index c9ec6b5..06ecdcd 100644
@@ -94,4 +94,9 @@ typedef struct fsl_dma {
 	char	res4[56];
 } fsl_dma_t;
 
+#ifdef CONFIG_FSL_DMA
+void dma_init(void);
+int dmacpy(void *dest, const void *src, size_t n);
+#endif
+
 #endif	/* _ASM_DMA_H_ */
Signature · 1 line
1.6.2.1
#15 lore raw

PATCH 9/11 fsl_dma: Move dma function prototypes to common header file

Quoted 28 lines · Peter Tyser

---

cpu/mpc85xx/ddr-gen1.c    |    4 ----
include/asm-ppc/fsl_dma.h |    5 +++++
2 files changed, 5 insertions(+), 4 deletions(-)
cpu/mpc85xx/ddr-gen1.c +0 -4
index 7c7a458..6e628bd 100644
@@ -66,10 +66,6 @@ void fsl_ddr_set_memctl_regs(const  
 fsl_ddr_cfg_regs_t *regs,
 }
 
 #if defined(CONFIG_DDR_ECC) && ! 
 defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-extern void dma_init(void);
-extern uint dma_check(void);
-extern int dmacpy(void *dest, const void *src, size_t n);
-
 /*

* Initialize all of memory for ECC, then enable errors. */

include/asm-ppc/fsl_dma.h +0 -0
index c9ec6b5..06ecdcd 100644

include/asm-ppc/fsl_dma.h typedef struct fsl_dma { · line 101

Quoted 8 lines
include/asm-ppc/fsl_dma.h +5 -0
@@ -94,4 +94,9 @@ typedef struct fsl_dma {
 	char	res4[56];
 } fsl_dma_t;
 
+#ifdef CONFIG_FSL_DMA
+void dma_init(void);
+int dmacpy(void *dest, const void *src, size_t n);
+#endif
+

#ifdef protection here seems kinda pointless

- k

#16 lore raw

PATCH 9/11 fsl_dma: Move dma function prototypes to common header file

Hi Kumar,

Quoted 8 lines
Quoted 8 lines
include/asm-ppc/fsl_dma.h +0 -0
index c9ec6b5..06ecdcd 100644
@@ -94,4 +94,9 @@ typedef struct fsl_dma {
 	char	res4[56];
 } fsl_dma_t;
 
Quoted 7 lines

include/asm-ppc/fsl_dma.h typedef struct fsl_dma { · line 101

Quoted 5 lines
include/asm-ppc/fsl_dma.h +5 -0
+#ifdef CONFIG_FSL_DMA
+void dma_init(void);
+int dmacpy(void *dest, const void *src, size_t n);
+#endif
+

#ifdef protection here seems kinda pointless

Most boards won't have CONFIG_FSL_DMA defined, but this file will still be used in the immap_86xx.h files for padding immap_t. I figured most users won't have dma_init() or dmacpy() so the protection wouldn't hurt.

Peter

#17 lore raw

PATCH 9/11 fsl_dma: Move dma function prototypes to common header file

Quoted 18 lines · Peter Tyser

Hi Kumar,

Quoted 8 lines
Quoted 8 lines
include/asm-ppc/fsl_dma.h +0 -0
index c9ec6b5..06ecdcd 100644
@@ -94,4 +94,9 @@ typedef struct fsl_dma {
 	char	res4[56];
 } fsl_dma_t;
 
Quoted 7 lines

include/asm-ppc/fsl_dma.h typedef struct fsl_dma { · line 101

Quoted 5 lines
include/asm-ppc/fsl_dma.h +5 -0
+#ifdef CONFIG_FSL_DMA
+void dma_init(void);
+int dmacpy(void *dest, const void *src, size_t n);
+#endif
+

#ifdef protection here seems kinda pointless

Quoted 7 lines

Most boards won't have CONFIG_FSL_DMA defined, but this file will still
be used in the immap_86xx.h files for padding immap_t. I figured most users won't have dma_init() or dmacpy() so the protection wouldn't hurt.

Peter

that's fine.. do you plan on respinning the other patches that had comments?

- k

#18 lore raw

PATCH 9/11 fsl_dma: Move dma function prototypes to common header file

Hi Kumar,

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

#ifdef protection here seems kinda pointless

Most boards won't have CONFIG_FSL_DMA defined, but this file will still
be used in the immap_86xx.h files for padding immap_t. I figured most users won't have dma_init() or dmacpy() so the protection wouldn't hurt.

Quoted 4 lines
Quoted 1 line

Peter

that's fine.. do you plan on respinning the other patches that had comments?

Yes, I will resend today.

Peter

#19 lore raw

PATCH 10/11 85xx, 86xx: Move dma_init() call to common code

In reply to Peter Tyser
---
 board/mpc8540eval/mpc8540eval.c |    2 +-
 board/sbc8560/sbc8560.c         |    2 +-
 cpu/mpc85xx/cpu_init.c          |    4 +++-
 cpu/mpc85xx/ddr-gen1.c          |    2 --
 cpu/mpc86xx/cpu_init.c          |    3 +++
 5 files changed, 8 insertions(+), 5 deletions(-)
board/mpc8540eval/mpc8540eval.c +1 -1
index 3d395c6..27d7a3d 100644
@@ -140,7 +140,7 @@ phys_size_t initdram (int board_type)
 		uint *p = 0;
 		uint i = 0;
 		volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
-		dma_init();
+
 		for (*p = 0; p < (uint *)(8 * 1024); p++) {
 			if (((unsigned int)p & 0x1f) == 0) { dcbz(p); }
 			*p = (unsigned int)0xdeadbeef;
board/sbc8560/sbc8560.c +1 -1
index 0b8e3e5..64d4154 100644
@@ -341,7 +341,7 @@ phys_size_t initdram (int board_type)
 		uint *p = 0;
 		uint i = 0;
 		volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
-		dma_init();
+
 		for (*p = 0; p < (uint *)(8 * 1024); p++) {
 			if (((unsigned int)p & 0x1f) == 0) { dcbz(p); }
 			*p = (unsigned int)0xdeadbeef;
cpu/mpc85xx/cpu_init.c +3 -1
index c98dd8d..41de694 100644
@@ -261,7 +261,9 @@ void cpu_init_f (void)
 #if defined(CONFIG_MPC8536)
 	fsl_serdes_init();
 #endif
-
+#if defined(CONFIG_FSL_DMA)
+	dma_init();
+#endif
 }
 
 
cpu/mpc85xx/ddr-gen1.c +0 -2
index 6e628bd..5529021 100644
@@ -77,8 +77,6 @@ ddr_enable_ecc(unsigned int dram_size)
 	uint i = 0;
 	volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
 
-	dma_init();
-
 	for (*p = 0; p < (uint *)(8 * 1024); p++) {
 		if (((unsigned int)p & 0x1f) == 0) {
 			ppcDcbz((unsigned long) p);
cpu/mpc86xx/cpu_init.c +3 -0
index 49528aa..341e815 100644
@@ -113,6 +113,9 @@ void cpu_init_f(void)
 	memctl->or7 = CONFIG_SYS_OR7_PRELIM;
 	memctl->br7 = CONFIG_SYS_BR7_PRELIM;
 #endif
+#if defined(CONFIG_FSL_DMA)
+	dma_init();
+#endif
 
 	/* enable the timebase bit in HID0 */
 	set_hid0(get_hid0() | 0x4000000);
Signature · 1 line
1.6.2.1
#20 lore raw

PATCH 11/11 fsl_dma: Break out common memory initialization function

In reply to Peter Tyser
---
 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(-)
board/mpc8540eval/mpc8540eval.c +1 -32
index 27d7a3d..7c27233 100644
@@ -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;
board/sbc8560/sbc8560.c +1 -32
index 64d4154..c40b5e3 100644
@@ -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;
cpu/mpc85xx/ddr-gen1.c +1 -26
index 5529021..54437dd 100644
@@ -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.
drivers/dma/fsl_dma.c +32 -0
index 90eeef7..b7497b5 100644
@@ -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
include/asm-ppc/fsl_dma.h +3 -0
index 06ecdcd..dd92343 100644
@@ -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_ */
Signature · 1 line
1.6.2.1
#21 lore raw

cover 85xx/86xx dma updates

In reply to Peter Tyser
Quoted 9 lines · Peter Tyser

This patch series attempts to clean up the DMA implementation for the 85xx and 86xx architectures. The changes include:
- consolidate 85xx and 86xx structures and code
- add defines for bitfields
- use proper IO accessors
- add support for arbitrarily large transfer sizes
- rename dma_xfer() to dmacpy() and make dmacpy's prototype similar to memcpy()

Quoted 8 lines

The patches are based on the mainline "next" branch.

I've tested the code on MPC8572 and MPC8640-based boards.

I'm not initimately familar with the 83xx platform, but at a glance it looked like the fsl_dma driver could be extended to support it with some ifdeffery.

I've been doing some Linux work with the 83xx DMA controller. The only real differences between the 83xx/85xx controller are the register endianness and snoop bits. The 83xx controller's registers are all little-endian, while the 85xx is all big-endian.

Also, there are some snoop bits that need to be enabled on 83xx as well, in the control register as well as in each descriptor if you're running in chaining mode.

That's everything that I've noticed that is different. I don't have an 85xx/86xx to test anything with, but I'm happy to run some tests on my mpc8349emds if you want to try adding support for 83xx.

Ira

#22 lore raw

cover 85xx/86xx dma updates

Quoted 24 lines · Ira Snyder
Quoted 9 lines · Peter Tyser

This patch series attempts to clean up the DMA implementation for the 85xx and 86xx architectures. The changes include:
- consolidate 85xx and 86xx structures and code
- add defines for bitfields
- use proper IO accessors
- add support for arbitrarily large transfer sizes
- rename dma_xfer() to dmacpy() and make dmacpy's prototype similar to memcpy()

Quoted 8 lines

The patches are based on the mainline "next" branch.

I've tested the code on MPC8572 and MPC8640-based boards.

I'm not initimately familar with the 83xx platform, but at a glance it looked like the fsl_dma driver could be extended to support it with some ifdeffery.

I've been doing some Linux work with the 83xx DMA controller. The only real differences between the 83xx/85xx controller are the register endianness and snoop bits. The 83xx controller's registers are all little-endian, while the 85xx is all big-endian.

Quoted 7 lines

Also, there are some snoop bits that need to be enabled on 83xx as well, in the control register as well as in each descriptor if you're running in chaining mode.

That's everything that I've noticed that is different. I don't have an 85xx/86xx to test anything with, but I'm happy to run some tests on my mpc8349emds if you want to try adding support for 83xx.

Thanks!

I believe some of the register locations are slightly different too, for example the source address on the 85xx is at offset 0x114 while its at 0x110 on the 83xx.

I don't think any 83xx boards currently use the 83xx DMA implementation in cpu/mpc83xx/cpu.c. Before spending any time on the 83xx, is there any good reason to support the 83xx in U-Boot? There would be no users of the updated implementation as is.

Best,
Peter

#23 lore raw

cover 85xx/86xx dma updates

Quoted 35 lines · Peter Tyser
Quoted 24 lines · Ira Snyder
Quoted 9 lines · Peter Tyser

This patch series attempts to clean up the DMA implementation for the 85xx and 86xx architectures. The changes include:
- consolidate 85xx and 86xx structures and code
- add defines for bitfields
- use proper IO accessors
- add support for arbitrarily large transfer sizes
- rename dma_xfer() to dmacpy() and make dmacpy's prototype similar to memcpy()

Quoted 8 lines

The patches are based on the mainline "next" branch.

I've tested the code on MPC8572 and MPC8640-based boards.

I'm not initimately familar with the 83xx platform, but at a glance it looked like the fsl_dma driver could be extended to support it with some ifdeffery.

I've been doing some Linux work with the 83xx DMA controller. The only real differences between the 83xx/85xx controller are the register endianness and snoop bits. The 83xx controller's registers are all little-endian, while the 85xx is all big-endian.

Quoted 7 lines

Also, there are some snoop bits that need to be enabled on 83xx as well, in the control register as well as in each descriptor if you're running in chaining mode.

That's everything that I've noticed that is different. I don't have an 85xx/86xx to test anything with, but I'm happy to run some tests on my mpc8349emds if you want to try adding support for 83xx.

Thanks!

Quoted 9 lines

I believe some of the register locations are slightly different too, for example the source address on the 85xx is at offset 0x114 while its at 0x110 on the 83xx.

I don't think any 83xx boards currently use the 83xx DMA implementation in cpu/mpc83xx/cpu.c. Before spending any time on the 83xx, is there any good reason to support the 83xx in U-Boot? There would be no users of the updated implementation as is.

I think there is an option for the mpc8349emds to use the DMA controller to initialize the RAM for ECC mode. I tried using it, and it was much slower than using the CPU.

I'll probably end up writing a virtual network driver for U-Boot eventually. In the Linux version, I've used the DMA controller to handle transferring data over PCI. It is much faster than the CPU, but I'll only be transferring a few megabytes from within U-Boot anyway.

In short, having the driver ported to 83xx would make some of my future development easier, but there aren't any serious in-tree users at the moment (to the best of my knowledge).

Ira

#24 lore raw

cover 85xx/86xx dma updates

In reply to Ira Snyder
Quoted 4 lines · Ira Snyder

I've been doing some Linux work with the 83xx DMA controller. The only real differences between the 83xx/85xx controller are the register endianness and snoop bits. The 83xx controller's registers are all little-endian, while the 85xx is all big-endian.

83xx DMA = Elo DMA controller
85xx/86xx DMA = Elo Plus DMA controller

The Elo Plus supports list descriptors in addition to link descriptors. The Elo only supports link descriptors.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale