[PATCH 05/11] ARM: add generic PrimeCell interface to COH 901 318 v5

Previous thread: [PATCH 04/11] ARM: define the PrimeCell DMA API v5 by Linus Walleij on Wednesday, April 7, 2010 - 4:12 pm. (1 message)

Next thread: [PATCH 06/11] ARM: add generic PrimeCell interface to DMA40 v1 by Linus Walleij on Wednesday, April 7, 2010 - 4:13 pm. (1 message)
From: Linus Walleij
Date: Wednesday, April 7, 2010 - 4:12 pm

This extends the DMA engine driver for the COH 901 318 used in the
U300 platform with the generic PrimeCell interface.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/dma/coh901318.c     |  146 +++++++++++++++++++++++++++++++++++++++++++
 drivers/dma/coh901318_lli.c |   78 ++++++++++++++++++++++-
 2 files changed, 221 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index 4233440..1d5ed16 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -21,6 +21,7 @@
 #include <linux/uaccess.h>
 #include <linux/debugfs.h>
 #include <mach/coh901318.h>
+#include <linux/amba/dma.h>
 
 #include "coh901318_lli.h"
 
@@ -72,6 +73,9 @@ struct coh901318_chan {
 	unsigned long nbr_active_done;
 	unsigned long busy;
 
+	u32 amba_addr;
+	u32 amba_ctrl;
+
 	struct coh901318_base *base;
 };
 
@@ -190,6 +194,9 @@ static inline struct coh901318_chan *to_coh901318_chan(struct dma_chan *chan)
 static inline dma_addr_t
 cohc_dev_addr(struct coh901318_chan *cohc)
 {
+	/* PrimeCell supplied address will take precedence */
+	if (cohc->amba_addr)
+		return cohc->amba_addr;
 	return cohc->base->platform->chan_conf[cohc->id].dev_addr;
 }
 
@@ -1055,6 +1062,14 @@ coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
 
 	params = cohc_chan_param(cohc);
 	config = params->config;
+	/*
+	 * Add primecell-specific control on top, make
+	 * sure the bits you set per peripheral channel are
+	 * cleared in the default config from the platform.
+	 */
+	ctrl_chained |= cohc->amba_ctrl;
+	ctrl_last |= cohc->amba_ctrl;
+	ctrl |= cohc->amba_ctrl;
 
 	if (direction == DMA_TO_DEVICE) {
 		u32 tx_flags = COH901318_CX_CTRL_PRDD_SOURCE |
@@ -1113,6 +1128,12 @@ coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
 	if (ret)
 		goto err_lli_fill;
 
+	/*
+	 * Set the default ctrl for the channel to the one from the lli,
+	 * things may have changed due to odd buffer alignment ...
From: Dan Williams
Date: Wednesday, April 14, 2010 - 3:40 pm

Hi Linus,

On Wed, Apr 7, 2010 at 4:12 PM, Linus Walleij


It looks like this bit twiddling code is duplicated three times.  Can
it be moved to a static inline in a header file and hide the #if 0
there as well.  I assume you want it for documentation purposes in
case someone in the future has an unaligned usage model?

--
Dan
--

Previous thread: [PATCH 04/11] ARM: define the PrimeCell DMA API v5 by Linus Walleij on Wednesday, April 7, 2010 - 4:12 pm. (1 message)

Next thread: [PATCH 06/11] ARM: add generic PrimeCell interface to DMA40 v1 by Linus Walleij on Wednesday, April 7, 2010 - 4:13 pm. (1 message)