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

staging: comedi: pcl812: introduce pcl812_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 a1ce5f03
...@@ -533,6 +533,20 @@ struct pcl812_private { ...@@ -533,6 +533,20 @@ struct pcl812_private {
unsigned int ai_eos:1; unsigned int ai_eos:1;
}; };
static void pcl812_isadma_program(unsigned int dma_chan,
struct pcl812_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 void pcl812_start_pacer(struct comedi_device *dev, bool load_timers) static void pcl812_start_pacer(struct comedi_device *dev, bool load_timers)
{ {
struct pcl812_private *devpriv = dev->private; struct pcl812_private *devpriv = dev->private;
...@@ -555,7 +569,6 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev, ...@@ -555,7 +569,6 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev,
struct pcl812_dma_desc *dma0 = &devpriv->dma_desc[0]; struct pcl812_dma_desc *dma0 = &devpriv->dma_desc[0];
struct pcl812_dma_desc *dma1 = &devpriv->dma_desc[1]; struct pcl812_dma_desc *dma1 = &devpriv->dma_desc[1];
struct comedi_cmd *cmd = &s->async->cmd; struct comedi_cmd *cmd = &s->async->cmd;
unsigned int dma_flags;
unsigned int bytes; unsigned int bytes;
/* we use EOS, so adapt DMA buffer to one scan */ /* we use EOS, so adapt DMA buffer to one scan */
...@@ -595,13 +608,8 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev, ...@@ -595,13 +608,8 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev,
devpriv->ai_eos = 0; devpriv->ai_eos = 0;
} }
devpriv->cur_dma = 0; devpriv->cur_dma = 0;
set_dma_mode(devpriv->dma, DMA_MODE_READ);
dma_flags = claim_dma_lock(); pcl812_isadma_program(devpriv->dma, dma0);
clear_dma_ff(devpriv->dma);
set_dma_addr(devpriv->dma, dma0->hw_addr);
set_dma_count(devpriv->dma, dma0->size);
release_dma_lock(dma_flags);
enable_dma(devpriv->dma);
} }
static void pcl812_ai_setup_next_dma(struct comedi_device *dev, static void pcl812_ai_setup_next_dma(struct comedi_device *dev,
...@@ -609,26 +617,19 @@ static void pcl812_ai_setup_next_dma(struct comedi_device *dev, ...@@ -609,26 +617,19 @@ static void pcl812_ai_setup_next_dma(struct comedi_device *dev,
{ {
struct pcl812_private *devpriv = dev->private; struct pcl812_private *devpriv = dev->private;
struct pcl812_dma_desc *dma; struct pcl812_dma_desc *dma;
unsigned long dma_flags;
disable_dma(devpriv->dma);
devpriv->cur_dma = 1 - devpriv->cur_dma; devpriv->cur_dma = 1 - devpriv->cur_dma;
dma = &devpriv->dma_desc[devpriv->cur_dma]; dma = &devpriv->dma_desc[devpriv->cur_dma];
disable_dma(devpriv->dma); if (!devpriv->ai_eos) {
set_dma_mode(devpriv->dma, DMA_MODE_READ); if (devpriv->dma_runs_to_end)
dma_flags = claim_dma_lock(); devpriv->dma_runs_to_end--;
set_dma_addr(devpriv->dma, dma->hw_addr); else
if (devpriv->ai_eos) { dma->size = devpriv->last_dma_run;
set_dma_count(devpriv->dma, dma->size);
} else {
if (devpriv->dma_runs_to_end) {
set_dma_count(devpriv->dma, dma->size);
} else {
set_dma_count(devpriv->dma, devpriv->last_dma_run);
}
devpriv->dma_runs_to_end--;
} }
release_dma_lock(dma_flags);
enable_dma(devpriv->dma); pcl812_isadma_program(devpriv->dma, dma);
} }
static void pcl812_ai_set_chan_range(struct comedi_device *dev, static void pcl812_ai_set_chan_range(struct comedi_device *dev,
......
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