dma.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /* $Id: dma.h,v 1.2 1999/04/27 00:46:18 deller Exp $
  2. * linux/include/asm/dma.h: Defines for using and allocating dma channels.
  3. * Written by Hennus Bergman, 1992.
  4. * High DMA channel support & info by Hannu Savolainen
  5. * and John Boyd, Nov. 1992.
  6. * (c) Copyright 2000, Grant Grundler
  7. */
  8. #ifndef _ASM_DMA_H
  9. #define _ASM_DMA_H
  10. #include <asm/io.h> /* need byte IO */
  11. #include <asm/system.h>
  12. #define dma_outb outb
  13. #define dma_inb inb
  14. /*
  15. ** DMA_CHUNK_SIZE is used by the SCSI mid-layer to break up
  16. ** (or rather not merge) DMAs into manageable chunks.
  17. ** On parisc, this is more of the software/tuning constraint
  18. ** rather than the HW. I/O MMU allocation algorithms can be
  19. ** faster with smaller sizes (to some degree).
  20. */
  21. #define DMA_CHUNK_SIZE (BITS_PER_LONG*PAGE_SIZE)
  22. /* The maximum address that we can perform a DMA transfer to on this platform
  23. ** New dynamic DMA interfaces should obsolete this....
  24. */
  25. #define MAX_DMA_ADDRESS (~0UL)
  26. /*
  27. ** We don't have DMA channels... well V-class does but the
  28. ** Dynamic DMA Mapping interface will support them... right? :^)
  29. ** Note: this is not relevant right now for PA-RISC, but we cannot
  30. ** leave this as undefined because some things (e.g. sound)
  31. ** won't compile :-(
  32. */
  33. #define MAX_DMA_CHANNELS 8
  34. #define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
  35. #define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
  36. #define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
  37. #define DMA_AUTOINIT 0x10
  38. /* 8237 DMA controllers */
  39. #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
  40. #define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
  41. /* DMA controller registers */
  42. #define DMA1_CMD_REG 0x08 /* command register (w) */
  43. #define DMA1_STAT_REG 0x08 /* status register (r) */
  44. #define DMA1_REQ_REG 0x09 /* request register (w) */
  45. #define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
  46. #define DMA1_MODE_REG 0x0B /* mode register (w) */
  47. #define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
  48. #define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
  49. #define DMA1_RESET_REG 0x0D /* Master Clear (w) */
  50. #define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
  51. #define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
  52. #define DMA1_EXT_MODE_REG (0x400 | DMA1_MODE_REG)
  53. #define DMA2_CMD_REG 0xD0 /* command register (w) */
  54. #define DMA2_STAT_REG 0xD0 /* status register (r) */
  55. #define DMA2_REQ_REG 0xD2 /* request register (w) */
  56. #define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
  57. #define DMA2_MODE_REG 0xD6 /* mode register (w) */
  58. #define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
  59. #define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
  60. #define DMA2_RESET_REG 0xDA /* Master Clear (w) */
  61. #define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
  62. #define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
  63. #define DMA2_EXT_MODE_REG (0x400 | DMA2_MODE_REG)
  64. static __inline__ unsigned long claim_dma_lock(void)
  65. {
  66. return 0;
  67. }
  68. static __inline__ void release_dma_lock(unsigned long flags)
  69. {
  70. }
  71. /* Get DMA residue count. After a DMA transfer, this
  72. * should return zero. Reading this while a DMA transfer is
  73. * still in progress will return unpredictable results.
  74. * If called before the channel has been used, it may return 1.
  75. * Otherwise, it returns the number of _bytes_ left to transfer.
  76. *
  77. * Assumes DMA flip-flop is clear.
  78. */
  79. static __inline__ int get_dma_residue(unsigned int dmanr)
  80. {
  81. unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
  82. : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
  83. /* using short to get 16-bit wrap around */
  84. unsigned short count;
  85. count = 1 + dma_inb(io_port);
  86. count += dma_inb(io_port) << 8;
  87. return (dmanr<=3)? count : (count<<1);
  88. }
  89. /* enable/disable a specific DMA channel */
  90. static __inline__ void enable_dma(unsigned int dmanr)
  91. {
  92. #ifdef CONFIG_SUPERIO
  93. if (dmanr<=3)
  94. dma_outb(dmanr, DMA1_MASK_REG);
  95. else
  96. dma_outb(dmanr & 3, DMA2_MASK_REG);
  97. #endif
  98. }
  99. static __inline__ void disable_dma(unsigned int dmanr)
  100. {
  101. #ifdef CONFIG_SUPERIO
  102. if (dmanr<=3)
  103. dma_outb(dmanr | 4, DMA1_MASK_REG);
  104. else
  105. dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
  106. #endif
  107. }
  108. /* reserve a DMA channel */
  109. #define request_dma(dmanr, device_id) (0)
  110. /* Clear the 'DMA Pointer Flip Flop'.
  111. * Write 0 for LSB/MSB, 1 for MSB/LSB access.
  112. * Use this once to initialize the FF to a known state.
  113. * After that, keep track of it. :-)
  114. * --- In order to do that, the DMA routines below should ---
  115. * --- only be used while holding the DMA lock ! ---
  116. */
  117. static __inline__ void clear_dma_ff(unsigned int dmanr)
  118. {
  119. }
  120. /* set mode (above) for a specific DMA channel */
  121. static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
  122. {
  123. }
  124. /* Set only the page register bits of the transfer address.
  125. * This is used for successive transfers when we know the contents of
  126. * the lower 16 bits of the DMA current address register, but a 64k boundary
  127. * may have been crossed.
  128. */
  129. static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
  130. {
  131. }
  132. /* Set transfer address & page bits for specific DMA channel.
  133. * Assumes dma flipflop is clear.
  134. */
  135. static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
  136. {
  137. }
  138. /* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
  139. * a specific DMA channel.
  140. * You must ensure the parameters are valid.
  141. * NOTE: from a manual: "the number of transfers is one more
  142. * than the initial word count"! This is taken into account.
  143. * Assumes dma flip-flop is clear.
  144. * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
  145. */
  146. static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
  147. {
  148. }
  149. #define free_dma(dmanr)
  150. #ifdef CONFIG_PCI
  151. extern int isa_dma_bridge_buggy;
  152. #else
  153. #define isa_dma_bridge_buggy (0)
  154. #endif
  155. #endif /* _ASM_DMA_H */