dma.h 4.1 KB

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