dma.h 4.0 KB

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