tegra30_ahub.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. /*
  2. * tegra30_ahub.h - Definitions for Tegra30 AHUB driver
  3. *
  4. * Copyright (c) 2011,2012, NVIDIA CORPORATION. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __TEGRA30_AHUB_H__
  19. #define __TEGRA30_AHUB_H__
  20. /* Fields in *_CIF_RX/TX_CTRL; used by AHUB FIFOs, and all other audio modules */
  21. #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT 28
  22. #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US 0xf
  23. #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK (TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT)
  24. #define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT 24
  25. #define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US 0x3f
  26. #define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK (TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT)
  27. /* Channel count minus 1 */
  28. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT 24
  29. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US 7
  30. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT)
  31. /* Channel count minus 1 */
  32. #define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT 20
  33. #define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US 0xf
  34. #define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK (TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT)
  35. /* Channel count minus 1 */
  36. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT 16
  37. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US 7
  38. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT)
  39. /* Channel count minus 1 */
  40. #define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT 16
  41. #define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US 0xf
  42. #define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT)
  43. #define TEGRA30_AUDIOCIF_BITS_4 0
  44. #define TEGRA30_AUDIOCIF_BITS_8 1
  45. #define TEGRA30_AUDIOCIF_BITS_12 2
  46. #define TEGRA30_AUDIOCIF_BITS_16 3
  47. #define TEGRA30_AUDIOCIF_BITS_20 4
  48. #define TEGRA30_AUDIOCIF_BITS_24 5
  49. #define TEGRA30_AUDIOCIF_BITS_28 6
  50. #define TEGRA30_AUDIOCIF_BITS_32 7
  51. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT 12
  52. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_MASK (7 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  53. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_4 (TEGRA30_AUDIOCIF_BITS_4 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  54. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_8 (TEGRA30_AUDIOCIF_BITS_8 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  55. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_12 (TEGRA30_AUDIOCIF_BITS_12 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  56. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 (TEGRA30_AUDIOCIF_BITS_16 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  57. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_20 (TEGRA30_AUDIOCIF_BITS_20 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  58. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_24 (TEGRA30_AUDIOCIF_BITS_24 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  59. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_28 (TEGRA30_AUDIOCIF_BITS_28 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  60. #define TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_32 (TEGRA30_AUDIOCIF_BITS_32 << TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT)
  61. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT 8
  62. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_MASK (7 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  63. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_4 (TEGRA30_AUDIOCIF_BITS_4 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  64. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_8 (TEGRA30_AUDIOCIF_BITS_8 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  65. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_12 (TEGRA30_AUDIOCIF_BITS_12 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  66. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16 (TEGRA30_AUDIOCIF_BITS_16 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  67. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_20 (TEGRA30_AUDIOCIF_BITS_20 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  68. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_24 (TEGRA30_AUDIOCIF_BITS_24 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  69. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_28 (TEGRA30_AUDIOCIF_BITS_28 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  70. #define TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_32 (TEGRA30_AUDIOCIF_BITS_32 << TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT)
  71. #define TEGRA30_AUDIOCIF_EXPAND_ZERO 0
  72. #define TEGRA30_AUDIOCIF_EXPAND_ONE 1
  73. #define TEGRA30_AUDIOCIF_EXPAND_LFSR 2
  74. #define TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT 6
  75. #define TEGRA30_AUDIOCIF_CTRL_EXPAND_MASK (3 << TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT)
  76. #define TEGRA30_AUDIOCIF_CTRL_EXPAND_ZERO (TEGRA30_AUDIOCIF_EXPAND_ZERO << TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT)
  77. #define TEGRA30_AUDIOCIF_CTRL_EXPAND_ONE (TEGRA30_AUDIOCIF_EXPAND_ONE << TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT)
  78. #define TEGRA30_AUDIOCIF_CTRL_EXPAND_LFSR (TEGRA30_AUDIOCIF_EXPAND_LFSR << TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT)
  79. #define TEGRA30_AUDIOCIF_STEREO_CONV_CH0 0
  80. #define TEGRA30_AUDIOCIF_STEREO_CONV_CH1 1
  81. #define TEGRA30_AUDIOCIF_STEREO_CONV_AVG 2
  82. #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT 4
  83. #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_MASK (3 << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT)
  84. #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_CH0 (TEGRA30_AUDIOCIF_STEREO_CONV_CH0 << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT)
  85. #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_CH1 (TEGRA30_AUDIOCIF_STEREO_CONV_CH1 << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT)
  86. #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_AVG (TEGRA30_AUDIOCIF_STEREO_CONV_AVG << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT)
  87. #define TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT 3
  88. #define TEGRA30_AUDIOCIF_DIRECTION_TX 0
  89. #define TEGRA30_AUDIOCIF_DIRECTION_RX 1
  90. #define TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT 2
  91. #define TEGRA30_AUDIOCIF_CTRL_DIRECTION_MASK (1 << TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT)
  92. #define TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX (TEGRA30_AUDIOCIF_DIRECTION_TX << TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT)
  93. #define TEGRA30_AUDIOCIF_CTRL_DIRECTION_RX (TEGRA30_AUDIOCIF_DIRECTION_RX << TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT)
  94. #define TEGRA30_AUDIOCIF_TRUNCATE_ROUND 0
  95. #define TEGRA30_AUDIOCIF_TRUNCATE_CHOP 1
  96. #define TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT 1
  97. #define TEGRA30_AUDIOCIF_CTRL_TRUNCATE_MASK (1 << TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT)
  98. #define TEGRA30_AUDIOCIF_CTRL_TRUNCATE_ROUND (TEGRA30_AUDIOCIF_TRUNCATE_ROUND << TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT)
  99. #define TEGRA30_AUDIOCIF_CTRL_TRUNCATE_CHOP (TEGRA30_AUDIOCIF_TRUNCATE_CHOP << TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT)
  100. #define TEGRA30_AUDIOCIF_MONO_CONV_ZERO 0
  101. #define TEGRA30_AUDIOCIF_MONO_CONV_COPY 1
  102. #define TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT 0
  103. #define TEGRA30_AUDIOCIF_CTRL_MONO_CONV_MASK (1 << TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT)
  104. #define TEGRA30_AUDIOCIF_CTRL_MONO_CONV_ZERO (TEGRA30_AUDIOCIF_MONO_CONV_ZERO << TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT)
  105. #define TEGRA30_AUDIOCIF_CTRL_MONO_CONV_COPY (TEGRA30_AUDIOCIF_MONO_CONV_COPY << TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT)
  106. /* Registers within TEGRA30_AUDIO_CLUSTER_BASE */
  107. /* TEGRA30_AHUB_CHANNEL_CTRL */
  108. #define TEGRA30_AHUB_CHANNEL_CTRL 0x0
  109. #define TEGRA30_AHUB_CHANNEL_CTRL_STRIDE 0x20
  110. #define TEGRA30_AHUB_CHANNEL_CTRL_COUNT 4
  111. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_EN (1 << 31)
  112. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_EN (1 << 30)
  113. #define TEGRA30_AHUB_CHANNEL_CTRL_LOOPBACK (1 << 29)
  114. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_THRESHOLD_SHIFT 16
  115. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_THRESHOLD_MASK_US 0xff
  116. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_THRESHOLD_MASK (TEGRA30_AHUB_CHANNEL_CTRL_TX_THRESHOLD_MASK_US << TEGRA30_AHUB_CHANNEL_CTRL_TX_THRESHOLD_SHIFT)
  117. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_THRESHOLD_SHIFT 8
  118. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_THRESHOLD_MASK_US 0xff
  119. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_THRESHOLD_MASK (TEGRA30_AHUB_CHANNEL_CTRL_RX_THRESHOLD_MASK_US << TEGRA30_AHUB_CHANNEL_CTRL_RX_THRESHOLD_SHIFT)
  120. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_EN (1 << 6)
  121. #define TEGRA30_PACK_8_4 2
  122. #define TEGRA30_PACK_16 3
  123. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_SHIFT 4
  124. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_MASK_US 3
  125. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_MASK (TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_MASK_US << TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_SHIFT)
  126. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_8_4 (TEGRA30_PACK_8_4 << TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_SHIFT)
  127. #define TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_16 (TEGRA30_PACK_16 << TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_SHIFT)
  128. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_EN (1 << 2)
  129. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_SHIFT 0
  130. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_MASK_US 3
  131. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_MASK (TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_MASK_US << TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_SHIFT)
  132. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_8_4 (TEGRA30_PACK_8_4 << TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_SHIFT)
  133. #define TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_16 (TEGRA30_PACK_16 << TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_SHIFT)
  134. /* TEGRA30_AHUB_CHANNEL_CLEAR */
  135. #define TEGRA30_AHUB_CHANNEL_CLEAR 0x4
  136. #define TEGRA30_AHUB_CHANNEL_CLEAR_STRIDE 0x20
  137. #define TEGRA30_AHUB_CHANNEL_CLEAR_COUNT 4
  138. #define TEGRA30_AHUB_CHANNEL_CLEAR_TX_SOFT_RESET (1 << 31)
  139. #define TEGRA30_AHUB_CHANNEL_CLEAR_RX_SOFT_RESET (1 << 30)
  140. /* TEGRA30_AHUB_CHANNEL_STATUS */
  141. #define TEGRA30_AHUB_CHANNEL_STATUS 0x8
  142. #define TEGRA30_AHUB_CHANNEL_STATUS_STRIDE 0x20
  143. #define TEGRA30_AHUB_CHANNEL_STATUS_COUNT 4
  144. #define TEGRA30_AHUB_CHANNEL_STATUS_TX_FREE_SHIFT 24
  145. #define TEGRA30_AHUB_CHANNEL_STATUS_TX_FREE_MASK_US 0xff
  146. #define TEGRA30_AHUB_CHANNEL_STATUS_TX_FREE_MASK (TEGRA30_AHUB_CHANNEL_STATUS_TX_FREE_MASK_US << TEGRA30_AHUB_CHANNEL_STATUS_TX_FREE_SHIFT)
  147. #define TEGRA30_AHUB_CHANNEL_STATUS_RX_FREE_SHIFT 16
  148. #define TEGRA30_AHUB_CHANNEL_STATUS_RX_FREE_MASK_US 0xff
  149. #define TEGRA30_AHUB_CHANNEL_STATUS_RX_FREE_MASK (TEGRA30_AHUB_CHANNEL_STATUS_RX_FREE_MASK_US << TEGRA30_AHUB_CHANNEL_STATUS_RX_FREE_SHIFT)
  150. #define TEGRA30_AHUB_CHANNEL_STATUS_TX_TRIG (1 << 1)
  151. #define TEGRA30_AHUB_CHANNEL_STATUS_RX_TRIG (1 << 0)
  152. /* TEGRA30_AHUB_CHANNEL_TXFIFO */
  153. #define TEGRA30_AHUB_CHANNEL_TXFIFO 0xc
  154. #define TEGRA30_AHUB_CHANNEL_TXFIFO_STRIDE 0x20
  155. #define TEGRA30_AHUB_CHANNEL_TXFIFO_COUNT 4
  156. /* TEGRA30_AHUB_CHANNEL_RXFIFO */
  157. #define TEGRA30_AHUB_CHANNEL_RXFIFO 0x10
  158. #define TEGRA30_AHUB_CHANNEL_RXFIFO_STRIDE 0x20
  159. #define TEGRA30_AHUB_CHANNEL_RXFIFO_COUNT 4
  160. /* TEGRA30_AHUB_CIF_TX_CTRL */
  161. #define TEGRA30_AHUB_CIF_TX_CTRL 0x14
  162. #define TEGRA30_AHUB_CIF_TX_CTRL_STRIDE 0x20
  163. #define TEGRA30_AHUB_CIF_TX_CTRL_COUNT 4
  164. /* Uses field from TEGRA30_AUDIOCIF_CTRL_* */
  165. /* TEGRA30_AHUB_CIF_RX_CTRL */
  166. #define TEGRA30_AHUB_CIF_RX_CTRL 0x18
  167. #define TEGRA30_AHUB_CIF_RX_CTRL_STRIDE 0x20
  168. #define TEGRA30_AHUB_CIF_RX_CTRL_COUNT 4
  169. /* Uses field from TEGRA30_AUDIOCIF_CTRL_* */
  170. /* TEGRA30_AHUB_CONFIG_LINK_CTRL */
  171. #define TEGRA30_AHUB_CONFIG_LINK_CTRL 0x80
  172. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_MASTER_FIFO_FULL_CNT_SHIFT 28
  173. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_MASTER_FIFO_FULL_CNT_MASK_US 0xf
  174. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_MASTER_FIFO_FULL_CNT_MASK (TEGRA30_AHUB_CONFIG_LINK_CTRL_MASTER_FIFO_FULL_CNT_MASK_US << TEGRA30_AHUB_CONFIG_LINK_CTRL_MASTER_FIFO_FULL_CNT_SHIFT)
  175. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_TIMEOUT_CNT_SHIFT 16
  176. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_TIMEOUT_CNT_MASK_US 0xfff
  177. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_TIMEOUT_CNT_MASK (TEGRA30_AHUB_CONFIG_LINK_CTRL_TIMEOUT_CNT_MASK_US << TEGRA30_AHUB_CONFIG_LINK_CTRL_TIMEOUT_CNT_SHIFT)
  178. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_IDLE_CNT_SHIFT 4
  179. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_IDLE_CNT_MASK_US 0xfff
  180. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_IDLE_CNT_MASK (TEGRA30_AHUB_CONFIG_LINK_CTRL_IDLE_CNT_MASK_US << TEGRA30_AHUB_CONFIG_LINK_CTRL_IDLE_CNT_SHIFT)
  181. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_CG_EN (1 << 2)
  182. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_CLEAR_TIMEOUT_CNTR (1 << 1)
  183. #define TEGRA30_AHUB_CONFIG_LINK_CTRL_SOFT_RESET (1 << 0)
  184. /* TEGRA30_AHUB_MISC_CTRL */
  185. #define TEGRA30_AHUB_MISC_CTRL 0x84
  186. #define TEGRA30_AHUB_MISC_CTRL_AUDIO_ACTIVE (1 << 31)
  187. #define TEGRA30_AHUB_MISC_CTRL_AUDIO_CG_EN (1 << 8)
  188. #define TEGRA30_AHUB_MISC_CTRL_AUDIO_OBS_SEL_SHIFT 0
  189. #define TEGRA30_AHUB_MISC_CTRL_AUDIO_OBS_SEL_MASK (0x1f << TEGRA30_AHUB_MISC_CTRL_AUDIO_OBS_SEL_SHIFT)
  190. /* TEGRA30_AHUB_APBDMA_LIVE_STATUS */
  191. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS 0x88
  192. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH3_RX_CIF_FIFO_FULL (1 << 31)
  193. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH3_TX_CIF_FIFO_FULL (1 << 30)
  194. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH2_RX_CIF_FIFO_FULL (1 << 29)
  195. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH2_TX_CIF_FIFO_FULL (1 << 28)
  196. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH1_RX_CIF_FIFO_FULL (1 << 27)
  197. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH1_TX_CIF_FIFO_FULL (1 << 26)
  198. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH0_RX_CIF_FIFO_FULL (1 << 25)
  199. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH0_TX_CIF_FIFO_FULL (1 << 24)
  200. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH3_RX_CIF_FIFO_EMPTY (1 << 23)
  201. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH3_TX_CIF_FIFO_EMPTY (1 << 22)
  202. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH2_RX_CIF_FIFO_EMPTY (1 << 21)
  203. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH2_TX_CIF_FIFO_EMPTY (1 << 20)
  204. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH1_RX_CIF_FIFO_EMPTY (1 << 19)
  205. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH1_TX_CIF_FIFO_EMPTY (1 << 18)
  206. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH0_RX_CIF_FIFO_EMPTY (1 << 17)
  207. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH0_TX_CIF_FIFO_EMPTY (1 << 16)
  208. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH3_RX_DMA_FIFO_FULL (1 << 15)
  209. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH3_TX_DMA_FIFO_FULL (1 << 14)
  210. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH2_RX_DMA_FIFO_FULL (1 << 13)
  211. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH2_TX_DMA_FIFO_FULL (1 << 12)
  212. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH1_RX_DMA_FIFO_FULL (1 << 11)
  213. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH1_TX_DMA_FIFO_FULL (1 << 10)
  214. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH0_RX_DMA_FIFO_FULL (1 << 9)
  215. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH0_TX_DMA_FIFO_FULL (1 << 8)
  216. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH3_RX_DMA_FIFO_EMPTY (1 << 7)
  217. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH3_TX_DMA_FIFO_EMPTY (1 << 6)
  218. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH2_RX_DMA_FIFO_EMPTY (1 << 5)
  219. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH2_TX_DMA_FIFO_EMPTY (1 << 4)
  220. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH1_RX_DMA_FIFO_EMPTY (1 << 3)
  221. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH1_TX_DMA_FIFO_EMPTY (1 << 2)
  222. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH0_RX_DMA_FIFO_EMPTY (1 << 1)
  223. #define TEGRA30_AHUB_APBDMA_LIVE_STATUS_CH0_TX_DMA_FIFO_EMPTY (1 << 0)
  224. /* TEGRA30_AHUB_I2S_LIVE_STATUS */
  225. #define TEGRA30_AHUB_I2S_LIVE_STATUS 0x8c
  226. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S4_RX_FIFO_FULL (1 << 29)
  227. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S4_TX_FIFO_FULL (1 << 28)
  228. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S3_RX_FIFO_FULL (1 << 27)
  229. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S3_TX_FIFO_FULL (1 << 26)
  230. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S2_RX_FIFO_FULL (1 << 25)
  231. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S2_TX_FIFO_FULL (1 << 24)
  232. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S1_RX_FIFO_FULL (1 << 23)
  233. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S1_TX_FIFO_FULL (1 << 22)
  234. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S0_RX_FIFO_FULL (1 << 21)
  235. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S0_TX_FIFO_FULL (1 << 20)
  236. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S4_RX_FIFO_ENABLED (1 << 19)
  237. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S4_TX_FIFO_ENABLED (1 << 18)
  238. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S3_RX_FIFO_ENABLED (1 << 17)
  239. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S3_TX_FIFO_ENABLED (1 << 16)
  240. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S2_RX_FIFO_ENABLED (1 << 15)
  241. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S2_TX_FIFO_ENABLED (1 << 14)
  242. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S1_RX_FIFO_ENABLED (1 << 13)
  243. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S1_TX_FIFO_ENABLED (1 << 12)
  244. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S0_RX_FIFO_ENABLED (1 << 11)
  245. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S0_TX_FIFO_ENABLED (1 << 10)
  246. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S4_RX_FIFO_EMPTY (1 << 9)
  247. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S4_TX_FIFO_EMPTY (1 << 8)
  248. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S3_RX_FIFO_EMPTY (1 << 7)
  249. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S3_TX_FIFO_EMPTY (1 << 6)
  250. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S2_RX_FIFO_EMPTY (1 << 5)
  251. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S2_TX_FIFO_EMPTY (1 << 4)
  252. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S1_RX_FIFO_EMPTY (1 << 3)
  253. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S1_TX_FIFO_EMPTY (1 << 2)
  254. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S0_RX_FIFO_EMPTY (1 << 1)
  255. #define TEGRA30_AHUB_I2S_LIVE_STATUS_I2S0_TX_FIFO_EMPTY (1 << 0)
  256. /* TEGRA30_AHUB_DAM0_LIVE_STATUS */
  257. #define TEGRA30_AHUB_DAM_LIVE_STATUS 0x90
  258. #define TEGRA30_AHUB_DAM_LIVE_STATUS_STRIDE 0x8
  259. #define TEGRA30_AHUB_DAM_LIVE_STATUS_COUNT 3
  260. #define TEGRA30_AHUB_DAM_LIVE_STATUS_TX_ENABLED (1 << 26)
  261. #define TEGRA30_AHUB_DAM_LIVE_STATUS_RX1_ENABLED (1 << 25)
  262. #define TEGRA30_AHUB_DAM_LIVE_STATUS_RX0_ENABLED (1 << 24)
  263. #define TEGRA30_AHUB_DAM_LIVE_STATUS_TXFIFO_FULL (1 << 15)
  264. #define TEGRA30_AHUB_DAM_LIVE_STATUS_RX1FIFO_FULL (1 << 9)
  265. #define TEGRA30_AHUB_DAM_LIVE_STATUS_RX0FIFO_FULL (1 << 8)
  266. #define TEGRA30_AHUB_DAM_LIVE_STATUS_TXFIFO_EMPTY (1 << 7)
  267. #define TEGRA30_AHUB_DAM_LIVE_STATUS_RX1FIFO_EMPTY (1 << 1)
  268. #define TEGRA30_AHUB_DAM_LIVE_STATUS_RX0FIFO_EMPTY (1 << 0)
  269. /* TEGRA30_AHUB_SPDIF_LIVE_STATUS */
  270. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS 0xa8
  271. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_USER_TX_ENABLED (1 << 11)
  272. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_USER_RX_ENABLED (1 << 10)
  273. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_DATA_TX_ENABLED (1 << 9)
  274. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_DATA_RX_ENABLED (1 << 8)
  275. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_USER_TXFIFO_FULL (1 << 7)
  276. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_USER_RXFIFO_FULL (1 << 6)
  277. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_DATA_TXFIFO_FULL (1 << 5)
  278. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_DATA_RXFIFO_FULL (1 << 4)
  279. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_USER_TXFIFO_EMPTY (1 << 3)
  280. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_USER_RXFIFO_EMPTY (1 << 2)
  281. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_DATA_TXFIFO_EMPTY (1 << 1)
  282. #define TEGRA30_AHUB_SPDIF_LIVE_STATUS_DATA_RXFIFO_EMPTY (1 << 0)
  283. /* TEGRA30_AHUB_I2S_INT_MASK */
  284. #define TEGRA30_AHUB_I2S_INT_MASK 0xb0
  285. /* TEGRA30_AHUB_DAM_INT_MASK */
  286. #define TEGRA30_AHUB_DAM_INT_MASK 0xb4
  287. /* TEGRA30_AHUB_SPDIF_INT_MASK */
  288. #define TEGRA30_AHUB_SPDIF_INT_MASK 0xbc
  289. /* TEGRA30_AHUB_APBIF_INT_MASK */
  290. #define TEGRA30_AHUB_APBIF_INT_MASK 0xc0
  291. /* TEGRA30_AHUB_I2S_INT_STATUS */
  292. #define TEGRA30_AHUB_I2S_INT_STATUS 0xc8
  293. /* TEGRA30_AHUB_DAM_INT_STATUS */
  294. #define TEGRA30_AHUB_DAM_INT_STATUS 0xcc
  295. /* TEGRA30_AHUB_SPDIF_INT_STATUS */
  296. #define TEGRA30_AHUB_SPDIF_INT_STATUS 0xd4
  297. /* TEGRA30_AHUB_APBIF_INT_STATUS */
  298. #define TEGRA30_AHUB_APBIF_INT_STATUS 0xd8
  299. /* TEGRA30_AHUB_I2S_INT_SOURCE */
  300. #define TEGRA30_AHUB_I2S_INT_SOURCE 0xe0
  301. /* TEGRA30_AHUB_DAM_INT_SOURCE */
  302. #define TEGRA30_AHUB_DAM_INT_SOURCE 0xe4
  303. /* TEGRA30_AHUB_SPDIF_INT_SOURCE */
  304. #define TEGRA30_AHUB_SPDIF_INT_SOURCE 0xec
  305. /* TEGRA30_AHUB_APBIF_INT_SOURCE */
  306. #define TEGRA30_AHUB_APBIF_INT_SOURCE 0xf0
  307. /* TEGRA30_AHUB_I2S_INT_SET */
  308. #define TEGRA30_AHUB_I2S_INT_SET 0xf8
  309. /* TEGRA30_AHUB_DAM_INT_SET */
  310. #define TEGRA30_AHUB_DAM_INT_SET 0xfc
  311. /* TEGRA30_AHUB_SPDIF_INT_SET */
  312. #define TEGRA30_AHUB_SPDIF_INT_SET 0x100
  313. /* TEGRA30_AHUB_APBIF_INT_SET */
  314. #define TEGRA30_AHUB_APBIF_INT_SET 0x104
  315. /* Registers within TEGRA30_AHUB_BASE */
  316. #define TEGRA30_AHUB_AUDIO_RX 0x0
  317. #define TEGRA30_AHUB_AUDIO_RX_STRIDE 0x4
  318. #define TEGRA30_AHUB_AUDIO_RX_COUNT 17
  319. /* This register repeats once for each entry in enum tegra30_ahub_rxcif */
  320. /* The fields in this register are 1 bit per entry in tegra30_ahub_txcif */
  321. /*
  322. * Terminology:
  323. * AHUB: Audio Hub; a cross-bar switch between the audio devices: DMA FIFOs,
  324. * I2S controllers, SPDIF controllers, and DAMs.
  325. * XBAR: The core cross-bar component of the AHUB.
  326. * CIF: Client Interface; the HW module connecting an audio device to the
  327. * XBAR.
  328. * DAM: Digital Audio Mixer: A HW module that mixes multiple audio streams,
  329. * possibly including sample-rate conversion.
  330. *
  331. * Each TX CIF transmits data into the XBAR. Each RX CIF can receive audio
  332. * transmitted by a particular TX CIF.
  333. *
  334. * This driver is currently very simplistic; many HW features are not
  335. * exposed; DAMs are not supported, only 16-bit stereo audio is supported,
  336. * etc.
  337. */
  338. enum tegra30_ahub_txcif {
  339. TEGRA30_AHUB_TXCIF_APBIF_TX0,
  340. TEGRA30_AHUB_TXCIF_APBIF_TX1,
  341. TEGRA30_AHUB_TXCIF_APBIF_TX2,
  342. TEGRA30_AHUB_TXCIF_APBIF_TX3,
  343. TEGRA30_AHUB_TXCIF_I2S0_TX0,
  344. TEGRA30_AHUB_TXCIF_I2S1_TX0,
  345. TEGRA30_AHUB_TXCIF_I2S2_TX0,
  346. TEGRA30_AHUB_TXCIF_I2S3_TX0,
  347. TEGRA30_AHUB_TXCIF_I2S4_TX0,
  348. TEGRA30_AHUB_TXCIF_DAM0_TX0,
  349. TEGRA30_AHUB_TXCIF_DAM1_TX0,
  350. TEGRA30_AHUB_TXCIF_DAM2_TX0,
  351. TEGRA30_AHUB_TXCIF_SPDIF_TX0,
  352. TEGRA30_AHUB_TXCIF_SPDIF_TX1,
  353. };
  354. enum tegra30_ahub_rxcif {
  355. TEGRA30_AHUB_RXCIF_APBIF_RX0,
  356. TEGRA30_AHUB_RXCIF_APBIF_RX1,
  357. TEGRA30_AHUB_RXcIF_APBIF_RX2,
  358. TEGRA30_AHUB_RXCIF_APBIF_RX3,
  359. TEGRA30_AHUB_RXCIF_I2S0_RX0,
  360. TEGRA30_AHUB_RXCIF_I2S1_RX0,
  361. TEGRA30_AHUB_RXCIF_I2S2_RX0,
  362. TEGRA30_AHUB_RXCIF_I2S3_RX0,
  363. TEGRA30_AHUB_RXCIF_I2S4_RX0,
  364. TEGRA30_AHUB_RXCIF_DAM0_RX0,
  365. TEGRA30_AHUB_RXCIF_DAM0_RX1,
  366. TEGRA30_AHUB_RXCIF_DAM1_RX0,
  367. TEGRA30_AHUB_RXCIF_DAM2_RX1,
  368. TEGRA30_AHUB_RXCIF_DAM3_RX0,
  369. TEGRA30_AHUB_RXCIF_DAM3_RX1,
  370. TEGRA30_AHUB_RXCIF_SPDIF_RX0,
  371. TEGRA30_AHUB_RXCIF_SPDIF_RX1,
  372. };
  373. extern int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
  374. char *dmachan, int dmachan_len,
  375. dma_addr_t *fiforeg);
  376. extern int tegra30_ahub_enable_rx_fifo(enum tegra30_ahub_rxcif rxcif);
  377. extern int tegra30_ahub_disable_rx_fifo(enum tegra30_ahub_rxcif rxcif);
  378. extern int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif);
  379. extern int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
  380. char *dmachan, int dmachan_len,
  381. dma_addr_t *fiforeg);
  382. extern int tegra30_ahub_enable_tx_fifo(enum tegra30_ahub_txcif txcif);
  383. extern int tegra30_ahub_disable_tx_fifo(enum tegra30_ahub_txcif txcif);
  384. extern int tegra30_ahub_free_tx_fifo(enum tegra30_ahub_txcif txcif);
  385. extern int tegra30_ahub_set_rx_cif_source(enum tegra30_ahub_rxcif rxcif,
  386. enum tegra30_ahub_txcif txcif);
  387. extern int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif);
  388. struct tegra30_ahub_cif_conf {
  389. unsigned int threshold;
  390. unsigned int audio_channels;
  391. unsigned int client_channels;
  392. unsigned int audio_bits;
  393. unsigned int client_bits;
  394. unsigned int expand;
  395. unsigned int stereo_conv;
  396. unsigned int replicate;
  397. unsigned int direction;
  398. unsigned int truncate;
  399. unsigned int mono_conv;
  400. };
  401. void tegra30_ahub_set_cif(struct regmap *regmap, unsigned int reg,
  402. struct tegra30_ahub_cif_conf *conf);
  403. void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg,
  404. struct tegra30_ahub_cif_conf *conf);
  405. struct tegra30_ahub_soc_data {
  406. u32 mod_list_mask;
  407. void (*set_audio_cif)(struct regmap *regmap,
  408. unsigned int reg,
  409. struct tegra30_ahub_cif_conf *conf);
  410. /*
  411. * FIXME: There are many more differences in HW, such as:
  412. * - More APBIF channels.
  413. * - Extra separate chunks of register address space to represent
  414. * the extra APBIF channels.
  415. * - More units connected to the AHUB, so that tegra30_ahub_[rt]xcif
  416. * need expansion, coupled with there being more defined bits in
  417. * the AHUB routing registers.
  418. * However, the driver doesn't support those new features yet, so we
  419. * don't represent them here yet.
  420. */
  421. };
  422. struct tegra30_ahub {
  423. const struct tegra30_ahub_soc_data *soc_data;
  424. struct device *dev;
  425. struct clk *clk_d_audio;
  426. struct clk *clk_apbif;
  427. resource_size_t apbif_addr;
  428. struct regmap *regmap_apbif;
  429. struct regmap *regmap_ahub;
  430. DECLARE_BITMAP(rx_usage, TEGRA30_AHUB_CHANNEL_CTRL_COUNT);
  431. DECLARE_BITMAP(tx_usage, TEGRA30_AHUB_CHANNEL_CTRL_COUNT);
  432. };
  433. #endif