dma-sh.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * arch/sh/include/asm/dma-sh.h
  3. *
  4. * Copyright (C) 2000 Takashi YOSHII
  5. * Copyright (C) 2003 Paul Mundt
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #ifndef __DMA_SH_H
  12. #define __DMA_SH_H
  13. #include <asm/dma.h>
  14. #include <cpu/dma.h>
  15. /* DMAOR contorl: The DMAOR access size is different by CPU.*/
  16. #if defined(CONFIG_CPU_SUBTYPE_SH7723) || \
  17. defined(CONFIG_CPU_SUBTYPE_SH7724) || \
  18. defined(CONFIG_CPU_SUBTYPE_SH7780) || \
  19. defined(CONFIG_CPU_SUBTYPE_SH7785)
  20. #define dmaor_read_reg(n) \
  21. (n ? __raw_readw(SH_DMAC_BASE1 + DMAOR) \
  22. : __raw_readw(SH_DMAC_BASE0 + DMAOR))
  23. #define dmaor_write_reg(n, data) \
  24. (n ? __raw_writew(data, SH_DMAC_BASE1 + DMAOR) \
  25. : __raw_writew(data, SH_DMAC_BASE0 + DMAOR))
  26. #else /* Other CPU */
  27. #define dmaor_read_reg(n) __raw_readw(SH_DMAC_BASE0 + DMAOR)
  28. #define dmaor_write_reg(n, data) __raw_writew(data, SH_DMAC_BASE0 + DMAOR)
  29. #endif
  30. static int dmte_irq_map[] __maybe_unused = {
  31. #if (MAX_DMA_CHANNELS >= 4)
  32. DMTE0_IRQ,
  33. DMTE0_IRQ + 1,
  34. DMTE0_IRQ + 2,
  35. DMTE0_IRQ + 3,
  36. #endif
  37. #if (MAX_DMA_CHANNELS >= 6)
  38. DMTE4_IRQ,
  39. DMTE4_IRQ + 1,
  40. #endif
  41. #if (MAX_DMA_CHANNELS >= 8)
  42. DMTE6_IRQ,
  43. DMTE6_IRQ + 1,
  44. #endif
  45. #if (MAX_DMA_CHANNELS >= 12)
  46. DMTE8_IRQ,
  47. DMTE9_IRQ,
  48. DMTE10_IRQ,
  49. DMTE11_IRQ,
  50. #endif
  51. };
  52. /* Definitions for the SuperH DMAC */
  53. #define REQ_L 0x00000000
  54. #define REQ_E 0x00080000
  55. #define RACK_H 0x00000000
  56. #define RACK_L 0x00040000
  57. #define ACK_R 0x00000000
  58. #define ACK_W 0x00020000
  59. #define ACK_H 0x00000000
  60. #define ACK_L 0x00010000
  61. #define DM_INC 0x00004000
  62. #define DM_DEC 0x00008000
  63. #define DM_FIX 0x0000c000
  64. #define SM_INC 0x00001000
  65. #define SM_DEC 0x00002000
  66. #define SM_FIX 0x00003000
  67. #define RS_IN 0x00000200
  68. #define RS_OUT 0x00000300
  69. #define TS_BLK 0x00000040
  70. #define TM_BUR 0x00000020
  71. #define CHCR_DE 0x00000001
  72. #define CHCR_TE 0x00000002
  73. #define CHCR_IE 0x00000004
  74. /* DMAOR definitions */
  75. #define DMAOR_AE 0x00000004
  76. #define DMAOR_NMIF 0x00000002
  77. #define DMAOR_DME 0x00000001
  78. /*
  79. * Define the default configuration for dual address memory-memory transfer.
  80. * The 0x400 value represents auto-request, external->external.
  81. */
  82. #define RS_DUAL (DM_INC | SM_INC | 0x400 | TS_INDEX2VAL(XMIT_SZ_32BIT))
  83. /* DMA base address */
  84. static u32 dma_base_addr[] __maybe_unused = {
  85. #if (MAX_DMA_CHANNELS >= 4)
  86. SH_DMAC_BASE0 + 0x00, /* channel 0 */
  87. SH_DMAC_BASE0 + 0x10,
  88. SH_DMAC_BASE0 + 0x20,
  89. SH_DMAC_BASE0 + 0x30,
  90. #endif
  91. #if (MAX_DMA_CHANNELS >= 6)
  92. SH_DMAC_BASE0 + 0x50,
  93. SH_DMAC_BASE0 + 0x60,
  94. #endif
  95. #if (MAX_DMA_CHANNELS >= 8)
  96. SH_DMAC_BASE1 + 0x00,
  97. SH_DMAC_BASE1 + 0x10,
  98. #endif
  99. #if (MAX_DMA_CHANNELS >= 12)
  100. SH_DMAC_BASE1 + 0x20,
  101. SH_DMAC_BASE1 + 0x30,
  102. SH_DMAC_BASE1 + 0x50,
  103. SH_DMAC_BASE1 + 0x60, /* channel 11 */
  104. #endif
  105. };
  106. /* DMA register */
  107. #define SAR 0x00
  108. #define DAR 0x04
  109. #define TCR 0x08
  110. #define CHCR 0x0C
  111. #define DMAOR 0x40
  112. /*
  113. * for dma engine
  114. *
  115. * SuperH DMA mode
  116. */
  117. #define SHDMA_MIX_IRQ (1 << 1)
  118. #define SHDMA_DMAOR1 (1 << 2)
  119. #define SHDMA_DMAE1 (1 << 3)
  120. enum sh_dmae_slave_chan_id {
  121. SHDMA_SLAVE_SCIF0_TX,
  122. SHDMA_SLAVE_SCIF0_RX,
  123. SHDMA_SLAVE_SCIF1_TX,
  124. SHDMA_SLAVE_SCIF1_RX,
  125. SHDMA_SLAVE_SCIF2_TX,
  126. SHDMA_SLAVE_SCIF2_RX,
  127. SHDMA_SLAVE_SCIF3_TX,
  128. SHDMA_SLAVE_SCIF3_RX,
  129. SHDMA_SLAVE_SCIF4_TX,
  130. SHDMA_SLAVE_SCIF4_RX,
  131. SHDMA_SLAVE_SCIF5_TX,
  132. SHDMA_SLAVE_SCIF5_RX,
  133. SHDMA_SLAVE_SIUA_TX,
  134. SHDMA_SLAVE_SIUA_RX,
  135. SHDMA_SLAVE_SIUB_TX,
  136. SHDMA_SLAVE_SIUB_RX,
  137. SHDMA_SLAVE_NUMBER, /* Must stay last */
  138. };
  139. struct sh_dmae_slave_config {
  140. enum sh_dmae_slave_chan_id slave_id;
  141. dma_addr_t addr;
  142. u32 chcr;
  143. char mid_rid;
  144. };
  145. struct sh_dmae_pdata {
  146. unsigned int mode;
  147. struct sh_dmae_slave_config *config;
  148. int config_num;
  149. };
  150. struct device;
  151. struct sh_dmae_slave {
  152. enum sh_dmae_slave_chan_id slave_id; /* Set by the platform */
  153. struct device *dma_dev; /* Set by the platform */
  154. struct sh_dmae_slave_config *config; /* Set by the driver */
  155. };
  156. #endif /* __DMA_SH_H */