Skip to content

Commit

Permalink
sh: G2 DMA IRQ and residue sampling.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul Mundt committed Sep 27, 2006
1 parent ade2b3f commit e2d1864
Showing 1 changed file with 41 additions and 13 deletions.
54 changes: 41 additions & 13 deletions arch/sh/drivers/dma/dma-g2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 = {
Expand All @@ -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)
Expand All @@ -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");

0 comments on commit e2d1864

Please sign in to comment.