sirf-usp.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*
  2. * arch/arm/mach-prima2/include/mach/sirfsoc_usp.h
  3. *
  4. * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
  5. *
  6. * Licensed under GPLv2 or later.
  7. */
  8. #ifndef _SIRF_USP_H
  9. #define _SIRF_USP_H
  10. /* USP Registers */
  11. #define USP_MODE1 0x00
  12. #define USP_MODE2 0x04
  13. #define USP_TX_FRAME_CTRL 0x08
  14. #define USP_RX_FRAME_CTRL 0x0C
  15. #define USP_TX_RX_ENABLE 0x10
  16. #define USP_INT_ENABLE 0x14
  17. #define USP_INT_STATUS 0x18
  18. #define USP_PIN_IO_DATA 0x1C
  19. #define USP_RISC_DSP_MODE 0x20
  20. #define USP_AYSNC_PARAM_REG 0x24
  21. #define USP_IRDA_X_MODE_DIV 0x28
  22. #define USP_SM_CFG 0x2C
  23. #define USP_TX_DMA_IO_CTRL 0x100
  24. #define USP_TX_DMA_IO_LEN 0x104
  25. #define USP_TX_FIFO_CTRL 0x108
  26. #define USP_TX_FIFO_LEVEL_CHK 0x10C
  27. #define USP_TX_FIFO_OP 0x110
  28. #define USP_TX_FIFO_STATUS 0x114
  29. #define USP_TX_FIFO_DATA 0x118
  30. #define USP_RX_DMA_IO_CTRL 0x120
  31. #define USP_RX_DMA_IO_LEN 0x124
  32. #define USP_RX_FIFO_CTRL 0x128
  33. #define USP_RX_FIFO_LEVEL_CHK 0x12C
  34. #define USP_RX_FIFO_OP 0x130
  35. #define USP_RX_FIFO_STATUS 0x134
  36. #define USP_RX_FIFO_DATA 0x138
  37. /* USP MODE register-1 */
  38. #define USP_SYNC_MODE 0x00000001
  39. #define USP_CLOCK_MODE_SLAVE 0x00000002
  40. #define USP_LOOP_BACK_EN 0x00000004
  41. #define USP_HPSIR_EN 0x00000008
  42. #define USP_ENDIAN_CTRL_LSBF 0x00000010
  43. #define USP_EN 0x00000020
  44. #define USP_RXD_ACT_EDGE_FALLING 0x00000040
  45. #define USP_TXD_ACT_EDGE_FALLING 0x00000080
  46. #define USP_RFS_ACT_LEVEL_LOGIC1 0x00000100
  47. #define USP_TFS_ACT_LEVEL_LOGIC1 0x00000200
  48. #define USP_SCLK_IDLE_MODE_TOGGLE 0x00000400
  49. #define USP_SCLK_IDLE_LEVEL_LOGIC1 0x00000800
  50. #define USP_SCLK_PIN_MODE_IO 0x00001000
  51. #define USP_RFS_PIN_MODE_IO 0x00002000
  52. #define USP_TFS_PIN_MODE_IO 0x00004000
  53. #define USP_RXD_PIN_MODE_IO 0x00008000
  54. #define USP_TXD_PIN_MODE_IO 0x00010000
  55. #define USP_SCLK_IO_MODE_INPUT 0x00020000
  56. #define USP_RFS_IO_MODE_INPUT 0x00040000
  57. #define USP_TFS_IO_MODE_INPUT 0x00080000
  58. #define USP_RXD_IO_MODE_INPUT 0x00100000
  59. #define USP_TXD_IO_MODE_INPUT 0x00200000
  60. #define USP_IRDA_WIDTH_DIV_MASK 0x3FC00000
  61. #define USP_IRDA_WIDTH_DIV_OFFSET 0
  62. #define USP_IRDA_IDLE_LEVEL_HIGH 0x40000000
  63. #define USP_TX_UFLOW_REPEAT_ZERO 0x80000000
  64. #define USP_TX_ENDIAN_MODE 0x00000020
  65. #define USP_RX_ENDIAN_MODE 0x00000020
  66. /* USP Mode Register-2 */
  67. #define USP_RXD_DELAY_LEN_MASK 0x000000FF
  68. #define USP_RXD_DELAY_LEN_OFFSET 0
  69. #define USP_TXD_DELAY_LEN_MASK 0x0000FF00
  70. #define USP_TXD_DELAY_LEN_OFFSET 8
  71. #define USP_ENA_CTRL_MODE 0x00010000
  72. #define USP_FRAME_CTRL_MODE 0x00020000
  73. #define USP_TFS_SOURCE_MODE 0x00040000
  74. #define USP_TFS_MS_MODE 0x00080000
  75. #define USP_CLK_DIVISOR_MASK 0x7FE00000
  76. #define USP_CLK_DIVISOR_OFFSET 21
  77. #define USP_TFS_CLK_SLAVE_MODE (1<<20)
  78. #define USP_RFS_CLK_SLAVE_MODE (1<<19)
  79. #define USP_IRDA_DATA_WIDTH 0x80000000
  80. /* USP Transmit Frame Control Register */
  81. #define USP_TXC_DATA_LEN_MASK 0x000000FF
  82. #define USP_TXC_DATA_LEN_OFFSET 0
  83. #define USP_TXC_SYNC_LEN_MASK 0x0000FF00
  84. #define USP_TXC_SYNC_LEN_OFFSET 8
  85. #define USP_TXC_FRAME_LEN_MASK 0x00FF0000
  86. #define USP_TXC_FRAME_LEN_OFFSET 16
  87. #define USP_TXC_SHIFTER_LEN_MASK 0x1F000000
  88. #define USP_TXC_SHIFTER_LEN_OFFSET 24
  89. #define USP_TXC_SLAVE_CLK_SAMPLE 0x20000000
  90. #define USP_TXC_CLK_DIVISOR_MASK 0xC0000000
  91. #define USP_TXC_CLK_DIVISOR_OFFSET 30
  92. /* USP Receive Frame Control Register */
  93. #define USP_RXC_DATA_LEN_MASK 0x000000FF
  94. #define USP_RXC_DATA_LEN_OFFSET 0
  95. #define USP_RXC_FRAME_LEN_MASK 0x0000FF00
  96. #define USP_RXC_FRAME_LEN_OFFSET 8
  97. #define USP_RXC_SHIFTER_LEN_MASK 0x001F0000
  98. #define USP_RXC_SHIFTER_LEN_OFFSET 16
  99. #define USP_START_EDGE_MODE 0x00800000
  100. #define USP_I2S_SYNC_CHG 0x00200000
  101. #define USP_RXC_CLK_DIVISOR_MASK 0x0F000000
  102. #define USP_RXC_CLK_DIVISOR_OFFSET 24
  103. #define USP_SINGLE_SYNC_MODE 0x00400000
  104. /* Tx - RX Enable Register */
  105. #define USP_RX_ENA 0x00000001
  106. #define USP_TX_ENA 0x00000002
  107. /* USP Interrupt Enable and status Register */
  108. #define USP_RX_DONE_INT 0x00000001
  109. #define USP_TX_DONE_INT 0x00000002
  110. #define USP_RX_OFLOW_INT 0x00000004
  111. #define USP_TX_UFLOW_INT 0x00000008
  112. #define USP_RX_IO_DMA_INT 0x00000010
  113. #define USP_TX_IO_DMA_INT 0x00000020
  114. #define USP_RXFIFO_FULL_INT 0x00000040
  115. #define USP_TXFIFO_EMPTY_INT 0x00000080
  116. #define USP_RXFIFO_THD_INT 0x00000100
  117. #define USP_TXFIFO_THD_INT 0x00000200
  118. #define USP_UART_FRM_ERR_INT 0x00000400
  119. #define USP_RX_TIMEOUT_INT 0x00000800
  120. #define USP_TX_ALLOUT_INT 0x00001000
  121. #define USP_RXD_BREAK_INT 0x00008000
  122. /* All possible TX interruots */
  123. #define USP_TX_INTERRUPT (USP_TX_DONE_INT|USP_TX_UFLOW_INT|\
  124. USP_TX_IO_DMA_INT|\
  125. USP_TXFIFO_EMPTY_INT|\
  126. USP_TXFIFO_THD_INT)
  127. /* All possible RX interruots */
  128. #define USP_RX_INTERRUPT (USP_RX_DONE_INT|USP_RX_OFLOW_INT|\
  129. USP_RX_IO_DMA_INT|\
  130. USP_RXFIFO_FULL_INT|\
  131. USP_RXFIFO_THD_INT|\
  132. USP_RXFIFO_THD_INT|USP_RX_TIMEOUT_INT)
  133. #define USP_INT_ALL 0x1FFF
  134. /* USP Pin I/O Data Register */
  135. #define USP_RFS_PIN_VALUE_MASK 0x00000001
  136. #define USP_TFS_PIN_VALUE_MASK 0x00000002
  137. #define USP_RXD_PIN_VALUE_MASK 0x00000004
  138. #define USP_TXD_PIN_VALUE_MASK 0x00000008
  139. #define USP_SCLK_PIN_VALUE_MASK 0x00000010
  140. /* USP RISC/DSP Mode Register */
  141. #define USP_RISC_DSP_SEL 0x00000001
  142. /* USP ASYNC PARAMETER Register*/
  143. #define USP_ASYNC_TIMEOUT_MASK 0x0000FFFF
  144. #define USP_ASYNC_TIMEOUT_OFFSET 0
  145. #define USP_ASYNC_TIMEOUT(x) (((x)&USP_ASYNC_TIMEOUT_MASK) \
  146. <<USP_ASYNC_TIMEOUT_OFFSET)
  147. #define USP_ASYNC_DIV2_MASK 0x003F0000
  148. #define USP_ASYNC_DIV2_OFFSET 16
  149. /* USP TX DMA I/O MODE Register */
  150. #define USP_TX_MODE_IO 0x00000001
  151. /* USP TX DMA I/O Length Register */
  152. #define USP_TX_DATA_LEN_MASK 0xFFFFFFFF
  153. #define USP_TX_DATA_LEN_OFFSET 0
  154. /* USP TX FIFO Control Register */
  155. #define USP_TX_FIFO_WIDTH_MASK 0x00000003
  156. #define USP_TX_FIFO_WIDTH_OFFSET 0
  157. #define USP_TX_FIFO_THD_MASK 0x000001FC
  158. #define USP_TX_FIFO_THD_OFFSET 2
  159. /* USP TX FIFO Level Check Register */
  160. #define USP_TX_FIFO_LEVEL_CHECK_MASK 0x1F
  161. #define USP_TX_FIFO_SC_OFFSET 0
  162. #define USP_TX_FIFO_LC_OFFSET 10
  163. #define USP_TX_FIFO_HC_OFFSET 20
  164. #define TX_FIFO_SC(x) (((x) & USP_TX_FIFO_LEVEL_CHECK_MASK) \
  165. << USP_TX_FIFO_SC_OFFSET)
  166. #define TX_FIFO_LC(x) (((x) & USP_TX_FIFO_LEVEL_CHECK_MASK) \
  167. << USP_TX_FIFO_LC_OFFSET)
  168. #define TX_FIFO_HC(x) (((x) & USP_TX_FIFO_LEVEL_CHECK_MASK) \
  169. << USP_TX_FIFO_HC_OFFSET)
  170. /* USP TX FIFO Operation Register */
  171. #define USP_TX_FIFO_RESET 0x00000001
  172. #define USP_TX_FIFO_START 0x00000002
  173. /* USP TX FIFO Status Register */
  174. #define USP_TX_FIFO_LEVEL_MASK 0x0000007F
  175. #define USP_TX_FIFO_LEVEL_OFFSET 0
  176. #define USP_TX_FIFO_FULL 0x00000080
  177. #define USP_TX_FIFO_EMPTY 0x00000100
  178. /* USP TX FIFO Data Register */
  179. #define USP_TX_FIFO_DATA_MASK 0xFFFFFFFF
  180. #define USP_TX_FIFO_DATA_OFFSET 0
  181. /* USP RX DMA I/O MODE Register */
  182. #define USP_RX_MODE_IO 0x00000001
  183. #define USP_RX_DMA_FLUSH 0x00000004
  184. /* USP RX DMA I/O Length Register */
  185. #define USP_RX_DATA_LEN_MASK 0xFFFFFFFF
  186. #define USP_RX_DATA_LEN_OFFSET 0
  187. /* USP RX FIFO Control Register */
  188. #define USP_RX_FIFO_WIDTH_MASK 0x00000003
  189. #define USP_RX_FIFO_WIDTH_OFFSET 0
  190. #define USP_RX_FIFO_THD_MASK 0x000001FC
  191. #define USP_RX_FIFO_THD_OFFSET 2
  192. /* USP RX FIFO Level Check Register */
  193. #define USP_RX_FIFO_LEVEL_CHECK_MASK 0x1F
  194. #define USP_RX_FIFO_SC_OFFSET 0
  195. #define USP_RX_FIFO_LC_OFFSET 10
  196. #define USP_RX_FIFO_HC_OFFSET 20
  197. #define RX_FIFO_SC(x) (((x) & USP_RX_FIFO_LEVEL_CHECK_MASK) \
  198. << USP_RX_FIFO_SC_OFFSET)
  199. #define RX_FIFO_LC(x) (((x) & USP_RX_FIFO_LEVEL_CHECK_MASK) \
  200. << USP_RX_FIFO_LC_OFFSET)
  201. #define RX_FIFO_HC(x) (((x) & USP_RX_FIFO_LEVEL_CHECK_MASK) \
  202. << USP_RX_FIFO_HC_OFFSET)
  203. /* USP RX FIFO Operation Register */
  204. #define USP_RX_FIFO_RESET 0x00000001
  205. #define USP_RX_FIFO_START 0x00000002
  206. /* USP RX FIFO Status Register */
  207. #define USP_RX_FIFO_LEVEL_MASK 0x0000007F
  208. #define USP_RX_FIFO_LEVEL_OFFSET 0
  209. #define USP_RX_FIFO_FULL 0x00000080
  210. #define USP_RX_FIFO_EMPTY 0x00000100
  211. /* USP RX FIFO Data Register */
  212. #define USP_RX_FIFO_DATA_MASK 0xFFFFFFFF
  213. #define USP_RX_FIFO_DATA_OFFSET 0
  214. /*
  215. * When rx thd irq occur, sender just disable tx empty irq,
  216. * Remaining data in tx fifo wil also be sent out.
  217. */
  218. #define USP_FIFO_SIZE 128
  219. #define USP_TX_FIFO_THRESHOLD (USP_FIFO_SIZE/2)
  220. #define USP_RX_FIFO_THRESHOLD (USP_FIFO_SIZE/2)
  221. /* FIFO_WIDTH for the USP_TX_FIFO_CTRL and USP_RX_FIFO_CTRL registers */
  222. #define USP_FIFO_WIDTH_BYTE 0x00
  223. #define USP_FIFO_WIDTH_WORD 0x01
  224. #define USP_FIFO_WIDTH_DWORD 0x02
  225. #define USP_ASYNC_DIV2 16
  226. #define USP_PLUGOUT_RETRY_CNT 2
  227. #define USP_TX_RX_FIFO_WIDTH_DWORD 2
  228. #define SIRF_USP_DIV_MCLK 0
  229. #define SIRF_USP_I2S_TFS_SYNC 0
  230. #define SIRF_USP_I2S_RFS_SYNC 1
  231. #endif