dma.h 3.7 KB

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