dma.h 3.8 KB

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