dma.h 3.6 KB

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