imx-dma.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * linux/include/asm-arm/imxads/dma.h
  3. *
  4. * Copyright (C) 1997,1998 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <mach/dma.h>
  21. #ifndef __ASM_ARCH_IMX_DMA_H
  22. #define __ASM_ARCH_IMX_DMA_H
  23. #define IMX_DMA_CHANNELS 11
  24. /*
  25. * struct imx_dma_channel - i.MX specific DMA extension
  26. * @name: name specified by DMA client
  27. * @irq_handler: client callback for end of transfer
  28. * @err_handler: client callback for error condition
  29. * @data: clients context data for callbacks
  30. * @dma_mode: direction of the transfer %DMA_MODE_READ or %DMA_MODE_WRITE
  31. * @sg: pointer to the actual read/written chunk for scatter-gather emulation
  32. * @sgbc: counter of processed bytes in the actual read/written chunk
  33. * @resbytes: total residual number of bytes to transfer
  34. * (it can be lower or same as sum of SG mapped chunk sizes)
  35. * @sgcount: number of chunks to be read/written
  36. *
  37. * Structure is used for IMX DMA processing. It would be probably good
  38. * @struct dma_struct in the future for external interfacing and use
  39. * @struct imx_dma_channel only as extension to it.
  40. */
  41. struct imx_dma_channel {
  42. const char *name;
  43. void (*irq_handler) (int, void *);
  44. void (*err_handler) (int, void *, int errcode);
  45. void *data;
  46. unsigned int dma_mode;
  47. struct scatterlist *sg;
  48. unsigned int sgbc;
  49. unsigned int sgcount;
  50. unsigned int resbytes;
  51. int dma_num;
  52. };
  53. extern struct imx_dma_channel imx_dma_channels[IMX_DMA_CHANNELS];
  54. #define IMX_DMA_ERR_BURST 1
  55. #define IMX_DMA_ERR_REQUEST 2
  56. #define IMX_DMA_ERR_TRANSFER 4
  57. #define IMX_DMA_ERR_BUFFER 8
  58. /* The type to distinguish channel numbers parameter from ordinal int type */
  59. typedef int imx_dmach_t;
  60. #define DMA_MODE_READ 0
  61. #define DMA_MODE_WRITE 1
  62. #define DMA_MODE_MASK 1
  63. int
  64. imx_dma_setup_single(imx_dmach_t dma_ch, dma_addr_t dma_address,
  65. unsigned int dma_length, unsigned int dev_addr, unsigned int dmamode);
  66. int
  67. imx_dma_setup_sg(imx_dmach_t dma_ch,
  68. struct scatterlist *sg, unsigned int sgcount, unsigned int dma_length,
  69. unsigned int dev_addr, unsigned int dmamode);
  70. int
  71. imx_dma_setup_handlers(imx_dmach_t dma_ch,
  72. void (*irq_handler) (int, void *),
  73. void (*err_handler) (int, void *, int), void *data);
  74. void imx_dma_enable(imx_dmach_t dma_ch);
  75. void imx_dma_disable(imx_dmach_t dma_ch);
  76. int imx_dma_request(imx_dmach_t dma_ch, const char *name);
  77. void imx_dma_free(imx_dmach_t dma_ch);
  78. imx_dmach_t imx_dma_request_by_prio(const char *name, imx_dma_prio prio);
  79. #endif /* _ASM_ARCH_IMX_DMA_H */