dma.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #ifndef _ASM_SPARC_DMA_H
  2. #define _ASM_SPARC_DMA_H
  3. /* These are irrelevant for Sparc DMA, but we leave it in so that
  4. * things can compile.
  5. */
  6. #define MAX_DMA_CHANNELS 8
  7. #define DMA_MODE_READ 1
  8. #define DMA_MODE_WRITE 2
  9. #define MAX_DMA_ADDRESS (~0UL)
  10. /* Useful constants */
  11. #define SIZE_16MB (16*1024*1024)
  12. #define SIZE_64K (64*1024)
  13. /* SBUS DMA controller reg offsets */
  14. #define DMA_CSR 0x00UL /* rw DMA control/status register 0x00 */
  15. #define DMA_ADDR 0x04UL /* rw DMA transfer address register 0x04 */
  16. #define DMA_COUNT 0x08UL /* rw DMA transfer count register 0x08 */
  17. #define DMA_TEST 0x0cUL /* rw DMA test/debug register 0x0c */
  18. /* Fields in the cond_reg register */
  19. /* First, the version identification bits */
  20. #define DMA_DEVICE_ID 0xf0000000 /* Device identification bits */
  21. #define DMA_VERS0 0x00000000 /* Sunray DMA version */
  22. #define DMA_ESCV1 0x40000000 /* DMA ESC Version 1 */
  23. #define DMA_VERS1 0x80000000 /* DMA rev 1 */
  24. #define DMA_VERS2 0xa0000000 /* DMA rev 2 */
  25. #define DMA_VERHME 0xb0000000 /* DMA hme gate array */
  26. #define DMA_VERSPLUS 0x90000000 /* DMA rev 1 PLUS */
  27. #define DMA_HNDL_INTR 0x00000001 /* An IRQ needs to be handled */
  28. #define DMA_HNDL_ERROR 0x00000002 /* We need to take an error */
  29. #define DMA_FIFO_ISDRAIN 0x0000000c /* The DMA FIFO is draining */
  30. #define DMA_INT_ENAB 0x00000010 /* Turn on interrupts */
  31. #define DMA_FIFO_INV 0x00000020 /* Invalidate the FIFO */
  32. #define DMA_ACC_SZ_ERR 0x00000040 /* The access size was bad */
  33. #define DMA_FIFO_STDRAIN 0x00000040 /* DMA_VERS1 Drain the FIFO */
  34. #define DMA_RST_SCSI 0x00000080 /* Reset the SCSI controller */
  35. #define DMA_RST_ENET DMA_RST_SCSI /* Reset the ENET controller */
  36. #define DMA_ST_WRITE 0x00000100 /* write from device to memory */
  37. #define DMA_ENABLE 0x00000200 /* Fire up DMA, handle requests */
  38. #define DMA_PEND_READ 0x00000400 /* DMA_VERS1/0/PLUS Pending Read */
  39. #define DMA_ESC_BURST 0x00000800 /* 1=16byte 0=32byte */
  40. #define DMA_READ_AHEAD 0x00001800 /* DMA read ahead partial longword */
  41. #define DMA_DSBL_RD_DRN 0x00001000 /* No EC drain on slave reads */
  42. #define DMA_BCNT_ENAB 0x00002000 /* If on, use the byte counter */
  43. #define DMA_TERM_CNTR 0x00004000 /* Terminal counter */
  44. #define DMA_SCSI_SBUS64 0x00008000 /* HME: Enable 64-bit SBUS mode. */
  45. #define DMA_CSR_DISAB 0x00010000 /* No FIFO drains during csr */
  46. #define DMA_SCSI_DISAB 0x00020000 /* No FIFO drains during reg */
  47. #define DMA_DSBL_WR_INV 0x00020000 /* No EC inval. on slave writes */
  48. #define DMA_ADD_ENABLE 0x00040000 /* Special ESC DVMA optimization */
  49. #define DMA_E_BURSTS 0x000c0000 /* ENET: SBUS r/w burst mask */
  50. #define DMA_E_BURST32 0x00040000 /* ENET: SBUS 32 byte r/w burst */
  51. #define DMA_E_BURST16 0x00000000 /* ENET: SBUS 16 byte r/w burst */
  52. #define DMA_BRST_SZ 0x000c0000 /* SCSI: SBUS r/w burst size */
  53. #define DMA_BRST64 0x000c0000 /* SCSI: 64byte bursts (HME on UltraSparc only) */
  54. #define DMA_BRST32 0x00040000 /* SCSI: 32byte bursts */
  55. #define DMA_BRST16 0x00000000 /* SCSI: 16byte bursts */
  56. #define DMA_BRST0 0x00080000 /* SCSI: no bursts (non-HME gate arrays) */
  57. #define DMA_ADDR_DISAB 0x00100000 /* No FIFO drains during addr */
  58. #define DMA_2CLKS 0x00200000 /* Each transfer = 2 clock ticks */
  59. #define DMA_3CLKS 0x00400000 /* Each transfer = 3 clock ticks */
  60. #define DMA_EN_ENETAUI DMA_3CLKS /* Put lance into AUI-cable mode */
  61. #define DMA_CNTR_DISAB 0x00800000 /* No IRQ when DMA_TERM_CNTR set */
  62. #define DMA_AUTO_NADDR 0x01000000 /* Use "auto nxt addr" feature */
  63. #define DMA_SCSI_ON 0x02000000 /* Enable SCSI dma */
  64. #define DMA_PARITY_OFF 0x02000000 /* HME: disable parity checking */
  65. #define DMA_LOADED_ADDR 0x04000000 /* Address has been loaded */
  66. #define DMA_LOADED_NADDR 0x08000000 /* Next address has been loaded */
  67. #define DMA_RESET_FAS366 0x08000000 /* HME: Assert RESET to FAS366 */
  68. /* Values describing the burst-size property from the PROM */
  69. #define DMA_BURST1 0x01
  70. #define DMA_BURST2 0x02
  71. #define DMA_BURST4 0x04
  72. #define DMA_BURST8 0x08
  73. #define DMA_BURST16 0x10
  74. #define DMA_BURST32 0x20
  75. #define DMA_BURST64 0x40
  76. #define DMA_BURSTBITS 0x7f
  77. /* From PCI */
  78. #ifdef CONFIG_PCI
  79. extern int isa_dma_bridge_buggy;
  80. #else
  81. #define isa_dma_bridge_buggy (0)
  82. #endif
  83. #ifdef CONFIG_SPARC32
  84. /* Routines for data transfer buffers. */
  85. struct device;
  86. struct scatterlist;
  87. struct sparc32_dma_ops {
  88. __u32 (*get_scsi_one)(struct device *, char *, unsigned long);
  89. void (*get_scsi_sgl)(struct device *, struct scatterlist *, int);
  90. void (*release_scsi_one)(struct device *, __u32, unsigned long);
  91. void (*release_scsi_sgl)(struct device *, struct scatterlist *,int);
  92. #ifdef CONFIG_SBUS
  93. int (*map_dma_area)(struct device *, dma_addr_t *, unsigned long, unsigned long, int);
  94. void (*unmap_dma_area)(struct device *, unsigned long, int);
  95. #endif
  96. };
  97. extern const struct sparc32_dma_ops *sparc32_dma_ops;
  98. #define mmu_get_scsi_one(dev,vaddr,len) \
  99. sparc32_dma_ops->get_scsi_one(dev, vaddr, len)
  100. #define mmu_get_scsi_sgl(dev,sg,sz) \
  101. sparc32_dma_ops->get_scsi_sgl(dev, sg, sz)
  102. #define mmu_release_scsi_one(dev,vaddr,len) \
  103. sparc32_dma_ops->release_scsi_one(dev, vaddr,len)
  104. #define mmu_release_scsi_sgl(dev,sg,sz) \
  105. sparc32_dma_ops->release_scsi_sgl(dev, sg, sz)
  106. #ifdef CONFIG_SBUS
  107. /*
  108. * mmu_map/unmap are provided by iommu/iounit; Invalid to call on IIep.
  109. *
  110. * The mmu_map_dma_area establishes two mappings in one go.
  111. * These mappings point to pages normally mapped at 'va' (linear address).
  112. * First mapping is for CPU visible address at 'a', uncached.
  113. * This is an alias, but it works because it is an uncached mapping.
  114. * Second mapping is for device visible address, or "bus" address.
  115. * The bus address is returned at '*pba'.
  116. *
  117. * These functions seem distinct, but are hard to split.
  118. * On sun4m, page attributes depend on the CPU type, so we have to
  119. * know if we are mapping RAM or I/O, so it has to be an additional argument
  120. * to a separate mapping function for CPU visible mappings.
  121. */
  122. #define sbus_map_dma_area(dev,pba,va,a,len) \
  123. sparc32_dma_ops->map_dma_area(dev, pba, va, a, len)
  124. #define sbus_unmap_dma_area(dev,ba,len) \
  125. sparc32_dma_ops->unmap_dma_area(dev, ba, len)
  126. #endif /* CONFIG_SBUS */
  127. #endif
  128. #endif /* !(_ASM_SPARC_DMA_H) */