mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-05 12:13:57 +08:00
staging: comedi: dt282x: introduce dt282x_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: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
65fdfedbc0
commit
f609c29dfb
@ -305,6 +305,7 @@ struct dt282x_dma_desc {
|
|||||||
void *virt_addr; /* virtual address of DMA buffer */
|
void *virt_addr; /* virtual address of DMA buffer */
|
||||||
dma_addr_t hw_addr; /* hardware (bus) address of DMA buffer */
|
dma_addr_t hw_addr; /* hardware (bus) address of DMA buffer */
|
||||||
unsigned int size; /* transfer size (in bytes) */
|
unsigned int size; /* transfer size (in bytes) */
|
||||||
|
char mode; /* DMA_MODE_* */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dt282x_private {
|
struct dt282x_private {
|
||||||
@ -325,11 +326,23 @@ struct dt282x_private {
|
|||||||
int dma_dir;
|
int dma_dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void dt282x_isadma_program(struct dt282x_dma_desc *dma)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
flags = claim_dma_lock();
|
||||||
|
clear_dma_ff(dma->chan);
|
||||||
|
set_dma_mode(dma->chan, dma->mode);
|
||||||
|
set_dma_addr(dma->chan, dma->hw_addr);
|
||||||
|
set_dma_count(dma->chan, dma->size);
|
||||||
|
enable_dma(dma->chan);
|
||||||
|
release_dma_lock(flags);
|
||||||
|
}
|
||||||
|
|
||||||
static int dt282x_prep_ai_dma(struct comedi_device *dev, int dma_index, int n)
|
static int dt282x_prep_ai_dma(struct comedi_device *dev, int dma_index, int n)
|
||||||
{
|
{
|
||||||
struct dt282x_private *devpriv = dev->private;
|
struct dt282x_private *devpriv = dev->private;
|
||||||
struct dt282x_dma_desc *dma = &devpriv->dma_desc[dma_index];
|
struct dt282x_dma_desc *dma = &devpriv->dma_desc[dma_index];
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (!devpriv->ntrig)
|
if (!devpriv->ntrig)
|
||||||
return 0;
|
return 0;
|
||||||
@ -341,15 +354,9 @@ static int dt282x_prep_ai_dma(struct comedi_device *dev, int dma_index, int n)
|
|||||||
devpriv->ntrig -= n / 2;
|
devpriv->ntrig -= n / 2;
|
||||||
|
|
||||||
dma->size = n;
|
dma->size = n;
|
||||||
|
dma->mode = DMA_MODE_READ;
|
||||||
|
|
||||||
set_dma_mode(dma->chan, DMA_MODE_READ);
|
dt282x_isadma_program(dma);
|
||||||
flags = claim_dma_lock();
|
|
||||||
clear_dma_ff(dma->chan);
|
|
||||||
set_dma_addr(dma->chan, dma->hw_addr);
|
|
||||||
set_dma_count(dma->chan, dma->size);
|
|
||||||
release_dma_lock(flags);
|
|
||||||
|
|
||||||
enable_dma(dma->chan);
|
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -358,18 +365,11 @@ static int dt282x_prep_ao_dma(struct comedi_device *dev, int dma_index, int n)
|
|||||||
{
|
{
|
||||||
struct dt282x_private *devpriv = dev->private;
|
struct dt282x_private *devpriv = dev->private;
|
||||||
struct dt282x_dma_desc *dma = &devpriv->dma_desc[dma_index];
|
struct dt282x_dma_desc *dma = &devpriv->dma_desc[dma_index];
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
dma->size = n;
|
dma->size = n;
|
||||||
|
dma->mode = DMA_MODE_WRITE;
|
||||||
|
|
||||||
set_dma_mode(dma->chan, DMA_MODE_WRITE);
|
dt282x_isadma_program(dma);
|
||||||
flags = claim_dma_lock();
|
|
||||||
clear_dma_ff(dma->chan);
|
|
||||||
set_dma_addr(dma->chan, dma->hw_addr);
|
|
||||||
set_dma_count(dma->chan, dma->size);
|
|
||||||
release_dma_lock(flags);
|
|
||||||
|
|
||||||
enable_dma(dma->chan);
|
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user