dma.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* linux/include/asm-arm/arch-msm/dma.h
  2. *
  3. * Copyright (C) 2007 Google, Inc.
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #ifndef __ASM_ARCH_MSM_DMA_H
  16. #include <linux/list.h>
  17. #include <mach/msm_iomap.h>
  18. struct msm_dmov_errdata {
  19. uint32_t flush[6];
  20. };
  21. struct msm_dmov_cmd {
  22. struct list_head list;
  23. unsigned int cmdptr;
  24. void (*complete_func)(struct msm_dmov_cmd *cmd,
  25. unsigned int result,
  26. struct msm_dmov_errdata *err);
  27. };
  28. void msm_dmov_enqueue_cmd(unsigned id, struct msm_dmov_cmd *cmd);
  29. void msm_dmov_stop_cmd(unsigned id, struct msm_dmov_cmd *cmd, int graceful);
  30. int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr);
  31. #define DMOV_SD0(off, ch) (MSM_DMOV_BASE + 0x0000 + (off) + ((ch) << 2))
  32. #define DMOV_SD1(off, ch) (MSM_DMOV_BASE + 0x0400 + (off) + ((ch) << 2))
  33. #define DMOV_SD2(off, ch) (MSM_DMOV_BASE + 0x0800 + (off) + ((ch) << 2))
  34. #define DMOV_SD3(off, ch) (MSM_DMOV_BASE + 0x0C00 + (off) + ((ch) << 2))
  35. /* only security domain 3 is available to the ARM11
  36. * SD0 -> mARM trusted, SD1 -> mARM nontrusted, SD2 -> aDSP, SD3 -> aARM
  37. */
  38. #define DMOV_CMD_PTR(ch) DMOV_SD3(0x000, ch)
  39. #define DMOV_CMD_LIST (0 << 29) /* does not work */
  40. #define DMOV_CMD_PTR_LIST (1 << 29) /* works */
  41. #define DMOV_CMD_INPUT_CFG (2 << 29) /* untested */
  42. #define DMOV_CMD_OUTPUT_CFG (3 << 29) /* untested */
  43. #define DMOV_CMD_ADDR(addr) ((addr) >> 3)
  44. #define DMOV_RSLT(ch) DMOV_SD3(0x040, ch)
  45. #define DMOV_RSLT_VALID (1 << 31) /* 0 == host has empties result fifo */
  46. #define DMOV_RSLT_ERROR (1 << 3)
  47. #define DMOV_RSLT_FLUSH (1 << 2)
  48. #define DMOV_RSLT_DONE (1 << 1) /* top pointer done */
  49. #define DMOV_RSLT_USER (1 << 0) /* command with FR force result */
  50. #define DMOV_FLUSH0(ch) DMOV_SD3(0x080, ch)
  51. #define DMOV_FLUSH1(ch) DMOV_SD3(0x0C0, ch)
  52. #define DMOV_FLUSH2(ch) DMOV_SD3(0x100, ch)
  53. #define DMOV_FLUSH3(ch) DMOV_SD3(0x140, ch)
  54. #define DMOV_FLUSH4(ch) DMOV_SD3(0x180, ch)
  55. #define DMOV_FLUSH5(ch) DMOV_SD3(0x1C0, ch)
  56. #define DMOV_STATUS(ch) DMOV_SD3(0x200, ch)
  57. #define DMOV_STATUS_RSLT_COUNT(n) (((n) >> 29))
  58. #define DMOV_STATUS_CMD_COUNT(n) (((n) >> 27) & 3)
  59. #define DMOV_STATUS_RSLT_VALID (1 << 1)
  60. #define DMOV_STATUS_CMD_PTR_RDY (1 << 0)
  61. #define DMOV_ISR DMOV_SD3(0x380, 0)
  62. #define DMOV_CONFIG(ch) DMOV_SD3(0x300, ch)
  63. #define DMOV_CONFIG_FORCE_TOP_PTR_RSLT (1 << 2)
  64. #define DMOV_CONFIG_FORCE_FLUSH_RSLT (1 << 1)
  65. #define DMOV_CONFIG_IRQ_EN (1 << 0)
  66. /* channel assignments */
  67. #define DMOV_NAND_CHAN 7
  68. #define DMOV_NAND_CRCI_CMD 5
  69. #define DMOV_NAND_CRCI_DATA 4
  70. #define DMOV_SDC1_CHAN 8
  71. #define DMOV_SDC1_CRCI 6
  72. #define DMOV_SDC2_CHAN 8
  73. #define DMOV_SDC2_CRCI 7
  74. #define DMOV_TSIF_CHAN 10
  75. #define DMOV_TSIF_CRCI 10
  76. #define DMOV_USB_CHAN 11
  77. /* no client rate control ifc (eg, ram) */
  78. #define DMOV_NONE_CRCI 0
  79. /* If the CMD_PTR register has CMD_PTR_LIST selected, the data mover
  80. * is going to walk a list of 32bit pointers as described below. Each
  81. * pointer points to a *array* of dmov_s, etc structs. The last pointer
  82. * in the list is marked with CMD_PTR_LP. The last struct in each array
  83. * is marked with CMD_LC (see below).
  84. */
  85. #define CMD_PTR_ADDR(addr) ((addr) >> 3)
  86. #define CMD_PTR_LP (1 << 31) /* last pointer */
  87. #define CMD_PTR_PT (3 << 29) /* ? */
  88. /* Single Item Mode */
  89. typedef struct {
  90. unsigned cmd;
  91. unsigned src;
  92. unsigned dst;
  93. unsigned len;
  94. } dmov_s;
  95. /* Scatter/Gather Mode */
  96. typedef struct {
  97. unsigned cmd;
  98. unsigned src_dscr;
  99. unsigned dst_dscr;
  100. unsigned _reserved;
  101. } dmov_sg;
  102. /* Box mode */
  103. typedef struct {
  104. uint32_t cmd;
  105. uint32_t src_row_addr;
  106. uint32_t dst_row_addr;
  107. uint32_t src_dst_len;
  108. uint32_t num_rows;
  109. uint32_t row_offset;
  110. } dmov_box;
  111. /* bits for the cmd field of the above structures */
  112. #define CMD_LC (1 << 31) /* last command */
  113. #define CMD_FR (1 << 22) /* force result -- does not work? */
  114. #define CMD_OCU (1 << 21) /* other channel unblock */
  115. #define CMD_OCB (1 << 20) /* other channel block */
  116. #define CMD_TCB (1 << 19) /* ? */
  117. #define CMD_DAH (1 << 18) /* destination address hold -- does not work?*/
  118. #define CMD_SAH (1 << 17) /* source address hold -- does not work? */
  119. #define CMD_MODE_SINGLE (0 << 0) /* dmov_s structure used */
  120. #define CMD_MODE_SG (1 << 0) /* untested */
  121. #define CMD_MODE_IND_SG (2 << 0) /* untested */
  122. #define CMD_MODE_BOX (3 << 0) /* untested */
  123. #define CMD_DST_SWAP_BYTES (1 << 14) /* exchange each byte n with byte n+1 */
  124. #define CMD_DST_SWAP_SHORTS (1 << 15) /* exchange each short n with short n+1 */
  125. #define CMD_DST_SWAP_WORDS (1 << 16) /* exchange each word n with word n+1 */
  126. #define CMD_SRC_SWAP_BYTES (1 << 11) /* exchange each byte n with byte n+1 */
  127. #define CMD_SRC_SWAP_SHORTS (1 << 12) /* exchange each short n with short n+1 */
  128. #define CMD_SRC_SWAP_WORDS (1 << 13) /* exchange each word n with word n+1 */
  129. #define CMD_DST_CRCI(n) (((n) & 15) << 7)
  130. #define CMD_SRC_CRCI(n) (((n) & 15) << 3)
  131. #endif