2 * COMEDI ISA DMA support functions
3 * Copyright (c) 2014 H Hartley Sweeten <hsweeten@visionengravers.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef _COMEDI_ISADMA_H
17 #define _COMEDI_ISADMA_H
20 * These are used to avoid issues when <asm/dma.h> and the DMA_MODE_
21 * defines are not available.
23 #define COMEDI_ISADMA_READ 0
24 #define COMEDI_ISADMA_WRITE 1
27 * struct comedi_isadma_desc - cookie for ISA DMA
28 * @virt_addr: virtual address of buffer
29 * @hw_addr: hardware (bus) address of buffer
31 * @maxsize: allocated size of buffer (in bytes)
32 * @size: transfer size (in bytes)
33 * @mode: DMA_MODE_READ or DMA_MODE_WRITE
35 struct comedi_isadma_desc {
45 * struct comedi_isadma - ISA DMA data
46 * @desc: cookie for each DMA buffer
47 * @n_desc: the number of cookies
48 * @cur_dma: the current cookie in use
49 * @chan: the first DMA channel requested
50 * @chan2: the second DMA channel requested
52 struct comedi_isadma {
53 struct comedi_isadma_desc *desc;
60 #if IS_ENABLED(CONFIG_ISA_DMA_API)
62 void comedi_isadma_program(struct comedi_isadma_desc *);
63 unsigned int comedi_isadma_disable(unsigned int dma_chan);
64 unsigned int comedi_isadma_disable_on_sample(unsigned int dma_chan,
66 unsigned int comedi_isadma_poll(struct comedi_isadma *);
67 void comedi_isadma_set_mode(struct comedi_isadma_desc *, char dma_dir);
69 struct comedi_isadma *comedi_isadma_alloc(struct comedi_device *,
70 int n_desc, unsigned int dma_chan1,
71 unsigned int dma_chan2,
72 unsigned int maxsize, char dma_dir);
73 void comedi_isadma_free(struct comedi_isadma *);
75 #else /* !IS_ENABLED(CONFIG_ISA_DMA_API) */
77 static inline void comedi_isadma_program(struct comedi_isadma_desc *desc)
81 static inline unsigned int comedi_isadma_disable(unsigned int dma_chan)
86 static inline unsigned int
87 comedi_isadma_disable_on_sample(unsigned int dma_chan, unsigned int size)
92 static inline unsigned int comedi_isadma_poll(struct comedi_isadma *dma)
97 static inline void comedi_isadma_set_mode(struct comedi_isadma_desc *desc,
102 static inline struct comedi_isadma *
103 comedi_isadma_alloc(struct comedi_device *dev, int n_desc,
104 unsigned int dma_chan1, unsigned int dma_chan2,
105 unsigned int maxsize, char dma_dir)
110 static inline void comedi_isadma_free(struct comedi_isadma *dma)
114 #endif /* !IS_ENABLED(CONFIG_ISA_DMA_API) */
116 #endif /* #ifndef _COMEDI_ISADMA_H */