tegra20_i2s.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * tegra20_i2s.h - Definitions for Tegra20 I2S driver
  3. *
  4. * Author: Stephen Warren <swarren@nvidia.com>
  5. * Copyright (C) 2010,2012 - NVIDIA, Inc.
  6. *
  7. * Based on code copyright/by:
  8. *
  9. * Copyright (c) 2009-2010, NVIDIA Corporation.
  10. * Scott Peterson <speterson@nvidia.com>
  11. *
  12. * Copyright (C) 2010 Google, Inc.
  13. * Iliyan Malchev <malchev@google.com>
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * version 2 as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful, but
  20. * WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  27. * 02110-1301 USA
  28. *
  29. */
  30. #ifndef __TEGRA20_I2S_H__
  31. #define __TEGRA20_I2S_H__
  32. #include "tegra_pcm.h"
  33. /* Register offsets from TEGRA20_I2S1_BASE and TEGRA20_I2S2_BASE */
  34. #define TEGRA20_I2S_CTRL 0x00
  35. #define TEGRA20_I2S_STATUS 0x04
  36. #define TEGRA20_I2S_TIMING 0x08
  37. #define TEGRA20_I2S_FIFO_SCR 0x0c
  38. #define TEGRA20_I2S_PCM_CTRL 0x10
  39. #define TEGRA20_I2S_NW_CTRL 0x14
  40. #define TEGRA20_I2S_TDM_CTRL 0x20
  41. #define TEGRA20_I2S_TDM_TX_RX_CTRL 0x24
  42. #define TEGRA20_I2S_FIFO1 0x40
  43. #define TEGRA20_I2S_FIFO2 0x80
  44. /* Fields in TEGRA20_I2S_CTRL */
  45. #define TEGRA20_I2S_CTRL_FIFO2_TX_ENABLE (1 << 30)
  46. #define TEGRA20_I2S_CTRL_FIFO1_ENABLE (1 << 29)
  47. #define TEGRA20_I2S_CTRL_FIFO2_ENABLE (1 << 28)
  48. #define TEGRA20_I2S_CTRL_FIFO1_RX_ENABLE (1 << 27)
  49. #define TEGRA20_I2S_CTRL_FIFO_LPBK_ENABLE (1 << 26)
  50. #define TEGRA20_I2S_CTRL_MASTER_ENABLE (1 << 25)
  51. #define TEGRA20_I2S_LRCK_LEFT_LOW 0
  52. #define TEGRA20_I2S_LRCK_RIGHT_LOW 1
  53. #define TEGRA20_I2S_CTRL_LRCK_SHIFT 24
  54. #define TEGRA20_I2S_CTRL_LRCK_MASK (1 << TEGRA20_I2S_CTRL_LRCK_SHIFT)
  55. #define TEGRA20_I2S_CTRL_LRCK_L_LOW (TEGRA20_I2S_LRCK_LEFT_LOW << TEGRA20_I2S_CTRL_LRCK_SHIFT)
  56. #define TEGRA20_I2S_CTRL_LRCK_R_LOW (TEGRA20_I2S_LRCK_RIGHT_LOW << TEGRA20_I2S_CTRL_LRCK_SHIFT)
  57. #define TEGRA20_I2S_BIT_FORMAT_I2S 0
  58. #define TEGRA20_I2S_BIT_FORMAT_RJM 1
  59. #define TEGRA20_I2S_BIT_FORMAT_LJM 2
  60. #define TEGRA20_I2S_BIT_FORMAT_DSP 3
  61. #define TEGRA20_I2S_CTRL_BIT_FORMAT_SHIFT 10
  62. #define TEGRA20_I2S_CTRL_BIT_FORMAT_MASK (3 << TEGRA20_I2S_CTRL_BIT_FORMAT_SHIFT)
  63. #define TEGRA20_I2S_CTRL_BIT_FORMAT_I2S (TEGRA20_I2S_BIT_FORMAT_I2S << TEGRA20_I2S_CTRL_BIT_FORMAT_SHIFT)
  64. #define TEGRA20_I2S_CTRL_BIT_FORMAT_RJM (TEGRA20_I2S_BIT_FORMAT_RJM << TEGRA20_I2S_CTRL_BIT_FORMAT_SHIFT)
  65. #define TEGRA20_I2S_CTRL_BIT_FORMAT_LJM (TEGRA20_I2S_BIT_FORMAT_LJM << TEGRA20_I2S_CTRL_BIT_FORMAT_SHIFT)
  66. #define TEGRA20_I2S_CTRL_BIT_FORMAT_DSP (TEGRA20_I2S_BIT_FORMAT_DSP << TEGRA20_I2S_CTRL_BIT_FORMAT_SHIFT)
  67. #define TEGRA20_I2S_BIT_SIZE_16 0
  68. #define TEGRA20_I2S_BIT_SIZE_20 1
  69. #define TEGRA20_I2S_BIT_SIZE_24 2
  70. #define TEGRA20_I2S_BIT_SIZE_32 3
  71. #define TEGRA20_I2S_CTRL_BIT_SIZE_SHIFT 8
  72. #define TEGRA20_I2S_CTRL_BIT_SIZE_MASK (3 << TEGRA20_I2S_CTRL_BIT_SIZE_SHIFT)
  73. #define TEGRA20_I2S_CTRL_BIT_SIZE_16 (TEGRA20_I2S_BIT_SIZE_16 << TEGRA20_I2S_CTRL_BIT_SIZE_SHIFT)
  74. #define TEGRA20_I2S_CTRL_BIT_SIZE_20 (TEGRA20_I2S_BIT_SIZE_20 << TEGRA20_I2S_CTRL_BIT_SIZE_SHIFT)
  75. #define TEGRA20_I2S_CTRL_BIT_SIZE_24 (TEGRA20_I2S_BIT_SIZE_24 << TEGRA20_I2S_CTRL_BIT_SIZE_SHIFT)
  76. #define TEGRA20_I2S_CTRL_BIT_SIZE_32 (TEGRA20_I2S_BIT_SIZE_32 << TEGRA20_I2S_CTRL_BIT_SIZE_SHIFT)
  77. #define TEGRA20_I2S_FIFO_16_LSB 0
  78. #define TEGRA20_I2S_FIFO_20_LSB 1
  79. #define TEGRA20_I2S_FIFO_24_LSB 2
  80. #define TEGRA20_I2S_FIFO_32 3
  81. #define TEGRA20_I2S_FIFO_PACKED 7
  82. #define TEGRA20_I2S_CTRL_FIFO_FORMAT_SHIFT 4
  83. #define TEGRA20_I2S_CTRL_FIFO_FORMAT_MASK (7 << TEGRA20_I2S_CTRL_FIFO_FORMAT_SHIFT)
  84. #define TEGRA20_I2S_CTRL_FIFO_FORMAT_16_LSB (TEGRA20_I2S_FIFO_16_LSB << TEGRA20_I2S_CTRL_FIFO_FORMAT_SHIFT)
  85. #define TEGRA20_I2S_CTRL_FIFO_FORMAT_20_LSB (TEGRA20_I2S_FIFO_20_LSB << TEGRA20_I2S_CTRL_FIFO_FORMAT_SHIFT)
  86. #define TEGRA20_I2S_CTRL_FIFO_FORMAT_24_LSB (TEGRA20_I2S_FIFO_24_LSB << TEGRA20_I2S_CTRL_FIFO_FORMAT_SHIFT)
  87. #define TEGRA20_I2S_CTRL_FIFO_FORMAT_32 (TEGRA20_I2S_FIFO_32 << TEGRA20_I2S_CTRL_FIFO_FORMAT_SHIFT)
  88. #define TEGRA20_I2S_CTRL_FIFO_FORMAT_PACKED (TEGRA20_I2S_FIFO_PACKED << TEGRA20_I2S_CTRL_FIFO_FORMAT_SHIFT)
  89. #define TEGRA20_I2S_CTRL_IE_FIFO1_ERR (1 << 3)
  90. #define TEGRA20_I2S_CTRL_IE_FIFO2_ERR (1 << 2)
  91. #define TEGRA20_I2S_CTRL_QE_FIFO1 (1 << 1)
  92. #define TEGRA20_I2S_CTRL_QE_FIFO2 (1 << 0)
  93. /* Fields in TEGRA20_I2S_STATUS */
  94. #define TEGRA20_I2S_STATUS_FIFO1_RDY (1 << 31)
  95. #define TEGRA20_I2S_STATUS_FIFO2_RDY (1 << 30)
  96. #define TEGRA20_I2S_STATUS_FIFO1_BSY (1 << 29)
  97. #define TEGRA20_I2S_STATUS_FIFO2_BSY (1 << 28)
  98. #define TEGRA20_I2S_STATUS_FIFO1_ERR (1 << 3)
  99. #define TEGRA20_I2S_STATUS_FIFO2_ERR (1 << 2)
  100. #define TEGRA20_I2S_STATUS_QS_FIFO1 (1 << 1)
  101. #define TEGRA20_I2S_STATUS_QS_FIFO2 (1 << 0)
  102. /* Fields in TEGRA20_I2S_TIMING */
  103. #define TEGRA20_I2S_TIMING_NON_SYM_ENABLE (1 << 12)
  104. #define TEGRA20_I2S_TIMING_CHANNEL_BIT_COUNT_SHIFT 0
  105. #define TEGRA20_I2S_TIMING_CHANNEL_BIT_COUNT_MASK_US 0x7ff
  106. #define TEGRA20_I2S_TIMING_CHANNEL_BIT_COUNT_MASK (TEGRA20_I2S_TIMING_CHANNEL_BIT_COUNT_MASK_US << TEGRA20_I2S_TIMING_CHANNEL_BIT_COUNT_SHIFT)
  107. /* Fields in TEGRA20_I2S_FIFO_SCR */
  108. #define TEGRA20_I2S_FIFO_SCR_FIFO2_FULL_EMPTY_COUNT_SHIFT 24
  109. #define TEGRA20_I2S_FIFO_SCR_FIFO1_FULL_EMPTY_COUNT_SHIFT 16
  110. #define TEGRA20_I2S_FIFO_SCR_FIFO_FULL_EMPTY_COUNT_MASK 0x3f
  111. #define TEGRA20_I2S_FIFO_SCR_FIFO2_CLR (1 << 12)
  112. #define TEGRA20_I2S_FIFO_SCR_FIFO1_CLR (1 << 8)
  113. #define TEGRA20_I2S_FIFO_ATN_LVL_ONE_SLOT 0
  114. #define TEGRA20_I2S_FIFO_ATN_LVL_FOUR_SLOTS 1
  115. #define TEGRA20_I2S_FIFO_ATN_LVL_EIGHT_SLOTS 2
  116. #define TEGRA20_I2S_FIFO_ATN_LVL_TWELVE_SLOTS 3
  117. #define TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_SHIFT 4
  118. #define TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_MASK (3 << TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_SHIFT)
  119. #define TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_ONE_SLOT (TEGRA20_I2S_FIFO_ATN_LVL_ONE_SLOT << TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_SHIFT)
  120. #define TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_FOUR_SLOTS (TEGRA20_I2S_FIFO_ATN_LVL_FOUR_SLOTS << TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_SHIFT)
  121. #define TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_EIGHT_SLOTS (TEGRA20_I2S_FIFO_ATN_LVL_EIGHT_SLOTS << TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_SHIFT)
  122. #define TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_TWELVE_SLOTS (TEGRA20_I2S_FIFO_ATN_LVL_TWELVE_SLOTS << TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_SHIFT)
  123. #define TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_SHIFT 0
  124. #define TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_MASK (3 << TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_SHIFT)
  125. #define TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_ONE_SLOT (TEGRA20_I2S_FIFO_ATN_LVL_ONE_SLOT << TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_SHIFT)
  126. #define TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_FOUR_SLOTS (TEGRA20_I2S_FIFO_ATN_LVL_FOUR_SLOTS << TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_SHIFT)
  127. #define TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_EIGHT_SLOTS (TEGRA20_I2S_FIFO_ATN_LVL_EIGHT_SLOTS << TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_SHIFT)
  128. #define TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_TWELVE_SLOTS (TEGRA20_I2S_FIFO_ATN_LVL_TWELVE_SLOTS << TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_SHIFT)
  129. struct tegra20_i2s {
  130. struct snd_soc_dai_driver dai;
  131. struct clk *clk_i2s;
  132. struct snd_dmaengine_dai_dma_data capture_dma_data;
  133. struct snd_dmaengine_dai_dma_data playback_dma_data;
  134. struct regmap *regmap;
  135. };
  136. #endif