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
19 #include <linux/types.h>
24 * These are used to avoid issues when <asm/dma.h> and the DMA_MODE_
25 * defines are not available.
27 #define COMEDI_ISADMA_READ 0
28 #define COMEDI_ISADMA_WRITE 1
31 * struct comedi_isadma_desc - cookie for ISA DMA
32 * @virt_addr: virtual address of buffer
33 * @hw_addr: hardware (bus) address of buffer
35 * @maxsize: allocated size of buffer (in bytes)
36 * @size: transfer size (in bytes)
37 * @mode: DMA_MODE_READ or DMA_MODE_WRITE
39 struct comedi_isadma_desc {
49 * struct comedi_isadma - ISA DMA data
50 * @desc: cookie for each DMA buffer
51 * @n_desc: the number of cookies
52 * @cur_dma: the current cookie in use
53 * @chan: the first DMA channel requested
54 * @chan2: the second DMA channel requested
56 struct comedi_isadma {
57 struct comedi_isadma_desc *desc;
64 #if IS_ENABLED(CONFIG_ISA_DMA_API)
66 void comedi_isadma_program(struct comedi_isadma_desc *);
67 unsigned int comedi_isadma_disable(unsigned int dma_chan);
68 unsigned int comedi_isadma_disable_on_sample(unsigned int dma_chan,
70 unsigned int comedi_isadma_poll(struct comedi_isadma *);
71 void comedi_isadma_set_mode(struct comedi_isadma_desc *, char dma_dir);
73 struct comedi_isadma *comedi_isadma_alloc(struct comedi_device *,
74 int n_desc, unsigned int dma_chan1,
75 unsigned int dma_chan2,
76 unsigned int maxsize, char dma_dir);
77 void comedi_isadma_free(struct comedi_isadma *);
79 #else /* !IS_ENABLED(CONFIG_ISA_DMA_API) */
81 static inline void comedi_isadma_program(struct comedi_isadma_desc *desc)
85 static inline unsigned int comedi_isadma_disable(unsigned int dma_chan)
90 static inline unsigned int
91 comedi_isadma_disable_on_sample(unsigned int dma_chan, unsigned int size)
96 static inline unsigned int comedi_isadma_poll(struct comedi_isadma *dma)
101 static inline void comedi_isadma_set_mode(struct comedi_isadma_desc *desc,
106 static inline struct comedi_isadma *
107 comedi_isadma_alloc(struct comedi_device *dev, int n_desc,
108 unsigned int dma_chan1, unsigned int dma_chan2,
109 unsigned int maxsize, char dma_dir)
114 static inline void comedi_isadma_free(struct comedi_isadma *dma)
118 #endif /* !IS_ENABLED(CONFIG_ISA_DMA_API) */
120 #endif /* #ifndef _COMEDI_ISADMA_H */