dma.h 3.9 KB

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