dma.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #ifndef __ASM_ARM_DMA_H
  2. #define __ASM_ARM_DMA_H
  3. #include <asm/memory.h>
  4. /*
  5. * This is the maximum virtual address which can be DMA'd from.
  6. */
  7. #ifndef MAX_DMA_ADDRESS
  8. #define MAX_DMA_ADDRESS 0xffffffff
  9. #endif
  10. #ifdef CONFIG_ISA_DMA_API
  11. /*
  12. * This is used to support drivers written for the x86 ISA DMA API.
  13. * It should not be re-used except for that purpose.
  14. */
  15. #include <linux/spinlock.h>
  16. #include <asm/system.h>
  17. #include <asm/scatterlist.h>
  18. #include <mach/isa-dma.h>
  19. /*
  20. * DMA modes
  21. */
  22. typedef unsigned int dmamode_t;
  23. #define DMA_MODE_MASK 3
  24. #define DMA_MODE_READ 0
  25. #define DMA_MODE_WRITE 1
  26. #define DMA_MODE_CASCADE 2
  27. #define DMA_AUTOINIT 4
  28. extern spinlock_t dma_spin_lock;
  29. static inline unsigned long claim_dma_lock(void)
  30. {
  31. unsigned long flags;
  32. spin_lock_irqsave(&dma_spin_lock, flags);
  33. return flags;
  34. }
  35. static inline void release_dma_lock(unsigned long flags)
  36. {
  37. spin_unlock_irqrestore(&dma_spin_lock, flags);
  38. }
  39. /* Clear the 'DMA Pointer Flip Flop'.
  40. * Write 0 for LSB/MSB, 1 for MSB/LSB access.
  41. */
  42. #define clear_dma_ff(chan)
  43. /* Set only the page register bits of the transfer address.
  44. *
  45. * NOTE: This is an architecture specific function, and should
  46. * be hidden from the drivers
  47. */
  48. extern void set_dma_page(unsigned int chan, char pagenr);
  49. /* Request a DMA channel
  50. *
  51. * Some architectures may need to do allocate an interrupt
  52. */
  53. extern int request_dma(unsigned int chan, const char * device_id);
  54. /* Free a DMA channel
  55. *
  56. * Some architectures may need to do free an interrupt
  57. */
  58. extern void free_dma(unsigned int chan);
  59. /* Enable DMA for this channel
  60. *
  61. * On some architectures, this may have other side effects like
  62. * enabling an interrupt and setting the DMA registers.
  63. */
  64. extern void enable_dma(unsigned int chan);
  65. /* Disable DMA for this channel
  66. *
  67. * On some architectures, this may have other side effects like
  68. * disabling an interrupt or whatever.
  69. */
  70. extern void disable_dma(unsigned int chan);
  71. /* Test whether the specified channel has an active DMA transfer
  72. */
  73. extern int dma_channel_active(unsigned int chan);
  74. /* Set the DMA scatter gather list for this channel
  75. *
  76. * This should not be called if a DMA channel is enabled,
  77. * especially since some DMA architectures don't update the
  78. * DMA address immediately, but defer it to the enable_dma().
  79. */
  80. extern void set_dma_sg(unsigned int chan, struct scatterlist *sg, int nr_sg);
  81. /* Set the DMA address for this channel
  82. *
  83. * This should not be called if a DMA channel is enabled,
  84. * especially since some DMA architectures don't update the
  85. * DMA address immediately, but defer it to the enable_dma().
  86. */
  87. extern void __set_dma_addr(unsigned int chan, void *addr);
  88. #define set_dma_addr(chan, addr) \
  89. __set_dma_addr(chan, bus_to_virt(addr))
  90. /* Set the DMA byte count for this channel
  91. *
  92. * This should not be called if a DMA channel is enabled,
  93. * especially since some DMA architectures don't update the
  94. * DMA count immediately, but defer it to the enable_dma().
  95. */
  96. extern void set_dma_count(unsigned int chan, unsigned long count);
  97. /* Set the transfer direction for this channel
  98. *
  99. * This should not be called if a DMA channel is enabled,
  100. * especially since some DMA architectures don't update the
  101. * DMA transfer direction immediately, but defer it to the
  102. * enable_dma().
  103. */
  104. extern void set_dma_mode(unsigned int chan, dmamode_t mode);
  105. /* Set the transfer speed for this channel
  106. */
  107. extern void set_dma_speed(unsigned int chan, int cycle_ns);
  108. /* Get DMA residue count. After a DMA transfer, this
  109. * should return zero. Reading this while a DMA transfer is
  110. * still in progress will return unpredictable results.
  111. * If called before the channel has been used, it may return 1.
  112. * Otherwise, it returns the number of _bytes_ left to transfer.
  113. */
  114. extern int get_dma_residue(unsigned int chan);
  115. #ifndef NO_DMA
  116. #define NO_DMA 255
  117. #endif
  118. #ifdef CONFIG_PCI
  119. extern int isa_dma_bridge_buggy;
  120. #else
  121. #define isa_dma_bridge_buggy (0)
  122. #endif
  123. #endif /* CONFIG_ISA_DMA_API */
  124. #endif /* __ASM_ARM_DMA_H */