summaryrefslogtreecommitdiffstats
path: root/arch/sh/drivers/dma/dma-g2.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2006-09-27 09:53:40 +0200
committerPaul Mundt <lethal@linux-sh.org>2006-09-27 09:53:40 +0200
commite2d1864da5bfa419a108f42c0615f69432b1b876 (patch)
tree2ebd838b7b6cca8d5db7d2991797a5bc9ae1d1ab /arch/sh/drivers/dma/dma-g2.c
parentsh: VoyagerGX cleanups and 8250 UART support. (diff)
downloadlinux-e2d1864da5bfa419a108f42c0615f69432b1b876.tar.xz
linux-e2d1864da5bfa419a108f42c0615f69432b1b876.zip
sh: G2 DMA IRQ and residue sampling.
This fixes a long-standing FIXME for G2 DMA, where we finally wire up the IRQ handler and allow for sampling remaining bytes while in-flight. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/drivers/dma/dma-g2.c')
-rw-r--r--arch/sh/drivers/dma/dma-g2.c54
1 files changed, 41 insertions, 13 deletions
diff --git a/arch/sh/drivers/dma/dma-g2.c b/arch/sh/drivers/dma/dma-g2.c
index 0f866f8789f0..9cb070924180 100644
--- a/arch/sh/drivers/dma/dma-g2.c
+++ b/arch/sh/drivers/dma/dma-g2.c
@@ -3,7 +3,7 @@
*
* G2 bus DMA support
*
- * Copyright (C) 2003, 2004 Paul Mundt
+ * Copyright (C) 2003 - 2006 Paul Mundt
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
@@ -13,7 +13,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
-
+#include <asm/cacheflush.h>
#include <asm/mach/sysasic.h>
#include <asm/mach/dma.h>
#include <asm/dma.h>
@@ -47,17 +47,31 @@ struct g2_dma_info {
static volatile struct g2_dma_info *g2_dma = (volatile struct g2_dma_info *)0xa05f7800;
+#define g2_bytes_remaining(i) \
+ ((g2_dma->channel[i].size - \
+ g2_dma->status[i].size) & 0x0fffffff)
+
static irqreturn_t g2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
- /* FIXME: Do some meaningful completion work here.. */
- return IRQ_HANDLED;
-}
+ int i;
-static struct irqaction g2_dma_irq = {
- .name = "g2 DMA handler",
- .handler = g2_dma_interrupt,
- .flags = IRQF_DISABLED,
-};
+ for (i = 0; i < G2_NR_DMA_CHANNELS; i++) {
+ if (g2_dma->status[i].status & 0x20000000) {
+ unsigned int bytes = g2_bytes_remaining(i);
+
+ if (likely(bytes == 0)) {
+ struct dma_info *info = dev_id;
+ struct dma_channel *chan = info->channels + i;
+
+ wake_up(&chan->wait_queue);
+
+ return IRQ_HANDLED;
+ }
+ }
+ }
+
+ return IRQ_NONE;
+}
static int g2_enable_dma(struct dma_channel *chan)
{
@@ -135,8 +149,14 @@ static int g2_xfer_dma(struct dma_channel *chan)
return 0;
}
+static int g2_get_residue(struct dma_channel *chan)
+{
+ return g2_bytes_remaining(chan->chan);
+}
+
static struct dma_ops g2_dma_ops = {
.xfer = g2_xfer_dma,
+ .get_residue = g2_get_residue,
};
static struct dma_info g2_dma_info = {
@@ -148,13 +168,22 @@ static struct dma_info g2_dma_info = {
static int __init g2_dma_init(void)
{
- setup_irq(HW_EVENT_G2_DMA, &g2_dma_irq);
+ int ret;
+
+ ret = request_irq(HW_EVENT_G2_DMA, g2_dma_interrupt, IRQF_DISABLED,
+ "g2 DMA handler", &g2_dma_info);
+ if (unlikely(ret))
+ return -EINVAL;
/* Magic */
g2_dma->wait_state = 27;
g2_dma->magic = 0x4659404f;
- return register_dmac(&g2_dma_info);
+ ret = register_dmac(&g2_dma_info);
+ if (unlikely(ret != 0))
+ free_irq(HW_EVENT_G2_DMA, 0);
+
+ return ret;
}
static void __exit g2_dma_exit(void)
@@ -169,4 +198,3 @@ module_exit(g2_dma_exit);
MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
MODULE_DESCRIPTION("G2 bus DMA driver");
MODULE_LICENSE("GPL");
-