mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
To: Tony Lindgren <tony@atomide.com>
Cc: Jarkko Nikula <jhnikula@gmail.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Peter Ujfalusi <peter.ujfalusi@nokia.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"linux-arm-kernel@lists.arm.linux.org.uk" 
	<linux-arm-kernel@lists.arm.linux.org.uk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [RFC][PATCH 1/3] ARM: OMAP: DMA: Add support for DMA channel self linking on OMAP1510
Date: Mon, 10 Aug 2009 10:50:00 +0200	[thread overview]
Message-ID: <200908101050.02530.jkrzyszt@tis.icnet.pl> (raw)

Implement DMA channel self linking on OMAP1510 using AUTO_INIT and REPEAT
flags of the DMA CCR register.

Created against linux-2.6.31-rc5.

Tested on Amstrad Delta.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>

---
Note:
In its current form, enable_lnk() seems not very consistent (ie. result of a
conditional assignment is then overwritten unconditionally). As rather
different from OMAP1510 that I am familiar with, I am not quite sure how
support for other OMAP models should really look like. So I decided to leave
it as is and put my bit in a separate block, adding an additional FIXME
comment.

--- linux-2.6.31-rc5/arch/arm/plat-omap/dma.c.orig	2009-08-07 13:38:02.000000000 +0200
+++ linux-2.6.31-rc5/arch/arm/plat-omap/dma.c	2009-08-10 09:01:41.000000000 +0200
@@ -653,8 +653,21 @@ static inline void enable_lnk(int lch)
 {
 	u32 l;
 
+	if (omap_dma_in_1510_mode()) {
+		/* only self linking is supported */
+		if (dma_chan[lch].next_lch == lch) {
+			/* set AUTO_INIT | REPEAT bits in CCR */
+			l = dma_read(CCR(lch));
+			l |= 3 << 8;
+			dma_write(l, CCR(lch));
+		}
+		return;
+	}
+
 	l = dma_read(CLNK_CTRL(lch));
 
+	/* FIXME:
+	 * this conditional assignment is then overwritten unconditionally */
 	if (cpu_class_is_omap1())
 		l &= ~(1 << 14);
 
@@ -675,13 +688,21 @@ static inline void disable_lnk(int lch)
 {
 	u32 l;
 
-	l = dma_read(CLNK_CTRL(lch));
+	if (omap_dma_in_1510_mode())
+		l = dma_read(CCR(lch));
+	else
+		l = dma_read(CLNK_CTRL(lch));
 
 	/* Disable interrupts */
 	if (cpu_class_is_omap1()) {
 		dma_write(0, CICR(lch));
-		/* Set the STOP_LNK bit */
-		l |= 1 << 14;
+		if (omap_dma_in_1510_mode()) {
+			/* Unset AUTO_INIT & REPEAT bits */
+			l &= ~(3 << 8);
+		} else {
+			/* Set the STOP_LNK bit */
+			l |= 1 << 14;
+		}
 	}
 
 	if (cpu_class_is_omap2()) {
@@ -690,7 +711,10 @@ static inline void disable_lnk(int lch)
 		l &= ~(1 << 15);
 	}
 
-	dma_write(l, CLNK_CTRL(lch));
+	if (omap_dma_in_1510_mode())
+		dma_write(l, CCR(lch));
+	else
+		dma_write(l, CLNK_CTRL(lch));
 	dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE;
 }
 
@@ -928,7 +952,7 @@ void omap_start_dma(int lch)
 {
 	u32 l;
 
-	if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) {
+	if (dma_chan[lch].next_lch != -1) {
 		int next_lch, cur_lch;
 		char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT];
 
@@ -979,7 +1003,7 @@ void omap_stop_dma(int lch)
 {
 	u32 l;
 
-	if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) {
+	if (dma_chan[lch].next_lch != -1) {
 		int next_lch, cur_lch = lch;
 		char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT];
 
@@ -1130,7 +1154,7 @@ int omap_dma_running(void)
  */
 void omap_dma_link_lch(int lch_head, int lch_queue)
 {
-	if (omap_dma_in_1510_mode()) {
+	if (omap_dma_in_1510_mode() && (lch_head != lch_queue)) {
 		printk(KERN_ERR "DMA linking is not supported in 1510 mode\n");
 		BUG();
 		return;
@@ -1152,7 +1176,7 @@ EXPORT_SYMBOL(omap_dma_link_lch);
  */
 void omap_dma_unlink_lch(int lch_head, int lch_queue)
 {
-	if (omap_dma_in_1510_mode()) {
+	if (omap_dma_in_1510_mode() && (lch_head != lch_queue)) {
 		printk(KERN_ERR "DMA linking is not supported in 1510 mode\n");
 		BUG();
 		return;
@@ -1822,7 +1846,7 @@ static int omap1_dma_handle_ch(int ch)
 	if (unlikely(csr & OMAP_DMA_DROP_IRQ))
 		printk(KERN_WARNING "DMA synchronization event drop occurred "
 		       "with device %d\n", dma_chan[ch].dev_id);
-	if (likely(csr & OMAP_DMA_BLOCK_IRQ))
+	if (likely(csr & OMAP_DMA_BLOCK_IRQ) && (dma_chan[ch].next_lch != ch))
 		dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE;
 	if (likely(dma_chan[ch].callback != NULL))
 		dma_chan[ch].callback(ch, csr, dma_chan[ch].data);

             reply	other threads:[~2009-08-10  8:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10  8:50 Janusz Krzysztofik [this message]
2009-08-17  9:16 ` Jarkko Nikula
2009-08-23 15:56 ` [RFC][PATCH 1/3 v2] " Janusz Krzysztofik
2009-08-23 17:03   ` [alsa-devel] " Mark Brown
2009-08-23 17:45     ` Janusz Krzysztofik
2009-08-23 18:05       ` Mark Brown
2009-08-23 18:38         ` Janusz Krzysztofik
2009-08-23 18:49           ` Mark Brown
2009-08-24  5:49             ` Jarkko Nikula
2009-08-24 12:49               ` Tony Lindgren
2009-08-24 22:06                 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200908101050.02530.jkrzyszt@tis.icnet.pl \
    --to=jkrzyszt@tis.icnet.pl \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=jhnikula@gmail.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=peter.ujfalusi@nokia.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®