cs35l33.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * cs35l33.h -- CS35L33 ALSA SoC audio driver
  3. *
  4. * Copyright 2016 Cirrus Logic, Inc.
  5. *
  6. * Author: Paul Handrigan <paul.handrigan@cirrus.com>
  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. */
  13. #ifndef __CS35L33_H__
  14. #define __CS35L33_H__
  15. #define CS35L33_CHIP_ID 0x00035A33
  16. #define CS35L33_DEVID_AB 0x01 /* Device ID A & B [RO] */
  17. #define CS35L33_DEVID_CD 0x02 /* Device ID C & D [RO] */
  18. #define CS35L33_DEVID_E 0x03 /* Device ID E [RO] */
  19. #define CS35L33_FAB_ID 0x04 /* Fab ID [RO] */
  20. #define CS35L33_REV_ID 0x05 /* Revision ID [RO] */
  21. #define CS35L33_PWRCTL1 0x06 /* Power Ctl 1 */
  22. #define CS35L33_PWRCTL2 0x07 /* Power Ctl 2 */
  23. #define CS35L33_CLK_CTL 0x08 /* Clock Ctl */
  24. #define CS35L33_BST_PEAK_CTL 0x09 /* Max Current for Boost */
  25. #define CS35L33_PROTECT_CTL 0x0A /* Amp Protection Parameters */
  26. #define CS35L33_BST_CTL1 0x0B /* Boost Converter CTL1 */
  27. #define CS35L33_BST_CTL2 0x0C /* Boost Converter CTL2 */
  28. #define CS35L33_ADSP_CTL 0x0D /* Serial Port Control */
  29. #define CS35L33_ADC_CTL 0x0E /* ADC Control */
  30. #define CS35L33_DAC_CTL 0x0F /* DAC Control */
  31. #define CS35L33_DIG_VOL_CTL 0x10 /* Digital Volume CTL */
  32. #define CS35L33_CLASSD_CTL 0x11 /* Class D Amp CTL */
  33. #define CS35L33_AMP_CTL 0x12 /* Amp Gain/Protecton Release CTL */
  34. #define CS35L33_INT_MASK_1 0x13 /* Interrupt Mask 1 */
  35. #define CS35L33_INT_MASK_2 0x14 /* Interrupt Mask 2 */
  36. #define CS35L33_INT_STATUS_1 0x15 /* Interrupt Status 1 [RO] */
  37. #define CS35L33_INT_STATUS_2 0x16 /* Interrupt Status 2 [RO] */
  38. #define CS35L33_DIAG_LOCK 0x17 /* Diagnostic Mode Register Lock */
  39. #define CS35L33_DIAG_CTRL_1 0x18 /* Diagnostic Mode Register Control */
  40. #define CS35L33_DIAG_CTRL_2 0x19 /* Diagnostic Mode Register Control 2 */
  41. #define CS35L33_HG_MEMLDO_CTL 0x23 /* H/G Memory/LDO CTL */
  42. #define CS35L33_HG_REL_RATE 0x24 /* H/G Release Rate */
  43. #define CS35L33_LDO_DEL 0x25 /* LDO Entry Delay/VPhg Control 1 */
  44. #define CS35L33_HG_HEAD 0x29 /* H/G Headroom */
  45. #define CS35L33_HG_EN 0x2A /* H/G Enable/VPhg CNT2 */
  46. #define CS35L33_TX_VMON 0x2D /* TDM TX Control 1 (VMON) */
  47. #define CS35L33_TX_IMON 0x2E /* TDM TX Control 2 (IMON) */
  48. #define CS35L33_TX_VPMON 0x2F /* TDM TX Control 3 (VPMON) */
  49. #define CS35L33_TX_VBSTMON 0x30 /* TDM TX Control 4 (VBSTMON) */
  50. #define CS35L33_TX_FLAG 0x31 /* TDM TX Control 5 (FLAG) */
  51. #define CS35L33_TX_EN1 0x32 /* TDM TX Enable 1 */
  52. #define CS35L33_TX_EN2 0x33 /* TDM TX Enable 2 */
  53. #define CS35L33_TX_EN3 0x34 /* TDM TX Enable 3 */
  54. #define CS35L33_TX_EN4 0x35 /* TDM TX Enable 4 */
  55. #define CS35L33_RX_AUD 0x36 /* TDM RX Control 1 */
  56. #define CS35L33_RX_SPLY 0x37 /* TDM RX Control 2 */
  57. #define CS35L33_RX_ALIVE 0x38 /* TDM RX Control 3 */
  58. #define CS35L33_BST_CTL4 0x39 /* Boost Converter Control 4 */
  59. #define CS35L33_HG_STATUS 0x3F /* H/G Status */
  60. #define CS35L33_MAX_REGISTER 0x59
  61. #define CS35L33_MCLK_5644 5644800
  62. #define CS35L33_MCLK_6144 6144000
  63. #define CS35L33_MCLK_6 6000000
  64. #define CS35L33_MCLK_11289 11289600
  65. #define CS35L33_MCLK_12 12000000
  66. #define CS35L33_MCLK_12288 12288000
  67. /* CS35L33_PWRCTL1 */
  68. #define CS35L33_PDN_AMP (1 << 7)
  69. #define CS35L33_PDN_BST (1 << 2)
  70. #define CS35L33_PDN_ALL 1
  71. /* CS35L33_PWRCTL2 */
  72. #define CS35L33_PDN_VMON_SHIFT 7
  73. #define CS35L33_PDN_VMON (1 << CS35L33_PDN_VMON_SHIFT)
  74. #define CS35L33_PDN_IMON_SHIFT 6
  75. #define CS35L33_PDN_IMON (1 << CS35L33_PDN_IMON_SHIFT)
  76. #define CS35L33_PDN_VPMON_SHIFT 5
  77. #define CS35L33_PDN_VPMON (1 << CS35L33_PDN_VPMON_SHIFT)
  78. #define CS35L33_PDN_VBSTMON_SHIFT 4
  79. #define CS35L33_PDN_VBSTMON (1 << CS35L33_PDN_VBSTMON_SHIFT)
  80. #define CS35L33_SDOUT_3ST_I2S_SHIFT 3
  81. #define CS35L33_SDOUT_3ST_I2S (1 << CS35L33_SDOUT_3ST_I2S_SHIFT)
  82. #define CS35L33_PDN_SDIN_SHIFT 2
  83. #define CS35L33_PDN_SDIN (1 << CS35L33_PDN_SDIN_SHIFT)
  84. #define CS35L33_PDN_TDM_SHIFT 1
  85. #define CS35L33_PDN_TDM (1 << CS35L33_PDN_TDM_SHIFT)
  86. /* CS35L33_CLK_CTL */
  87. #define CS35L33_MCLKDIS (1 << 7)
  88. #define CS35L33_MCLKDIV2 (1 << 6)
  89. #define CS35L33_SDOUT_3ST_TDM (1 << 5)
  90. #define CS35L33_INT_FS_RATE (1 << 4)
  91. #define CS35L33_ADSP_FS 0xF
  92. /* CS35L33_PROTECT_CTL */
  93. #define CS35L33_ALIVE_WD_DIS (3 << 2)
  94. /* CS35L33_BST_CTL1 */
  95. #define CS35L33_BST_CTL_SRC (1 << 6)
  96. #define CS35L33_BST_CTL_SHIFT (1 << 5)
  97. #define CS35L33_BST_CTL_MASK 0x3F
  98. /* CS35L33_BST_CTL2 */
  99. #define CS35L33_TDM_WD_SEL (1 << 4)
  100. #define CS35L33_ALIVE_WD_DIS2 (1 << 3)
  101. #define CS35L33_VBST_SR_STEP 0x3
  102. /* CS35L33_ADSP_CTL */
  103. #define CS35L33_ADSP_DRIVE (1 << 7)
  104. #define CS35L33_MS_MASK (1 << 6)
  105. #define CS35L33_SDIN_LOC (3 << 4)
  106. #define CS35L33_ALIVE_RATE 0x3
  107. /* CS35L33_ADC_CTL */
  108. #define CS35L33_INV_VMON (1 << 7)
  109. #define CS35L33_INV_IMON (1 << 6)
  110. #define CS35L33_ADC_NOTCH_DIS (1 << 5)
  111. #define CS35L33_IMON_SCALE 0xF
  112. /* CS35L33_DAC_CTL */
  113. #define CS35L33_INV_DAC (1 << 7)
  114. #define CS35L33_DAC_NOTCH_DIS (1 << 5)
  115. #define CS35L33_DIGSFT (1 << 4)
  116. #define CS35L33_DSR_RATE 0xF
  117. /* CS35L33_CLASSD_CTL */
  118. #define CS35L33_AMP_SD (1 << 6)
  119. #define CS35L33_AMP_DRV_SEL_SRC (1 << 5)
  120. #define CS35L33_AMP_DRV_SEL_MASK 0x10
  121. #define CS35L33_AMP_DRV_SEL_SHIFT 4
  122. #define CS35L33_AMP_CAL (1 << 3)
  123. #define CS35L33_GAIN_CHG_ZC_MASK 0x04
  124. #define CS35L33_GAIN_CHG_ZC_SHIFT 2
  125. #define CS35L33_CLASS_D_CTL_MASK 0x3F
  126. /* CS35L33_AMP_CTL */
  127. #define CS35L33_AMP_GAIN 0xF0
  128. #define CS35L33_CAL_ERR_RLS (1 << 3)
  129. #define CS35L33_AMP_SHORT_RLS (1 << 2)
  130. #define CS35L33_OTW_RLS (1 << 1)
  131. #define CS35L33_OTE_RLS 1
  132. /* CS35L33_INT_MASK_1 */
  133. #define CS35L33_M_CAL_ERR_SHIFT 6
  134. #define CS35L33_M_CAL_ERR (1 << CS35L33_M_CAL_ERR_SHIFT)
  135. #define CS35L33_M_ALIVE_ERR_SHIFT 5
  136. #define CS35L33_M_ALIVE_ERR (1 << CS35L33_M_ALIVE_ERR_SHIFT)
  137. #define CS35L33_M_AMP_SHORT_SHIFT 2
  138. #define CS35L33_M_AMP_SHORT (1 << CS35L33_M_AMP_SHORT_SHIFT)
  139. #define CS35L33_M_OTW_SHIFT 1
  140. #define CS35L33_M_OTW (1 << CS35L33_M_OTW_SHIFT)
  141. #define CS35L33_M_OTE_SHIFT 0
  142. #define CS35L33_M_OTE (1 << CS35L33_M_OTE_SHIFT)
  143. /* CS35L33_INT_STATUS_1 */
  144. #define CS35L33_CAL_ERR (1 << 6)
  145. #define CS35L33_ALIVE_ERR (1 << 5)
  146. #define CS35L33_ADSPCLK_ERR (1 << 4)
  147. #define CS35L33_MCLK_ERR (1 << 3)
  148. #define CS35L33_AMP_SHORT (1 << 2)
  149. #define CS35L33_OTW (1 << 1)
  150. #define CS35L33_OTE (1 << 0)
  151. /* CS35L33_INT_STATUS_2 */
  152. #define CS35L33_VMON_OVFL (1 << 7)
  153. #define CS35L33_IMON_OVFL (1 << 6)
  154. #define CS35L33_VPMON_OVFL (1 << 5)
  155. #define CS35L33_VBSTMON_OVFL (1 << 4)
  156. #define CS35L33_PDN_DONE 1
  157. /* CS35L33_BST_CTL4 */
  158. #define CS35L33_BST_RGS 0x70
  159. #define CS35L33_BST_COEFF3 0xF
  160. /* CS35L33_HG_MEMLDO_CTL */
  161. #define CS35L33_MEM_DEPTH_SHIFT 5
  162. #define CS35L33_MEM_DEPTH_MASK (0x3 << CS35L33_MEM_DEPTH_SHIFT)
  163. #define CS35L33_LDO_THLD_SHIFT 1
  164. #define CS35L33_LDO_THLD_MASK (0xF << CS35L33_LDO_THLD_SHIFT)
  165. #define CS35L33_LDO_DISABLE_SHIFT 0
  166. #define CS35L33_LDO_DISABLE_MASK (0x1 << CS35L33_LDO_DISABLE_SHIFT)
  167. /* CS35L33_LDO_DEL */
  168. #define CS35L33_VP_HG_VA_SHIFT 5
  169. #define CS35L33_VP_HG_VA_MASK (0x7 << CS35L33_VP_HG_VA_SHIFT)
  170. #define CS35L33_LDO_ENTRY_DELAY_SHIFT 2
  171. #define CS35L33_LDO_ENTRY_DELAY_MASK (0x7 << CS35L33_LDO_ENTRY_DELAY_SHIFT)
  172. #define CS35L33_VP_HG_RATE_SHIFT 0
  173. #define CS35L33_VP_HG_RATE_MASK (0x3 << CS35L33_VP_HG_RATE_SHIFT)
  174. /* CS35L33_HG_HEAD */
  175. #define CS35L33_HD_RM_SHIFT 0
  176. #define CS35L33_HD_RM_MASK (0x7F << CS35L33_HD_RM_SHIFT)
  177. /* CS35L33_HG_EN */
  178. #define CS35L33_CLASS_HG_ENA_SHIFT 7
  179. #define CS35L33_CLASS_HG_EN_MASK (0x1 << CS35L33_CLASS_HG_ENA_SHIFT)
  180. #define CS35L33_VP_HG_AUTO_SHIFT 6
  181. #define CS35L33_VP_HG_AUTO_MASK (0x1 << 6)
  182. #define CS35L33_VP_HG_SHIFT 0
  183. #define CS35L33_VP_HG_MASK (0x1F << CS35L33_VP_HG_SHIFT)
  184. #define CS35L33_RATES (SNDRV_PCM_RATE_8000_48000)
  185. #define CS35L33_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
  186. SNDRV_PCM_FMTBIT_S24_LE)
  187. /* CS35L33_{RX,TX}_X */
  188. #define CS35L33_X_STATE_SHIFT 7
  189. #define CS35L33_X_STATE (1 << CS35L33_X_STATE_SHIFT)
  190. #define CS35L33_X_LOC_SHIFT 0
  191. #define CS35L33_X_LOC (0x1F << CS35L33_X_LOC_SHIFT)
  192. /* CS35L33_RX_AUD */
  193. #define CS35L33_AUDIN_RX_DEPTH_SHIFT 5
  194. #define CS35L33_AUDIN_RX_DEPTH (0x7 << CS35L33_AUDIN_RX_DEPTH_SHIFT)
  195. #endif