tlv320dac33.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * ALSA SoC Texas Instruments TLV320DAC33 codec driver
  3. *
  4. * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
  5. *
  6. * Copyright: (C) 2009 Nokia Corporation
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #ifndef __TLV320DAC33_H
  24. #define __TLV320DAC33_H
  25. #define DAC33_PAGE_SELECT 0x00
  26. #define DAC33_PWR_CTRL 0x01
  27. #define DAC33_PLL_CTRL_A 0x02
  28. #define DAC33_PLL_CTRL_B 0x03
  29. #define DAC33_PLL_CTRL_C 0x04
  30. #define DAC33_PLL_CTRL_D 0x05
  31. #define DAC33_PLL_CTRL_E 0x06
  32. #define DAC33_INT_OSC_CTRL 0x07
  33. #define DAC33_INT_OSC_FREQ_RAT_A 0x08
  34. #define DAC33_INT_OSC_FREQ_RAT_B 0x09
  35. #define DAC33_INT_OSC_DAC_RATIO_SET 0x0A
  36. #define DAC33_CALIB_TIME 0x0B
  37. #define DAC33_INT_OSC_CTRL_B 0x0C
  38. #define DAC33_INT_OSC_CTRL_C 0x0D
  39. #define DAC33_INT_OSC_STATUS 0x0E
  40. #define DAC33_INT_OSC_DAC_RATIO_READ 0x0F
  41. #define DAC33_INT_OSC_FREQ_RAT_READ_A 0x10
  42. #define DAC33_INT_OSC_FREQ_RAT_READ_B 0x11
  43. #define DAC33_SER_AUDIOIF_CTRL_A 0x12
  44. #define DAC33_SER_AUDIOIF_CTRL_B 0x13
  45. #define DAC33_SER_AUDIOIF_CTRL_C 0x14
  46. #define DAC33_FIFO_CTRL_A 0x15
  47. #define DAC33_UTHR_MSB 0x16
  48. #define DAC33_UTHR_LSB 0x17
  49. #define DAC33_ATHR_MSB 0x18
  50. #define DAC33_ATHR_LSB 0x19
  51. #define DAC33_LTHR_MSB 0x1A
  52. #define DAC33_LTHR_LSB 0x1B
  53. #define DAC33_PREFILL_MSB 0x1C
  54. #define DAC33_PREFILL_LSB 0x1D
  55. #define DAC33_NSAMPLE_MSB 0x1E
  56. #define DAC33_NSAMPLE_LSB 0x1F
  57. #define DAC33_FIFO_WPTR_MSB 0x20
  58. #define DAC33_FIFO_WPTR_LSB 0x21
  59. #define DAC33_FIFO_RPTR_MSB 0x22
  60. #define DAC33_FIFO_RPTR_LSB 0x23
  61. #define DAC33_FIFO_DEPTH_MSB 0x24
  62. #define DAC33_FIFO_DEPTH_LSB 0x25
  63. #define DAC33_SAMPLES_REMAINING_MSB 0x26
  64. #define DAC33_SAMPLES_REMAINING_LSB 0x27
  65. #define DAC33_FIFO_IRQ_FLAG 0x28
  66. #define DAC33_FIFO_IRQ_MASK 0x29
  67. #define DAC33_FIFO_IRQ_MODE_A 0x2A
  68. #define DAC33_FIFO_IRQ_MODE_B 0x2B
  69. #define DAC33_DAC_CTRL_A 0x2C
  70. #define DAC33_DAC_CTRL_B 0x2D
  71. #define DAC33_DAC_CTRL_C 0x2E
  72. #define DAC33_LDAC_DIG_VOL_CTRL 0x2F
  73. #define DAC33_RDAC_DIG_VOL_CTRL 0x30
  74. #define DAC33_DAC_STATUS_FLAGS 0x31
  75. #define DAC33_ASRC_CTRL_A 0x32
  76. #define DAC33_ASRC_CTRL_B 0x33
  77. #define DAC33_SRC_REF_CLK_RATIO_A 0x34
  78. #define DAC33_SRC_REF_CLK_RATIO_B 0x35
  79. #define DAC33_SRC_EST_REF_CLK_RATIO_A 0x36
  80. #define DAC33_SRC_EST_REF_CLK_RATIO_B 0x37
  81. #define DAC33_INTP_CTRL_A 0x38
  82. #define DAC33_INTP_CTRL_B 0x39
  83. /* Registers 0x3A - 0x3F Reserved */
  84. #define DAC33_LDAC_PWR_CTRL 0x40
  85. #define DAC33_RDAC_PWR_CTRL 0x41
  86. #define DAC33_OUT_AMP_CM_CTRL 0x42
  87. #define DAC33_OUT_AMP_PWR_CTRL 0x43
  88. #define DAC33_OUT_AMP_CTRL 0x44
  89. #define DAC33_LINEL_TO_LLO_VOL 0x45
  90. /* Registers 0x45 - 0x47 Reserved */
  91. #define DAC33_LINER_TO_RLO_VOL 0x48
  92. #define DAC33_ANA_VOL_SOFT_STEP_CTRL 0x49
  93. #define DAC33_OSC_TRIM 0x4A
  94. /* Registers 0x4B - 0x7C Reserved */
  95. #define DAC33_DEVICE_ID_MSB 0x7D
  96. #define DAC33_DEVICE_ID_LSB 0x7E
  97. #define DAC33_DEVICE_REV_ID 0x7F
  98. #define DAC33_CACHEREGNUM 128
  99. /* Bit definitions */
  100. /* DAC33_PWR_CTRL (0x01) */
  101. #define DAC33_DACRPDNB (0x01 << 0)
  102. #define DAC33_DACLPDNB (0x01 << 1)
  103. #define DAC33_OSCPDNB (0x01 << 2)
  104. #define DAC33_PLLPDNB (0x01 << 3)
  105. #define DAC33_PDNALLB (0x01 << 4)
  106. #define DAC33_SOFT_RESET (0x01 << 7)
  107. /* DAC33_INT_OSC_CTRL (0x07) */
  108. #define DAC33_REFSEL (0x01 << 1)
  109. /* DAC33_INT_OSC_CTRL_B (0x0C) */
  110. #define DAC33_ADJSTEP(x) (x << 0)
  111. #define DAC33_ADJTHRSHLD(x) (x << 4)
  112. /* DAC33_INT_OSC_CTRL_C (0x0D) */
  113. #define DAC33_REFDIV(x) (x << 4)
  114. /* DAC33_INT_OSC_STATUS (0x0E) */
  115. #define DAC33_OSCSTATUS_IDLE_CALIB (0x00)
  116. #define DAC33_OSCSTATUS_NORMAL (0x01)
  117. #define DAC33_OSCSTATUS_ADJUSTMENT (0x03)
  118. #define DAC33_OSCSTATUS_NOT_USED (0x02)
  119. /* DAC33_SER_AUDIOIF_CTRL_A (0x12) */
  120. #define DAC33_MSWCLK (0x01 << 0)
  121. #define DAC33_MSBCLK (0x01 << 1)
  122. #define DAC33_AFMT_MASK (0x03 << 2)
  123. #define DAC33_AFMT_I2S (0x00 << 2)
  124. #define DAC33_AFMT_DSP (0x01 << 2)
  125. #define DAC33_AFMT_RIGHT_J (0x02 << 2)
  126. #define DAC33_AFMT_LEFT_J (0x03 << 2)
  127. #define DAC33_WLEN_MASK (0x03 << 4)
  128. #define DAC33_WLEN_16 (0x00 << 4)
  129. #define DAC33_WLEN_20 (0x01 << 4)
  130. #define DAC33_WLEN_24 (0x02 << 4)
  131. #define DAC33_WLEN_32 (0x03 << 4)
  132. #define DAC33_NCYCL_MASK (0x03 << 6)
  133. #define DAC33_NCYCL_16 (0x00 << 6)
  134. #define DAC33_NCYCL_20 (0x01 << 6)
  135. #define DAC33_NCYCL_24 (0x02 << 6)
  136. #define DAC33_NCYCL_32 (0x03 << 6)
  137. /* DAC33_SER_AUDIOIF_CTRL_B (0x13) */
  138. #define DAC33_DATA_DELAY_MASK (0x03 << 2)
  139. #define DAC33_DATA_DELAY(x) (x << 2)
  140. #define DAC33_BCLKON (0x01 << 5)
  141. /* DAC33_FIFO_CTRL_A (0x15) */
  142. #define DAC33_WIDTH (0x01 << 0)
  143. #define DAC33_FBYPAS (0x01 << 1)
  144. #define DAC33_FAUTO (0x01 << 2)
  145. #define DAC33_FIFOFLUSH (0x01 << 3)
  146. /*
  147. * UTHR, ATHR, LTHR, PREFILL, NSAMPLE (0x16 - 0x1F)
  148. * 13-bit values
  149. */
  150. #define DAC33_THRREG(x) (((x) & 0x1FFF) << 3)
  151. /* DAC33_FIFO_IRQ_MASK (0x29) */
  152. #define DAC33_MNS (0x01 << 0)
  153. #define DAC33_MPS (0x01 << 1)
  154. #define DAC33_MAT (0x01 << 2)
  155. #define DAC33_MLT (0x01 << 3)
  156. #define DAC33_MUT (0x01 << 4)
  157. #define DAC33_MUF (0x01 << 5)
  158. #define DAC33_MOF (0x01 << 6)
  159. #define DAC33_FIFO_IRQ_MODE_MASK (0x03)
  160. #define DAC33_FIFO_IRQ_MODE_RISING (0x00)
  161. #define DAC33_FIFO_IRQ_MODE_FALLING (0x01)
  162. #define DAC33_FIFO_IRQ_MODE_LEVEL (0x02)
  163. #define DAC33_FIFO_IRQ_MODE_EDGE (0x03)
  164. /* DAC33_FIFO_IRQ_MODE_A (0x2A) */
  165. #define DAC33_UTM(x) (x << 0)
  166. #define DAC33_UFM(x) (x << 2)
  167. #define DAC33_OFM(x) (x << 4)
  168. /* DAC33_FIFO_IRQ_MODE_B (0x2B) */
  169. #define DAC33_NSM(x) (x << 0)
  170. #define DAC33_PSM(x) (x << 2)
  171. #define DAC33_ATM(x) (x << 4)
  172. #define DAC33_LTM(x) (x << 6)
  173. /* DAC33_DAC_CTRL_A (0x2C) */
  174. #define DAC33_DACRATE(x) (x << 0)
  175. #define DAC33_DACDUAL (0x01 << 4)
  176. #define DAC33_DACLKSEL_MASK (0x03 << 5)
  177. #define DAC33_DACLKSEL_INTSOC (0x00 << 5)
  178. #define DAC33_DACLKSEL_PLL (0x01 << 5)
  179. #define DAC33_DACLKSEL_MCLK (0x02 << 5)
  180. #define DAC33_DACLKSEL_BCLK (0x03 << 5)
  181. /* DAC33_DAC_CTRL_B (0x2D) */
  182. #define DAC33_DACSRCR_MASK (0x03 << 0)
  183. #define DAC33_DACSRCR_MUTE (0x00 << 0)
  184. #define DAC33_DACSRCR_RIGHT (0x01 << 0)
  185. #define DAC33_DACSRCR_LEFT (0x02 << 0)
  186. #define DAC33_DACSRCR_MONOMIX (0x03 << 0)
  187. #define DAC33_DACSRCL_MASK (0x03 << 2)
  188. #define DAC33_DACSRCL_MUTE (0x00 << 2)
  189. #define DAC33_DACSRCL_LEFT (0x01 << 2)
  190. #define DAC33_DACSRCL_RIGHT (0x02 << 2)
  191. #define DAC33_DACSRCL_MONOMIX (0x03 << 2)
  192. #define DAC33_DVOLSTEP_MASK (0x03 << 4)
  193. #define DAC33_DVOLSTEP_SS_PERFS (0x00 << 4)
  194. #define DAC33_DVOLSTEP_SS_PER2FS (0x01 << 4)
  195. #define DAC33_DVOLSTEP_SS_DISABLED (0x02 << 4)
  196. #define DAC33_DVOLCTRL_MASK (0x03 << 6)
  197. #define DAC33_DVOLCTRL_LR_INDEPENDENT1 (0x00 << 6)
  198. #define DAC33_DVOLCTRL_LR_RIGHT_CONTROL (0x01 << 6)
  199. #define DAC33_DVOLCTRL_LR_LEFT_CONTROL (0x02 << 6)
  200. #define DAC33_DVOLCTRL_LR_INDEPENDENT2 (0x03 << 6)
  201. /* DAC33_DAC_CTRL_C (0x2E) */
  202. #define DAC33_DEEMENR (0x01 << 0)
  203. #define DAC33_EFFENR (0x01 << 1)
  204. #define DAC33_DEEMENL (0x01 << 2)
  205. #define DAC33_EFFENL (0x01 << 3)
  206. #define DAC33_EN3D (0x01 << 4)
  207. #define DAC33_RESYNMUTE (0x01 << 5)
  208. #define DAC33_RESYNEN (0x01 << 6)
  209. /* DAC33_ASRC_CTRL_A (0x32) */
  210. #define DAC33_SRCBYP (0x01 << 0)
  211. #define DAC33_SRCLKSEL_MASK (0x03 << 1)
  212. #define DAC33_SRCLKSEL_INTSOC (0x00 << 1)
  213. #define DAC33_SRCLKSEL_PLL (0x01 << 1)
  214. #define DAC33_SRCLKSEL_MCLK (0x02 << 1)
  215. #define DAC33_SRCLKSEL_BCLK (0x03 << 1)
  216. #define DAC33_SRCLKDIV(x) (x << 3)
  217. /* DAC33_ASRC_CTRL_B (0x33) */
  218. #define DAC33_SRCSETUP(x) (x << 0)
  219. #define DAC33_SRCREFSEL (0x01 << 4)
  220. #define DAC33_SRCREFDIV(x) (x << 5)
  221. /* DAC33_INTP_CTRL_A (0x38) */
  222. #define DAC33_INTPSEL (0x01 << 0)
  223. #define DAC33_INTPM_MASK (0x03 << 1)
  224. #define DAC33_INTPM_ALOW_OPENDRAIN (0x00 << 1)
  225. #define DAC33_INTPM_ALOW (0x01 << 1)
  226. #define DAC33_INTPM_AHIGH (0x02 << 1)
  227. /* DAC33_LDAC_PWR_CTRL (0x40) */
  228. /* DAC33_RDAC_PWR_CTRL (0x41) */
  229. #define DAC33_DACLRNUM (0x01 << 2)
  230. #define DAC33_LROUT_GAIN(x) (x << 0)
  231. /* DAC33_ANA_VOL_SOFT_STEP_CTRL (0x49) */
  232. #define DAC33_VOLCLKSEL (0x01 << 0)
  233. #define DAC33_VOLCLKEN (0x01 << 1)
  234. #define DAC33_VOLBYPASS (0x01 << 2)
  235. #define TLV320DAC33_MCLK 0
  236. #define TLV320DAC33_SLEEPCLK 1
  237. #endif /* __TLV320DAC33_H */