public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] DMA: Added utility APIs for setting DMA global parameters
@ 2007-10-24  7:08 Gadiyar, Anand
  2007-10-31 13:14 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Gadiyar, Anand @ 2007-10-24  7:08 UTC (permalink / raw)
  To: linux-omap-open-source

From: Anand Gadiyar <gadiyar@ti.com>

Added DMA utility APIs for setting FIFO depth, arbitration rate and channel priority.
This patch depends on patch [2/4] "OMAP: DMA: Added support for OMAP3".

Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
---
 arch/arm/plat-omap/dma.c        |   68 ++++++++++++++++++++++++++++++++++++++++
 include/asm-arm/arch-omap/dma.h |   22 ++++++++++++
 2 files changed, 90 insertions(+)

Index: omap-git/arch/arm/plat-omap/dma.c
===================================================================
--- omap-git.orig/arch/arm/plat-omap/dma.c	2007-10-22 03:17:24.094818864 -0400
+++ omap-git/arch/arm/plat-omap/dma.c	2007-10-23 03:28:51.072585880 -0400
@@ -289,6 +289,9 @@
 	omap_set_dma_dest_params(lch, params->dst_port,
 				 params->dst_amode, params->dst_start,
 				 params->dst_ei, params->dst_fi);
+	if (params->read_prio || params->write_prio)
+		omap_dma_set_prio_lch(lch, params->read_prio,
+				      params->write_prio);
 }
 
 void omap_set_dma_src_index(int lch, int eidx, int fidx)
@@ -608,6 +611,67 @@
 	}
 }
 
+/**
+ * @brief omap_dma_set_global_params : Set global priority settings for dma
+ *
+ * @param arb_rate
+ * @param max_fifo_depth
+ * @param tparams - Number of thereads to reserve : DMA_THREAD_RESERVE_NORM
+ * 						    DMA_THREAD_RESERVE_ONET
+ * 						    DMA_THREAD_RESERVE_TWOT
+ * 						    DMA_THREAD_RESERVE_THREET
+ */
+void
+omap_dma_set_global_params(int arb_rate, int max_fifo_depth, int tparams)
+{
+	u32 reg;
+
+	if (!cpu_class_is_omap2()) {
+		printk(KERN_ERR "FIXME: no %s on 15xx/16xx\n", __FUNCTION__);
+		return;
+	}
+
+	if (arb_rate == 0)
+		arb_rate = 1;
+
+	reg = (arb_rate & 0xff) << 16;
+	reg |= (0xff & max_fifo_depth);
+
+	omap_writel(reg, OMAP_DMA4_GCR_REG);
+}
+EXPORT_SYMBOL(omap_dma_set_global_params);
+
+/**
+ * @brief omap_dma_set_prio_lch : Set channel wise priority settings
+ *
+ * @param lch
+ * @param read_prio - Read priority
+ * @param write_prio - Write priority
+ * Both of the above can be set with one of the following values :
+ * 	DMA_CH_PRIO_HIGH/DMA_CH_PRIO_LOW
+ */
+int
+omap_dma_set_prio_lch(int lch, unsigned char read_prio,
+		      unsigned char write_prio)
+{
+	u32 w;
+
+	if (unlikely((lch < 0 || lch >= OMAP_LOGICAL_DMA_CH_COUNT))) {
+		printk(KERN_ERR "Invalid channel id\n");
+		return -EINVAL;
+	}
+	w = OMAP_DMA_CCR_REG(lch);
+	w &= ~((1 << 6) | (1 << 26));
+	if (cpu_is_omap2430() || cpu_is_omap34xx())
+		w |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26);
+	else
+		w |= ((read_prio & 0x1) << 6);
+
+	OMAP_DMA_CCR_REG(lch) = w;
+	return 0;
+}
+EXPORT_SYMBOL(omap_dma_set_prio_lch);
+
 /*
  * Clears any DMA state so the DMA engine is ready to restart with new buffers
  * through omap_start_dma(). Any buffers in flight are discarded.
@@ -1428,6 +1492,10 @@
 		}
 	}
 
+	if (cpu_is_omap2430() || cpu_is_omap34xx())
+		omap_dma_set_global_params(DMA_DEFAULT_ARB_RATE,
+				DMA_DEFAULT_FIFO_DEPTH, 0);
+
 	if (cpu_class_is_omap2())
 		setup_irq(INT_24XX_SDMA_IRQ0, &omap24xx_dma_irq);
 
Index: omap-git/include/asm-arm/arch-omap/dma.h
===================================================================
--- omap-git.orig/include/asm-arm/arch-omap/dma.h	2007-10-22 03:17:22.830011144 -0400
+++ omap-git/include/asm-arm/arch-omap/dma.h	2007-10-22 03:18:23.902726680 -0400
@@ -407,6 +407,21 @@
 #define OMAP_DMA_AMODE_SINGLE_IDX	0x02
 #define OMAP_DMA_AMODE_DOUBLE_IDX	0x03
 
+#define DMA_DEFAULT_FIFO_DEPTH		0x10
+#define DMA_DEFAULT_ARB_RATE		0x01
+/* Pass THREAD_RESERVE ORed with THREAD_FIFO for tparams */
+#define DMA_THREAD_RESERVE_NORM		(0x00 << 12) /* Def */
+#define DMA_THREAD_RESERVE_ONET		(0x01 << 12)
+#define DMA_THREAD_RESERVE_TWOT		(0x02 << 12)
+#define DMA_THREAD_RESERVE_THREET	(0x03 << 12)
+#define DMA_THREAD_FIFO_NONE		(0x00 << 14) /* Def */
+#define DMA_THREAD_FIFO_75		(0x01 << 14)
+#define DMA_THREAD_FIFO_25		(0x02 << 14)
+#define DMA_THREAD_FIFO_50		(0x03 << 14)
+
+#define DMA_CH_PRIO_HIGH		0x1
+#define DMA_CH_PRIO_LOW			0x0 /* Def */
+
 /* LCD DMA block numbers */
 enum {
 	OMAP_LCD_DMA_B1_TOP,
@@ -456,6 +471,9 @@
 	int src_or_dst_synch;	/* source synch(1) or destination synch(0) */
 
 	int ie;			/* interrupt enabled */
+
+	unsigned char read_prio;/* read priority */
+	unsigned char write_prio;/* write priority */
 };
 
 
@@ -506,6 +524,10 @@
 extern int omap_get_dma_src_addr_counter(int lch);
 extern void omap_clear_dma(int lch);
 extern int omap_dma_running(void);
+extern void omap_dma_set_global_params(int arb_rate, int max_fifo_depth,
+				       int tparams);
+extern int omap_dma_set_prio_lch(int lch, unsigned char read_prio,
+				 unsigned char write_prio);
 
 /* LCD DMA functions */
 extern int omap_request_lcd_dma(void (* callback)(u16 status, void *data),

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/4] DMA: Added utility APIs for setting DMA global parameters
  2007-10-24  7:08 [PATCH 3/4] DMA: Added utility APIs for setting DMA global parameters Gadiyar, Anand
@ 2007-10-31 13:14 ` Tony Lindgren
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2007-10-31 13:14 UTC (permalink / raw)
  To: Gadiyar, Anand; +Cc: linux-omap-open-source

* Gadiyar, Anand <gadiyar@ti.com> [071024 00:11]:
> From: Anand Gadiyar <gadiyar@ti.com>
> 
> Added DMA utility APIs for setting FIFO depth, arbitration rate and channel priority.
> This patch depends on patch [2/4] "OMAP: DMA: Added support for OMAP3".

Pushing this today.

Tony

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-31 13:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-24  7:08 [PATCH 3/4] DMA: Added utility APIs for setting DMA global parameters Gadiyar, Anand
2007-10-31 13:14 ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox