dma.h 4.1 KB

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