linux/drivers/staging/comedi/drivers/comedi_isadma.h
<<
>>
Prefs
   1/*
   2 * COMEDI ISA DMA support functions
   3 * Copyright (c) 2014 H Hartley Sweeten <hsweeten@visionengravers.com>
   4 *
   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.
   9 *
  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.
  14 */
  15
  16#ifndef _COMEDI_ISADMA_H
  17#define _COMEDI_ISADMA_H
  18
  19#include <linux/types.h>
  20
  21struct comedi_device;
  22
  23/*
  24 * These are used to avoid issues when <asm/dma.h> and the DMA_MODE_
  25 * defines are not available.
  26 */
  27#define COMEDI_ISADMA_READ      0
  28#define COMEDI_ISADMA_WRITE     1
  29
  30/**
  31 * struct comedi_isadma_desc - cookie for ISA DMA
  32 * @virt_addr:  virtual address of buffer
  33 * @hw_addr:    hardware (bus) address of buffer
  34 * @chan:       DMA channel
  35 * @maxsize:    allocated size of buffer (in bytes)
  36 * @size:       transfer size (in bytes)
  37 * @mode:       DMA_MODE_READ or DMA_MODE_WRITE
  38 */
  39struct comedi_isadma_desc {
  40        void *virt_addr;
  41        dma_addr_t hw_addr;
  42        unsigned int chan;
  43        unsigned int maxsize;
  44        unsigned int size;
  45        char mode;
  46};
  47
  48/**
  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
  55 */
  56struct comedi_isadma {
  57        struct comedi_isadma_desc *desc;
  58        int n_desc;
  59        int cur_dma;
  60        unsigned int chan;
  61        unsigned int chan2;
  62};
  63
  64#if IS_ENABLED(CONFIG_ISA_DMA_API)
  65
  66void comedi_isadma_program(struct comedi_isadma_desc *desc);
  67unsigned int comedi_isadma_disable(unsigned int dma_chan);
  68unsigned int comedi_isadma_disable_on_sample(unsigned int dma_chan,
  69                                             unsigned int size);
  70unsigned int comedi_isadma_poll(struct comedi_isadma *dma);
  71void comedi_isadma_set_mode(struct comedi_isadma_desc *desc, char dma_dir);
  72
  73struct comedi_isadma *comedi_isadma_alloc(struct comedi_device *dev,
  74                                          int n_desc, unsigned int dma_chan1,
  75                                          unsigned int dma_chan2,
  76                                          unsigned int maxsize, char dma_dir);
  77void comedi_isadma_free(struct comedi_isadma *dma);
  78
  79#else   /* !IS_ENABLED(CONFIG_ISA_DMA_API) */
  80
  81static inline void comedi_isadma_program(struct comedi_isadma_desc *desc)
  82{
  83}
  84
  85static inline unsigned int comedi_isadma_disable(unsigned int dma_chan)
  86{
  87        return 0;
  88}
  89
  90static inline unsigned int
  91comedi_isadma_disable_on_sample(unsigned int dma_chan, unsigned int size)
  92{
  93        return 0;
  94}
  95
  96static inline unsigned int comedi_isadma_poll(struct comedi_isadma *dma)
  97{
  98        return 0;
  99}
 100
 101static inline void comedi_isadma_set_mode(struct comedi_isadma_desc *desc,
 102                                          char dma_dir)
 103{
 104}
 105
 106static inline struct comedi_isadma *
 107comedi_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)
 110{
 111        return NULL;
 112}
 113
 114static inline void comedi_isadma_free(struct comedi_isadma *dma)
 115{
 116}
 117
 118#endif  /* !IS_ENABLED(CONFIG_ISA_DMA_API) */
 119
 120#endif  /* #ifndef _COMEDI_ISADMA_H */
 121