Commit 0afa6153 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_labpc_isadma: introduce labpc_isadma_program()

Introduce a helper function to program the ISA DMA controller. Program
the ISA DMA as described in Documentation/DMA-ISA-LPC.txt.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f2c6bbe8
...@@ -31,6 +31,19 @@ ...@@ -31,6 +31,19 @@
/* size in bytes of dma buffer */ /* size in bytes of dma buffer */
#define LABPC_ISADMA_BUFFER_SIZE 0xff00 #define LABPC_ISADMA_BUFFER_SIZE 0xff00
static void labpc_isadma_program(struct labpc_dma_desc *dma)
{
unsigned long flags;
flags = claim_dma_lock();
clear_dma_ff(dma->chan);
set_dma_mode(dma->chan, DMA_MODE_READ);
set_dma_addr(dma->chan, dma->hw_addr);
set_dma_count(dma->chan, dma->size);
enable_dma(dma->chan);
release_dma_lock(flags);
}
static unsigned int labpc_isadma_disable(struct labpc_dma_desc *dma) static unsigned int labpc_isadma_disable(struct labpc_dma_desc *dma)
{ {
unsigned long flags; unsigned long flags;
...@@ -77,22 +90,15 @@ void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -77,22 +90,15 @@ void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s)
struct labpc_dma_desc *dma = &devpriv->dma_desc; struct labpc_dma_desc *dma = &devpriv->dma_desc;
struct comedi_cmd *cmd = &s->async->cmd; struct comedi_cmd *cmd = &s->async->cmd;
unsigned int sample_size = comedi_bytes_per_sample(s); unsigned int sample_size = comedi_bytes_per_sample(s);
unsigned long irq_flags;
irq_flags = claim_dma_lock();
/* clear flip-flop to make sure 2-byte registers for
* count and address get set correctly */
clear_dma_ff(dma->chan);
set_dma_mode(dma->chan, DMA_MODE_READ);
set_dma_addr(dma->chan, dma->hw_addr);
/* set appropriate size of transfer */ /* set appropriate size of transfer */
dma->size = labpc_suggest_transfer_size(dev, s); dma->size = labpc_suggest_transfer_size(dev, s);
if (cmd->stop_src == TRIG_COUNT && if (cmd->stop_src == TRIG_COUNT &&
devpriv->count * sample_size < dma->size) devpriv->count * sample_size < dma->size)
dma->size = devpriv->count * sample_size; dma->size = devpriv->count * sample_size;
set_dma_count(dma->chan, dma->size);
enable_dma(dma->chan); labpc_isadma_program(dma);
release_dma_lock(irq_flags);
/* set CMD3 bits for caller to enable DMA and interrupt */ /* set CMD3 bits for caller to enable DMA and interrupt */
devpriv->cmd3 |= (CMD3_DMAEN | CMD3_DMATCINTEN); devpriv->cmd3 |= (CMD3_DMAEN | CMD3_DMATCINTEN);
} }
...@@ -145,18 +151,11 @@ static void handle_isa_dma(struct comedi_device *dev) ...@@ -145,18 +151,11 @@ static void handle_isa_dma(struct comedi_device *dev)
{ {
struct labpc_private *devpriv = dev->private; struct labpc_private *devpriv = dev->private;
struct labpc_dma_desc *dma = &devpriv->dma_desc; struct labpc_dma_desc *dma = &devpriv->dma_desc;
unsigned long flags;
labpc_drain_dma(dev); labpc_drain_dma(dev);
if (dma->size) { if (dma->size)
flags = claim_dma_lock(); labpc_isadma_program(dma);
set_dma_mode(dma->chan, DMA_MODE_READ);
set_dma_addr(dma->chan, dma->hw_addr);
set_dma_count(dma->chan, dma->size);
enable_dma(dma->chan);
release_dma_lock(flags);
}
/* clear dma tc interrupt */ /* clear dma tc interrupt */
devpriv->write_byte(dev, 0x1, DMATC_CLEAR_REG); devpriv->write_byte(dev, 0x1, DMATC_CLEAR_REG);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment