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

staging: comedi: das1800: introduce das1800_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 5d12431c
...@@ -452,6 +452,19 @@ static const struct comedi_lrange range_ao_2 = { ...@@ -452,6 +452,19 @@ static const struct comedi_lrange range_ao_2 = {
}; };
*/ */
static void das1800_isadma_program(struct das1800_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 inline uint16_t munge_bipolar_sample(const struct comedi_device *dev, static inline uint16_t munge_bipolar_sample(const struct comedi_device *dev,
uint16_t sample) uint16_t sample)
{ {
...@@ -571,12 +584,11 @@ static void das1800_handle_dma(struct comedi_device *dev, ...@@ -571,12 +584,11 @@ static void das1800_handle_dma(struct comedi_device *dev,
flags = claim_dma_lock(); flags = claim_dma_lock();
das1800_flush_dma_channel(dev, s, dma); das1800_flush_dma_channel(dev, s, dma);
/* re-enable dma channel */
set_dma_addr(dma->chan, dma->hw_addr);
set_dma_count(dma->chan, dma->size);
enable_dma(dma->chan);
release_dma_lock(flags); release_dma_lock(flags);
/* re-enable dma channel */
das1800_isadma_program(dma);
if (status & DMATC) { if (status & DMATC) {
/* clear DMATC interrupt bit */ /* clear DMATC interrupt bit */
outb(CLEAR_INTR_MASK & ~DMATC, dev->iobase + DAS1800_STATUS); outb(CLEAR_INTR_MASK & ~DMATC, dev->iobase + DAS1800_STATUS);
...@@ -998,8 +1010,6 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) ...@@ -998,8 +1010,6 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
{ {
struct das1800_private *devpriv = dev->private; struct das1800_private *devpriv = dev->private;
struct das1800_dma_desc *dma = &devpriv->dma_desc[0]; struct das1800_dma_desc *dma = &devpriv->dma_desc[0];
unsigned long lock_flags;
const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
unsigned int bytes; unsigned int bytes;
if ((devpriv->irq_dma_bits & DMA_ENABLED) == 0) if ((devpriv->irq_dma_bits & DMA_ENABLED) == 0)
...@@ -1011,29 +1021,14 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) ...@@ -1011,29 +1021,14 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
bytes = suggest_transfer_size(cmd); bytes = suggest_transfer_size(cmd);
dma->size = bytes; dma->size = bytes;
lock_flags = claim_dma_lock(); das1800_isadma_program(dma);
disable_dma(dma->chan);
/* clear flip-flop to make sure 2-byte registers for /* set up dual dma if appropriate */
* count and address get set correctly */ if (devpriv->irq_dma_bits & DMA_DUAL) {
clear_dma_ff(dma->chan);
set_dma_addr(dma->chan, dma->hw_addr);
/* set appropriate size of transfer */
set_dma_count(dma->chan, dma->size);
enable_dma(dma->chan);
/* set up dual dma if appropriate */
if (dual_dma) {
dma = &devpriv->dma_desc[1]; dma = &devpriv->dma_desc[1];
dma->size = bytes; dma->size = bytes;
disable_dma(dma->chan); das1800_isadma_program(dma);
/* clear flip-flop to make sure 2-byte registers for
* count and address get set correctly */
clear_dma_ff(dma->chan);
set_dma_addr(dma->chan, dma->hw_addr);
/* set appropriate size of transfer */
set_dma_count(dma->chan, dma->size);
enable_dma(dma->chan);
} }
release_dma_lock(lock_flags);
} }
/* programs channel/gain list into card */ /* programs channel/gain list into card */
...@@ -1299,7 +1294,6 @@ static int das1800_init_dma(struct comedi_device *dev, ...@@ -1299,7 +1294,6 @@ static int das1800_init_dma(struct comedi_device *dev,
flags = claim_dma_lock(); flags = claim_dma_lock();
disable_dma(dma->chan); disable_dma(dma->chan);
set_dma_mode(dma->chan, DMA_MODE_READ);
release_dma_lock(flags); release_dma_lock(flags);
} }
......
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