memoryCall.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  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. *
  7. * NOTE: all this is true *only* for ISA/EISA expansions on Mips boards
  8. * and can only be used for expansion cards. Onboard DMA controllers, such
  9. * as the R4030 on Jazz boards behave totally different!
  10. */
  11. #ifndef _ASM_DMA_H
  12. #define _ASM_DMA_H
  13. #include <asm/io.h> /* need byte IO */
  14. #include <linux/spinlock.h> /* And spinlocks */
  15. #include <linux/delay.h>
  16. #ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
  17. #define dma_outb outb_p
  18. #else
  19. #define dma_outb outb
  20. #endif
  21. #define dma_inb inb
  22. /*
  23. * NOTES about DMA transfers:
  24. *
  25. * controller 1: channels 0-3, byte operations, ports 00-1F
  26. * controller 2: channels 4-7, word operations, ports C0-DF
  27. *
  28. * - ALL registers are 8 bits only, regardless of transfer size
  29. * - channel 4 is not used - cascades 1 into 2.
  30. * - channels 0-3 are byte - addresses/counts are for physical bytes
  31. * - channels 5-7 are word - addresses/counts are for physical words
  32. * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
  33. * - transfer count loaded to registers is 1 less than actual count
  34. * - controller 2 offsets are all even (2x offsets for controller 1)
  35. * - page registers for 5-7 don't use data bit 0, represent 128K pages
  36. * - page registers for 0-3 use bit 0, represent 64K pages
  37. *
  38. * DMA transfers are limited to the lower 16MB of _physical_ memory.
  39. * Note that addresses loaded into registers must be _physical_ addresses,
  40. * not logical addresses (which may differ if paging is active).
  41. *
  42. * Address mapping for channels 0-3:
  43. *
  44. * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
  45. * | ... | | ... | | ... |
  46. * | ... | | ... | | ... |
  47. * | ... | | ... | | ... |
  48. * P7 ... P0 A7 ... A0 A7 ... A0
  49. * | Page | Addr MSB | Addr LSB | (DMA registers)
  50. *
  51. * Address mapping for channels 5-7:
  52. *
  53. * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
  54. * | ... | \ \ ... \ \ \ ... \ \
  55. * | ... | \ \ ... \ \ \ ... \ (not used)
  56. * | ... | \ \ ... \ \ \ ... \
  57. * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
  58. * | Page | Addr MSB | Addr LSB | (DMA registers)
  59. *
  60. * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
  61. * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
  62. * the hardware level, so odd-byte transfers aren't possible).
  63. *
  64. * Transfer count (_not # bytes_) is limited to 64K, represented as actual
  65. * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
  66. * and up to 128K bytes may be transferred on channels 5-7 in one operation.
  67. *
  68. */
  69. #ifndef CONFIG_GENERIC_ISA_DMA_SUPPORT_BROKEN
  70. #define MAX_DMA_CHANNELS 8
  71. #endif
  72. /*
  73. * The maximum address in KSEG0 that we can perform a DMA transfer to on this
  74. * platform. This describes only the PC style part of the DMA logic like on
  75. * Deskstations or Acer PICA but not the much more versatile DMA logic used
  76. * for the local devices on Acer PICA or Magnums.
  77. */
  78. #if defined(CONFIG_SGI_IP22) || defined(CONFIG_SGI_IP28)
  79. /* don't care; ISA bus master won't work, ISA slave DMA supports 32bit addr */
  80. #define MAX_DMA_ADDRESS PAGE_OFFSET
  81. #else
  82. #define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
  83. #endif
  84. #define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS))
  85. #ifndef MAX_DMA32_PFN
  86. #define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT))
  87. #endif
  88. /* 8237 DMA controllers */
  89. #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
  90. #define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
  91. /* DMA controller registers */
  92. #define DMA1_CMD_REG 0x08 /* command register (w) */
  93. #define DMA1_STAT_REG 0x08 /* status register (r) */
  94. #define DMA1_REQ_REG 0x09 /* request register (w) */