cs53l30.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /*
  2. * ALSA SoC CS53L30 codec driver
  3. *
  4. * Copyright 2015 Cirrus Logic, Inc.
  5. *
  6. * Author: Paul Handrigan <Paul.Handrigan@cirrus.com>,
  7. * Tim Howe <Tim.Howe@cirrus.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #ifndef __CS53L30_H__
  15. #define __CS53L30_H__
  16. /* I2C Registers */
  17. #define CS53L30_DEVID_AB 0x01 /* Device ID A & B [RO]. */
  18. #define CS53L30_DEVID_CD 0x02 /* Device ID C & D [RO]. */
  19. #define CS53L30_DEVID_E 0x03 /* Device ID E [RO]. */
  20. #define CS53L30_REVID 0x05 /* Revision ID [RO]. */
  21. #define CS53L30_PWRCTL 0x06 /* Power Control. */
  22. #define CS53L30_MCLKCTL 0x07 /* MCLK Control. */
  23. #define CS53L30_INT_SR_CTL 0x08 /* Internal Sample Rate Control. */
  24. #define CS53L30_MICBIAS_CTL 0x0A /* Mic Bias Control. */
  25. #define CS53L30_ASPCFG_CTL 0x0C /* ASP Config Control. */
  26. #define CS53L30_ASP_CTL1 0x0D /* ASP1 Control. */
  27. #define CS53L30_ASP_TDMTX_CTL1 0x0E /* ASP1 TDM TX Control 1 */
  28. #define CS53L30_ASP_TDMTX_CTL2 0x0F /* ASP1 TDM TX Control 2 */
  29. #define CS53L30_ASP_TDMTX_CTL3 0x10 /* ASP1 TDM TX Control 3 */
  30. #define CS53L30_ASP_TDMTX_CTL4 0x11 /* ASP1 TDM TX Control 4 */
  31. #define CS53L30_ASP_TDMTX_EN1 0x12 /* ASP1 TDM TX Enable 1 */
  32. #define CS53L30_ASP_TDMTX_EN2 0x13 /* ASP1 TDM TX Enable 2 */
  33. #define CS53L30_ASP_TDMTX_EN3 0x14 /* ASP1 TDM TX Enable 3 */
  34. #define CS53L30_ASP_TDMTX_EN4 0x15 /* ASP1 TDM TX Enable 4 */
  35. #define CS53L30_ASP_TDMTX_EN5 0x16 /* ASP1 TDM TX Enable 5 */
  36. #define CS53L30_ASP_TDMTX_EN6 0x17 /* ASP1 TDM TX Enable 6 */
  37. #define CS53L30_ASP_CTL2 0x18 /* ASP2 Control. */
  38. #define CS53L30_SFT_RAMP 0x1A /* Soft Ramp Control. */
  39. #define CS53L30_LRCK_CTL1 0x1B /* LRCK Control 1. */
  40. #define CS53L30_LRCK_CTL2 0x1C /* LRCK Control 2. */
  41. #define CS53L30_MUTEP_CTL1 0x1F /* Mute Pin Control 1. */
  42. #define CS53L30_MUTEP_CTL2 0x20 /* Mute Pin Control 2. */
  43. #define CS53L30_INBIAS_CTL1 0x21 /* Input Bias Control 1. */
  44. #define CS53L30_INBIAS_CTL2 0x22 /* Input Bias Control 2. */
  45. #define CS53L30_DMIC1_STR_CTL 0x23 /* DMIC1 Stereo Control. */
  46. #define CS53L30_DMIC2_STR_CTL 0x24 /* DMIC2 Stereo Control. */
  47. #define CS53L30_ADCDMIC1_CTL1 0x25 /* ADC1/DMIC1 Control 1. */
  48. #define CS53L30_ADCDMIC1_CTL2 0x26 /* ADC1/DMIC1 Control 2. */
  49. #define CS53L30_ADC1_CTL3 0x27 /* ADC1 Control 3. */
  50. #define CS53L30_ADC1_NG_CTL 0x28 /* ADC1 Noise Gate Control. */
  51. #define CS53L30_ADC1A_AFE_CTL 0x29 /* ADC1A AFE Control. */
  52. #define CS53L30_ADC1B_AFE_CTL 0x2A /* ADC1B AFE Control. */
  53. #define CS53L30_ADC1A_DIG_VOL 0x2B /* ADC1A Digital Volume. */
  54. #define CS53L30_ADC1B_DIG_VOL 0x2C /* ADC1B Digital Volume. */
  55. #define CS53L30_ADCDMIC2_CTL1 0x2D /* ADC2/DMIC2 Control 1. */
  56. #define CS53L30_ADCDMIC2_CTL2 0x2E /* ADC2/DMIC2 Control 2. */
  57. #define CS53L30_ADC2_CTL3 0x2F /* ADC2 Control 3. */
  58. #define CS53L30_ADC2_NG_CTL 0x30 /* ADC2 Noise Gate Control. */
  59. #define CS53L30_ADC2A_AFE_CTL 0x31 /* ADC2A AFE Control. */
  60. #define CS53L30_ADC2B_AFE_CTL 0x32 /* ADC2B AFE Control. */
  61. #define CS53L30_ADC2A_DIG_VOL 0x33 /* ADC2A Digital Volume. */
  62. #define CS53L30_ADC2B_DIG_VOL 0x34 /* ADC2B Digital Volume. */
  63. #define CS53L30_INT_MASK 0x35 /* Interrupt Mask. */
  64. #define CS53L30_IS 0x36 /* Interrupt Status. */
  65. #define CS53L30_MAX_REGISTER 0x36
  66. #define CS53L30_TDM_SLOT_MAX 4
  67. #define CS53L30_ASP_TDMTX_CTL(x) (CS53L30_ASP_TDMTX_CTL1 + (x))
  68. /* x : index for registers; n : index for slot; 8 slots per register */
  69. #define CS53L30_ASP_TDMTX_ENx(x) (CS53L30_ASP_TDMTX_EN6 - (x))
  70. #define CS53L30_ASP_TDMTX_ENn(n) CS53L30_ASP_TDMTX_ENx((n) >> 3)
  71. #define CS53L30_ASP_TDMTX_ENx_MAX 6
  72. /* Device ID */
  73. #define CS53L30_DEVID 0x53A30
  74. /* PDN_DONE Poll Maximum
  75. * If soft ramp is set it will take much longer to power down
  76. * the system.
  77. */
  78. #define CS53L30_PDN_POLL_MAX 90
  79. /* Bitfield Definitions */
  80. /* R6 (0x06) CS53L30_PWRCTL - Power Control */
  81. #define CS53L30_PDN_ULP_SHIFT 7
  82. #define CS53L30_PDN_ULP_MASK (1 << CS53L30_PDN_ULP_SHIFT)
  83. #define CS53L30_PDN_ULP (1 << CS53L30_PDN_ULP_SHIFT)
  84. #define CS53L30_PDN_LP_SHIFT 6
  85. #define CS53L30_PDN_LP_MASK (1 << CS53L30_PDN_LP_SHIFT)
  86. #define CS53L30_PDN_LP (1 << CS53L30_PDN_LP_SHIFT)
  87. #define CS53L30_DISCHARGE_FILT_SHIFT 5
  88. #define CS53L30_DISCHARGE_FILT_MASK (1 << CS53L30_DISCHARGE_FILT_SHIFT)
  89. #define CS53L30_DISCHARGE_FILT (1 << CS53L30_DISCHARGE_FILT_SHIFT)
  90. #define CS53L30_THMS_PDN_SHIFT 4
  91. #define CS53L30_THMS_PDN_MASK (1 << CS53L30_THMS_PDN_SHIFT)
  92. #define CS53L30_THMS_PDN (1 << CS53L30_THMS_PDN_SHIFT)
  93. #define CS53L30_PWRCTL_DEFAULT (CS53L30_THMS_PDN)
  94. /* R7 (0x07) CS53L30_MCLKCTL - MCLK Control */
  95. #define CS53L30_MCLK_DIS_SHIFT 7
  96. #define CS53L30_MCLK_DIS_MASK (1 << CS53L30_MCLK_DIS_SHIFT)
  97. #define CS53L30_MCLK_DIS (1 << CS53L30_MCLK_DIS_SHIFT)
  98. #define CS53L30_MCLK_INT_SCALE_SHIFT 6
  99. #define CS53L30_MCLK_INT_SCALE_MASK (1 << CS53L30_MCLK_INT_SCALE_SHIFT)
  100. #define CS53L30_MCLK_INT_SCALE (1 << CS53L30_MCLK_INT_SCALE_SHIFT)
  101. #define CS53L30_DMIC_DRIVE_SHIFT 5
  102. #define CS53L30_DMIC_DRIVE_MASK (1 << CS53L30_DMIC_DRIVE_SHIFT)
  103. #define CS53L30_DMIC_DRIVE (1 << CS53L30_DMIC_DRIVE_SHIFT)
  104. #define CS53L30_MCLK_DIV_SHIFT 2
  105. #define CS53L30_MCLK_DIV_WIDTH 2
  106. #define CS53L30_MCLK_DIV_MASK (((1 << CS53L30_MCLK_DIV_WIDTH) - 1) << CS53L30_MCLK_DIV_SHIFT)
  107. #define CS53L30_MCLK_DIV_BY_1 (0x0 << CS53L30_MCLK_DIV_SHIFT)
  108. #define CS53L30_MCLK_DIV_BY_2 (0x1 << CS53L30_MCLK_DIV_SHIFT)
  109. #define CS53L30_MCLK_DIV_BY_3 (0x2 << CS53L30_MCLK_DIV_SHIFT)
  110. #define CS53L30_SYNC_EN_SHIFT 1
  111. #define CS53L30_SYNC_EN_MASK (1 << CS53L30_SYNC_EN_SHIFT)
  112. #define CS53L30_SYNC_EN (1 << CS53L30_SYNC_EN_SHIFT)
  113. #define CS53L30_MCLKCTL_DEFAULT (CS53L30_MCLK_DIV_BY_2)
  114. /* R8 (0x08) CS53L30_INT_SR_CTL - Internal Sample Rate Control */
  115. #define CS53L30_INTRNL_FS_RATIO_SHIFT 4
  116. #define CS53L30_INTRNL_FS_RATIO_MASK (1 << CS53L30_INTRNL_FS_RATIO_SHIFT)
  117. #define CS53L30_INTRNL_FS_RATIO (1 << CS53L30_INTRNL_FS_RATIO_SHIFT)
  118. #define CS53L30_MCLK_19MHZ_EN_SHIFT 0
  119. #define CS53L30_MCLK_19MHZ_EN_MASK (1 << CS53L30_MCLK_19MHZ_EN_SHIFT)
  120. #define CS53L30_MCLK_19MHZ_EN (1 << CS53L30_MCLK_19MHZ_EN_SHIFT)
  121. /* 0x6 << 1 is reserved bits */
  122. #define CS53L30_INT_SR_CTL_DEFAULT (CS53L30_INTRNL_FS_RATIO | 0x6 << 1)
  123. /* R10 (0x0A) CS53L30_MICBIAS_CTL - Mic Bias Control */
  124. #define CS53L30_MIC4_BIAS_PDN_SHIFT 7
  125. #define CS53L30_MIC4_BIAS_PDN_MASK (1 << CS53L30_MIC4_BIAS_PDN_SHIFT)
  126. #define CS53L30_MIC4_BIAS_PDN (1 << CS53L30_MIC4_BIAS_PDN_SHIFT)
  127. #define CS53L30_MIC3_BIAS_PDN_SHIFT 6
  128. #define CS53L30_MIC3_BIAS_PDN_MASK (1 << CS53L30_MIC3_BIAS_PDN_SHIFT)
  129. #define CS53L30_MIC3_BIAS_PDN (1 << CS53L30_MIC3_BIAS_PDN_SHIFT)
  130. #define CS53L30_MIC2_BIAS_PDN_SHIFT 5
  131. #define CS53L30_MIC2_BIAS_PDN_MASK (1 << CS53L30_MIC2_BIAS_PDN_SHIFT)
  132. #define CS53L30_MIC2_BIAS_PDN (1 << CS53L30_MIC2_BIAS_PDN_SHIFT)
  133. #define CS53L30_MIC1_BIAS_PDN_SHIFT 4
  134. #define CS53L30_MIC1_BIAS_PDN_MASK (1 << CS53L30_MIC1_BIAS_PDN_SHIFT)
  135. #define CS53L30_MIC1_BIAS_PDN (1 << CS53L30_MIC1_BIAS_PDN_SHIFT)
  136. #define CS53L30_MICx_BIAS_PDN (0xf << CS53L30_MIC1_BIAS_PDN_SHIFT)
  137. #define CS53L30_VP_MIN_SHIFT 2
  138. #define CS53L30_VP_MIN_MASK (1 << CS53L30_VP_MIN_SHIFT)
  139. #define CS53L30_VP_MIN (1 << CS53L30_VP_MIN_SHIFT)
  140. #define CS53L30_MIC_BIAS_CTRL_SHIFT 0
  141. #define CS53L30_MIC_BIAS_CTRL_WIDTH 2
  142. #define CS53L30_MIC_BIAS_CTRL_MASK (((1 << CS53L30_MIC_BIAS_CTRL_WIDTH) - 1) << CS53L30_MIC_BIAS_CTRL_SHIFT)
  143. #define CS53L30_MIC_BIAS_CTRL_HIZ (0 << CS53L30_MIC_BIAS_CTRL_SHIFT)
  144. #define CS53L30_MIC_BIAS_CTRL_1V8 (1 << CS53L30_MIC_BIAS_CTRL_SHIFT)
  145. #define CS53L30_MIC_BIAS_CTRL_2V75 (2 << CS53L30_MIC_BIAS_CTRL_SHIFT)
  146. #define CS53L30_MICBIAS_CTL_DEFAULT (CS53L30_MICx_BIAS_PDN | CS53L30_VP_MIN)
  147. /* R12 (0x0C) CS53L30_ASPCFG_CTL - ASP Configuration Control */
  148. #define CS53L30_ASP_MS_SHIFT 7
  149. #define CS53L30_ASP_MS_MASK (1 << CS53L30_ASP_MS_SHIFT)
  150. #define CS53L30_ASP_MS (1 << CS53L30_ASP_MS_SHIFT)
  151. #define CS53L30_ASP_SCLK_INV_SHIFT 4
  152. #define CS53L30_ASP_SCLK_INV_MASK (1 << CS53L30_ASP_SCLK_INV_SHIFT)
  153. #define CS53L30_ASP_SCLK_INV (1 << CS53L30_ASP_SCLK_INV_SHIFT)
  154. #define CS53L30_ASP_RATE_SHIFT 0
  155. #define CS53L30_ASP_RATE_WIDTH 4
  156. #define CS53L30_ASP_RATE_MASK (((1 << CS53L30_ASP_RATE_WIDTH) - 1) << CS53L30_ASP_RATE_SHIFT)
  157. #define CS53L30_ASP_RATE_48K (0xc << CS53L30_ASP_RATE_SHIFT)
  158. #define CS53L30_ASPCFG_CTL_DEFAULT (CS53L30_ASP_RATE_48K)
  159. /* R13/R24 (0x0D/0x18) CS53L30_ASP_CTL1 & CS53L30_ASP_CTL2 - ASP Control 1~2 */
  160. #define CS53L30_ASP_TDM_PDN_SHIFT 7
  161. #define CS53L30_ASP_TDM_PDN_MASK (1 << CS53L30_ASP_TDM_PDN_SHIFT)
  162. #define CS53L30_ASP_TDM_PDN (1 << CS53L30_ASP_TDM_PDN_SHIFT)
  163. #define CS53L30_ASP_SDOUTx_PDN_SHIFT 6
  164. #define CS53L30_ASP_SDOUTx_PDN_MASK (1 << CS53L30_ASP_SDOUTx_PDN_SHIFT)
  165. #define CS53L30_ASP_SDOUTx_PDN (1 << CS53L30_ASP_SDOUTx_PDN_SHIFT)
  166. #define CS53L30_ASP_3ST_SHIFT 5
  167. #define CS53L30_ASP_3ST_MASK (1 << CS53L30_ASP_3ST_SHIFT)
  168. #define CS53L30_ASP_3ST (1 << CS53L30_ASP_3ST_SHIFT)
  169. #define CS53L30_SHIFT_LEFT_SHIFT 4
  170. #define CS53L30_SHIFT_LEFT_MASK (1 << CS53L30_SHIFT_LEFT_SHIFT)
  171. #define CS53L30_SHIFT_LEFT (1 << CS53L30_SHIFT_LEFT_SHIFT)
  172. #define CS53L30_ASP_SDOUTx_DRIVE_SHIFT 0
  173. #define CS53L30_ASP_SDOUTx_DRIVE_MASK (1 << CS53L30_ASP_SDOUTx_DRIVE_SHIFT)
  174. #define CS53L30_ASP_SDOUTx_DRIVE (1 << CS53L30_ASP_SDOUTx_DRIVE_SHIFT)
  175. #define CS53L30_ASP_CTL1_DEFAULT (CS53L30_ASP_TDM_PDN)
  176. #define CS53L30_ASP_CTL2_DEFAULT (0)
  177. /* R14 (0x0E) ~ R17 (0x11) CS53L30_ASP_TDMTX_CTLx - ASP TDM TX Control 1~4 */
  178. #define CS53L30_ASP_CHx_TX_STATE_SHIFT 7
  179. #define CS53L30_ASP_CHx_TX_STATE_MASK (1 << CS53L30_ASP_CHx_TX_STATE_SHIFT)
  180. #define CS53L30_ASP_CHx_TX_STATE (1 << CS53L30_ASP_CHx_TX_STATE_SHIFT)
  181. #define CS53L30_ASP_CHx_TX_LOC_SHIFT 0
  182. #define CS53L30_ASP_CHx_TX_LOC_WIDTH 6
  183. #define CS53L30_ASP_CHx_TX_LOC_MASK (((1 << CS53L30_ASP_CHx_TX_LOC_WIDTH) - 1) << CS53L30_ASP_CHx_TX_LOC_SHIFT)
  184. #define CS53L30_ASP_CHx_TX_LOC_MAX (47 << CS53L30_ASP_CHx_TX_LOC_SHIFT)
  185. #define CS53L30_ASP_CHx_TX_LOC(x) ((x) << CS53L30_ASP_CHx_TX_LOC_SHIFT)
  186. #define CS53L30_ASP_TDMTX_CTLx_DEFAULT (CS53L30_ASP_CHx_TX_LOC_MAX)
  187. /* R18 (0x12) ~ R23 (0x17) CS53L30_ASP_TDMTX_ENx - ASP TDM TX Enable 1~6 */
  188. #define CS53L30_ASP_TDMTX_ENx_DEFAULT (0)
  189. /* R26 (0x1A) CS53L30_SFT_RAMP - Soft Ramp Control */
  190. #define CS53L30_DIGSFT_SHIFT 5
  191. #define CS53L30_DIGSFT_MASK (1 << CS53L30_DIGSFT_SHIFT)
  192. #define CS53L30_DIGSFT (1 << CS53L30_DIGSFT_SHIFT)
  193. #define CS53L30_SFT_RMP_DEFAULT (0)
  194. /* R28 (0x1C) CS53L30_LRCK_CTL2 - LRCK Control 2 */
  195. #define CS53L30_LRCK_50_NPW_SHIFT 3
  196. #define CS53L30_LRCK_50_NPW_MASK (1 << CS53L30_LRCK_50_NPW_SHIFT)
  197. #define CS53L30_LRCK_50_NPW (1 << CS53L30_LRCK_50_NPW_SHIFT)
  198. #define CS53L30_LRCK_TPWH_SHIFT 0
  199. #define CS53L30_LRCK_TPWH_WIDTH 3
  200. #define CS53L30_LRCK_TPWH_MASK (((1 << CS53L30_LRCK_TPWH_WIDTH) - 1) << CS53L30_LRCK_TPWH_SHIFT)
  201. #define CS53L30_LRCK_TPWH(x) (((x) << CS53L30_LRCK_TPWH_SHIFT) & CS53L30_LRCK_TPWH_MASK)
  202. #define CS53L30_LRCK_CTLx_DEFAULT (0)
  203. /* R31 (0x1F) CS53L30_MUTEP_CTL1 - MUTE Pin Control 1 */
  204. #define CS53L30_MUTE_PDN_ULP_SHIFT 7
  205. #define CS53L30_MUTE_PDN_ULP_MASK (1 << CS53L30_MUTE_PDN_ULP_SHIFT)
  206. #define CS53L30_MUTE_PDN_ULP (1 << CS53L30_MUTE_PDN_ULP_SHIFT)
  207. #define CS53L30_MUTE_PDN_LP_SHIFT 6
  208. #define CS53L30_MUTE_PDN_LP_MASK (1 << CS53L30_MUTE_PDN_LP_SHIFT)
  209. #define CS53L30_MUTE_PDN_LP (1 << CS53L30_MUTE_PDN_LP_SHIFT)
  210. #define CS53L30_MUTE_M4B_PDN_SHIFT 4
  211. #define CS53L30_MUTE_M4B_PDN_MASK (1 << CS53L30_MUTE_M4B_PDN_SHIFT)
  212. #define CS53L30_MUTE_M4B_PDN (1 << CS53L30_MUTE_M4B_PDN_SHIFT)
  213. #define CS53L30_MUTE_M3B_PDN_SHIFT 3
  214. #define CS53L30_MUTE_M3B_PDN_MASK (1 << CS53L30_MUTE_M3B_PDN_SHIFT)
  215. #define CS53L30_MUTE_M3B_PDN (1 << CS53L30_MUTE_M3B_PDN_SHIFT)
  216. #define CS53L30_MUTE_M2B_PDN_SHIFT 2
  217. #define CS53L30_MUTE_M2B_PDN_MASK (1 << CS53L30_MUTE_M2B_PDN_SHIFT)
  218. #define CS53L30_MUTE_M2B_PDN (1 << CS53L30_MUTE_M2B_PDN_SHIFT)
  219. #define CS53L30_MUTE_M1B_PDN_SHIFT 1
  220. #define CS53L30_MUTE_M1B_PDN_MASK (1 << CS53L30_MUTE_M1B_PDN_SHIFT)
  221. #define CS53L30_MUTE_M1B_PDN (1 << CS53L30_MUTE_M1B_PDN_SHIFT)
  222. /* Note: be careful - x starts from 0 */
  223. #define CS53L30_MUTE_MxB_PDN_SHIFT(x) (CS53L30_MUTE_M1B_PDN_SHIFT + (x))
  224. #define CS53L30_MUTE_MxB_PDN_MASK(x) (1 << CS53L30_MUTE_MxB_PDN_SHIFT(x))
  225. #define CS53L30_MUTE_MxB_PDN(x) (1 << CS53L30_MUTE_MxB_PDN_SHIFT(x))
  226. #define CS53L30_MUTE_MB_ALL_PDN_SHIFT 0
  227. #define CS53L30_MUTE_MB_ALL_PDN_MASK (1 << CS53L30_MUTE_MB_ALL_PDN_SHIFT)
  228. #define CS53L30_MUTE_MB_ALL_PDN (1 << CS53L30_MUTE_MB_ALL_PDN_SHIFT)
  229. #define CS53L30_MUTEP_CTL1_MUTEALL (0xdf)
  230. #define CS53L30_MUTEP_CTL1_DEFAULT (0)
  231. /* R32 (0x20) CS53L30_MUTEP_CTL2 - MUTE Pin Control 2 */
  232. #define CS53L30_MUTE_PIN_POLARITY_SHIFT 7
  233. #define CS53L30_MUTE_PIN_POLARITY_MASK (1 << CS53L30_MUTE_PIN_POLARITY_SHIFT)
  234. #define CS53L30_MUTE_PIN_POLARITY (1 << CS53L30_MUTE_PIN_POLARITY_SHIFT)
  235. #define CS53L30_MUTE_ASP_TDM_PDN_SHIFT 6
  236. #define CS53L30_MUTE_ASP_TDM_PDN_MASK (1 << CS53L30_MUTE_ASP_TDM_PDN_SHIFT)
  237. #define CS53L30_MUTE_ASP_TDM_PDN (1 << CS53L30_MUTE_ASP_TDM_PDN_SHIFT)
  238. #define CS53L30_MUTE_ASP_SDOUT2_PDN_SHIFT 5
  239. #define CS53L30_MUTE_ASP_SDOUT2_PDN_MASK (1 << CS53L30_MUTE_ASP_SDOUT2_PDN_SHIFT)
  240. #define CS53L30_MUTE_ASP_SDOUT2_PDN (1 << CS53L30_MUTE_ASP_SDOUT2_PDN_SHIFT)
  241. #define CS53L30_MUTE_ASP_SDOUT1_PDN_SHIFT 4
  242. #define CS53L30_MUTE_ASP_SDOUT1_PDN_MASK (1 << CS53L30_MUTE_ASP_SDOUT1_PDN_SHIFT)
  243. #define CS53L30_MUTE_ASP_SDOUT1_PDN (1 << CS53L30_MUTE_ASP_SDOUT1_PDN_SHIFT)
  244. /* Note: be careful - x starts from 0 */
  245. #define CS53L30_MUTE_ASP_SDOUTx_PDN_SHIFT(x) ((x) + CS53L30_MUTE_ASP_SDOUT1_PDN_SHIFT)
  246. #define CS53L30_MUTE_ASP_SDOUTx_PDN_MASK(x) (1 << CS53L30_MUTE_ASP_SDOUTx_PDN_SHIFT(x))
  247. #define CS53L30_MUTE_ASP_SDOUTx_PDN (1 << CS53L30_MUTE_ASP_SDOUTx_PDN_SHIFT(x))
  248. #define CS53L30_MUTE_ADC2B_PDN_SHIFT 3
  249. #define CS53L30_MUTE_ADC2B_PDN_MASK (1 << CS53L30_MUTE_ADC2B_PDN_SHIFT)
  250. #define CS53L30_MUTE_ADC2B_PDN (1 << CS53L30_MUTE_ADC2B_PDN_SHIFT)
  251. #define CS53L30_MUTE_ADC2A_PDN_SHIFT 2
  252. #define CS53L30_MUTE_ADC2A_PDN_MASK (1 << CS53L30_MUTE_ADC2A_PDN_SHIFT)
  253. #define CS53L30_MUTE_ADC2A_PDN (1 << CS53L30_MUTE_ADC2A_PDN_SHIFT)
  254. #define CS53L30_MUTE_ADC1B_PDN_SHIFT 1
  255. #define CS53L30_MUTE_ADC1B_PDN_MASK (1 << CS53L30_MUTE_ADC1B_PDN_SHIFT)
  256. #define CS53L30_MUTE_ADC1B_PDN (1 << CS53L30_MUTE_ADC1B_PDN_SHIFT)
  257. #define CS53L30_MUTE_ADC1A_PDN_SHIFT 0
  258. #define CS53L30_MUTE_ADC1A_PDN_MASK (1 << CS53L30_MUTE_ADC1A_PDN_SHIFT)
  259. #define CS53L30_MUTE_ADC1A_PDN (1 << CS53L30_MUTE_ADC1A_PDN_SHIFT)
  260. #define CS53L30_MUTEP_CTL2_DEFAULT (CS53L30_MUTE_PIN_POLARITY)
  261. /* R33 (0x21) CS53L30_INBIAS_CTL1 - Input Bias Control 1 */
  262. #define CS53L30_IN4M_BIAS_SHIFT 6
  263. #define CS53L30_IN4M_BIAS_WIDTH 2
  264. #define CS53L30_IN4M_BIAS_MASK (((1 << CS53L30_IN4M_BIAS_WIDTH) - 1) << CS53L30_IN4M_BIAS_SHIFT)
  265. #define CS53L30_IN4M_BIAS_OPEN (0 << CS53L30_IN4M_BIAS_SHIFT)
  266. #define CS53L30_IN4M_BIAS_PULL_DOWN (1 << CS53L30_IN4M_BIAS_SHIFT)
  267. #define CS53L30_IN4M_BIAS_VCM (2 << CS53L30_IN4M_BIAS_SHIFT)
  268. #define CS53L30_IN4P_BIAS_SHIFT 4
  269. #define CS53L30_IN4P_BIAS_WIDTH 2
  270. #define CS53L30_IN4P_BIAS_MASK (((1 << CS53L30_IN4P_BIAS_WIDTH) - 1) << CS53L30_IN4P_BIAS_SHIFT)
  271. #define CS53L30_IN4P_BIAS_OPEN (0 << CS53L30_IN4P_BIAS_SHIFT)
  272. #define CS53L30_IN4P_BIAS_PULL_DOWN (1 << CS53L30_IN4P_BIAS_SHIFT)
  273. #define CS53L30_IN4P_BIAS_VCM (2 << CS53L30_IN4P_BIAS_SHIFT)
  274. #define CS53L30_IN3M_BIAS_SHIFT 2
  275. #define CS53L30_IN3M_BIAS_WIDTH 2
  276. #define CS53L30_IN3M_BIAS_MASK (((1 << CS53L30_IN3M_BIAS_WIDTH) - 1) << CS53L30_IN4M_BIAS_SHIFT)
  277. #define CS53L30_IN3M_BIAS_OPEN (0 << CS53L30_IN3M_BIAS_SHIFT)
  278. #define CS53L30_IN3M_BIAS_PULL_DOWN (1 << CS53L30_IN3M_BIAS_SHIFT)
  279. #define CS53L30_IN3M_BIAS_VCM (2 << CS53L30_IN3M_BIAS_SHIFT)
  280. #define CS53L30_IN3P_BIAS_SHIFT 0
  281. #define CS53L30_IN3P_BIAS_WIDTH 2
  282. #define CS53L30_IN3P_BIAS_MASK (((1 << CS53L30_IN3P_BIAS_WIDTH) - 1) << CS53L30_IN3P_BIAS_SHIFT)
  283. #define CS53L30_IN3P_BIAS_OPEN (0 << CS53L30_IN3P_BIAS_SHIFT)
  284. #define CS53L30_IN3P_BIAS_PULL_DOWN (1 << CS53L30_IN3P_BIAS_SHIFT)
  285. #define CS53L30_IN3P_BIAS_VCM (2 << CS53L30_IN3P_BIAS_SHIFT)
  286. #define CS53L30_INBIAS_CTL1_DEFAULT (CS53L30_IN4M_BIAS_VCM | CS53L30_IN4P_BIAS_VCM |\
  287. CS53L30_IN3M_BIAS_VCM | CS53L30_IN3P_BIAS_VCM)
  288. /* R34 (0x22) CS53L30_INBIAS_CTL2 - Input Bias Control 2 */
  289. #define CS53L30_IN2M_BIAS_SHIFT 6
  290. #define CS53L30_IN2M_BIAS_WIDTH 2
  291. #define CS53L30_IN2M_BIAS_MASK (((1 << CS53L30_IN2M_BIAS_WIDTH) - 1) << CS53L30_IN2M_BIAS_SHIFT)
  292. #define CS53L30_IN2M_BIAS_OPEN (0 << CS53L30_IN2M_BIAS_SHIFT)
  293. #define CS53L30_IN2M_BIAS_PULL_DOWN (1 << CS53L30_IN2M_BIAS_SHIFT)
  294. #define CS53L30_IN2M_BIAS_VCM (2 << CS53L30_IN2M_BIAS_SHIFT)
  295. #define CS53L30_IN2P_BIAS_SHIFT 4
  296. #define CS53L30_IN2P_BIAS_WIDTH 2
  297. #define CS53L30_IN2P_BIAS_MASK (((1 << CS53L30_IN2P_BIAS_WIDTH) - 1) << CS53L30_IN2P_BIAS_SHIFT)
  298. #define CS53L30_IN2P_BIAS_OPEN (0 << CS53L30_IN2P_BIAS_SHIFT)
  299. #define CS53L30_IN2P_BIAS_PULL_DOWN (1 << CS53L30_IN2P_BIAS_SHIFT)
  300. #define CS53L30_IN2P_BIAS_VCM (2 << CS53L30_IN2P_BIAS_SHIFT)
  301. #define CS53L30_IN1M_BIAS_SHIFT 2
  302. #define CS53L30_IN1M_BIAS_WIDTH 2
  303. #define CS53L30_IN1M_BIAS_MASK (((1 << CS53L30_IN1M_BIAS_WIDTH) - 1) << CS53L30_IN1M_BIAS_SHIFT)
  304. #define CS53L30_IN1M_BIAS_OPEN (0 << CS53L30_IN1M_BIAS_SHIFT)
  305. #define CS53L30_IN1M_BIAS_PULL_DOWN (1 << CS53L30_IN1M_BIAS_SHIFT)
  306. #define CS53L30_IN1M_BIAS_VCM (2 << CS53L30_IN1M_BIAS_SHIFT)
  307. #define CS53L30_IN1P_BIAS_SHIFT 0
  308. #define CS53L30_IN1P_BIAS_WIDTH 2
  309. #define CS53L30_IN1P_BIAS_MASK (((1 << CS53L30_IN1P_BIAS_WIDTH) - 1) << CS53L30_IN1P_BIAS_SHIFT)
  310. #define CS53L30_IN1P_BIAS_OPEN (0 << CS53L30_IN1P_BIAS_SHIFT)
  311. #define CS53L30_IN1P_BIAS_PULL_DOWN (1 << CS53L30_IN1P_BIAS_SHIFT)
  312. #define CS53L30_IN1P_BIAS_VCM (2 << CS53L30_IN1P_BIAS_SHIFT)
  313. #define CS53L30_INBIAS_CTL2_DEFAULT (CS53L30_IN2M_BIAS_VCM | CS53L30_IN2P_BIAS_VCM |\
  314. CS53L30_IN1M_BIAS_VCM | CS53L30_IN1P_BIAS_VCM)
  315. /* R35 (0x23) & R36 (0x24) CS53L30_DMICx_STR_CTL - DMIC1 & DMIC2 Stereo Control */
  316. #define CS53L30_DMICx_STEREO_ENB_SHIFT 5
  317. #define CS53L30_DMICx_STEREO_ENB_MASK (1 << CS53L30_DMICx_STEREO_ENB_SHIFT)
  318. #define CS53L30_DMICx_STEREO_ENB (1 << CS53L30_DMICx_STEREO_ENB_SHIFT)
  319. /* 0x88 and 0xCC are reserved bits */
  320. #define CS53L30_DMIC1_STR_CTL_DEFAULT (CS53L30_DMICx_STEREO_ENB | 0x88)
  321. #define CS53L30_DMIC2_STR_CTL_DEFAULT (CS53L30_DMICx_STEREO_ENB | 0xCC)
  322. /* R37/R45 (0x25/0x2D) CS53L30_ADCDMICx_CTL1 - ADC1/DMIC1 & ADC2/DMIC2 Control 1 */
  323. #define CS53L30_ADCxB_PDN_SHIFT 7
  324. #define CS53L30_ADCxB_PDN_MASK (1 << CS53L30_ADCxB_PDN_SHIFT)
  325. #define CS53L30_ADCxB_PDN (1 << CS53L30_ADCxB_PDN_SHIFT)
  326. #define CS53L30_ADCxA_PDN_SHIFT 6
  327. #define CS53L30_ADCxA_PDN_MASK (1 << CS53L30_ADCxA_PDN_SHIFT)
  328. #define CS53L30_ADCxA_PDN (1 << CS53L30_ADCxA_PDN_SHIFT)
  329. #define CS53L30_DMICx_PDN_SHIFT 2
  330. #define CS53L30_DMICx_PDN_MASK (1 << CS53L30_DMICx_PDN_SHIFT)
  331. #define CS53L30_DMICx_PDN (1 << CS53L30_DMICx_PDN_SHIFT)
  332. #define CS53L30_DMICx_SCLK_DIV_SHIFT 1
  333. #define CS53L30_DMICx_SCLK_DIV_MASK (1 << CS53L30_DMICx_SCLK_DIV_SHIFT)
  334. #define CS53L30_DMICx_SCLK_DIV (1 << CS53L30_DMICx_SCLK_DIV_SHIFT)
  335. #define CS53L30_CH_TYPE_SHIFT 0
  336. #define CS53L30_CH_TYPE_MASK (1 << CS53L30_CH_TYPE_SHIFT)
  337. #define CS53L30_CH_TYPE (1 << CS53L30_CH_TYPE_SHIFT)
  338. #define CS53L30_ADCDMICx_PDN_MASK 0xFF
  339. #define CS53L30_ADCDMICx_CTL1_DEFAULT (CS53L30_DMICx_PDN)
  340. /* R38/R46 (0x26/0x2E) CS53L30_ADCDMICx_CTL2 - ADC1/DMIC1 & ADC2/DMIC2 Control 2 */
  341. #define CS53L30_ADCx_NOTCH_DIS_SHIFT 7
  342. #define CS53L30_ADCx_NOTCH_DIS_MASK (1 << CS53L30_ADCx_NOTCH_DIS_SHIFT)
  343. #define CS53L30_ADCx_NOTCH_DIS (1 << CS53L30_ADCx_NOTCH_DIS_SHIFT)
  344. #define CS53L30_ADCxB_INV_SHIFT 5
  345. #define CS53L30_ADCxB_INV_MASK (1 << CS53L30_ADCxB_INV_SHIFT)
  346. #define CS53L30_ADCxB_INV (1 << CS53L30_ADCxB_INV_SHIFT)
  347. #define CS53L30_ADCxA_INV_SHIFT 4
  348. #define CS53L30_ADCxA_INV_MASK (1 << CS53L30_ADCxA_INV_SHIFT)
  349. #define CS53L30_ADCxA_INV (1 << CS53L30_ADCxA_INV_SHIFT)
  350. #define CS53L30_ADCxB_DIG_BOOST_SHIFT 1
  351. #define CS53L30_ADCxB_DIG_BOOST_MASK (1 << CS53L30_ADCxB_DIG_BOOST_SHIFT)
  352. #define CS53L30_ADCxB_DIG_BOOST (1 << CS53L30_ADCxB_DIG_BOOST_SHIFT)
  353. #define CS53L30_ADCxA_DIG_BOOST_SHIFT 0
  354. #define CS53L30_ADCxA_DIG_BOOST_MASK (1 << CS53L30_ADCxA_DIG_BOOST_SHIFT)
  355. #define CS53L30_ADCxA_DIG_BOOST (1 << CS53L30_ADCxA_DIG_BOOST_SHIFT)
  356. #define CS53L30_ADCDMIC1_CTL2_DEFAULT (0)
  357. /* R39/R47 (0x27/0x2F) CS53L30_ADCx_CTL3 - ADC1/ADC2 Control 3 */
  358. #define CS53L30_ADCx_HPF_EN_SHIFT 3
  359. #define CS53L30_ADCx_HPF_EN_MASK (1 << CS53L30_ADCx_HPF_EN_SHIFT)
  360. #define CS53L30_ADCx_HPF_EN (1 << CS53L30_ADCx_HPF_EN_SHIFT)
  361. #define CS53L30_ADCx_HPF_CF_SHIFT 1
  362. #define CS53L30_ADCx_HPF_CF_WIDTH 2
  363. #define CS53L30_ADCx_HPF_CF_MASK (((1 << CS53L30_ADCx_HPF_CF_WIDTH) - 1) << CS53L30_ADCx_HPF_CF_SHIFT)
  364. #define CS53L30_ADCx_HPF_CF_1HZ86 (0 << CS53L30_ADCx_HPF_CF_SHIFT)
  365. #define CS53L30_ADCx_HPF_CF_120HZ (1 << CS53L30_ADCx_HPF_CF_SHIFT)
  366. #define CS53L30_ADCx_HPF_CF_235HZ (2 << CS53L30_ADCx_HPF_CF_SHIFT)
  367. #define CS53L30_ADCx_HPF_CF_466HZ (3 << CS53L30_ADCx_HPF_CF_SHIFT)
  368. #define CS53L30_ADCx_NG_ALL_SHIFT 0
  369. #define CS53L30_ADCx_NG_ALL_MASK (1 << CS53L30_ADCx_NG_ALL_SHIFT)
  370. #define CS53L30_ADCx_NG_ALL (1 << CS53L30_ADCx_NG_ALL_SHIFT)
  371. #define CS53L30_ADCx_CTL3_DEFAULT (CS53L30_ADCx_HPF_EN)
  372. /* R40/R48 (0x28/0x30) CS53L30_ADCx_NG_CTL - ADC1/ADC2 Noise Gate Control */
  373. #define CS53L30_ADCxB_NG_SHIFT 7
  374. #define CS53L30_ADCxB_NG_MASK (1 << CS53L30_ADCxB_NG_SHIFT)
  375. #define CS53L30_ADCxB_NG (1 << CS53L30_ADCxB_NG_SHIFT)
  376. #define CS53L30_ADCxA_NG_SHIFT 6
  377. #define CS53L30_ADCxA_NG_MASK (1 << CS53L30_ADCxA_NG_SHIFT)
  378. #define CS53L30_ADCxA_NG (1 << CS53L30_ADCxA_NG_SHIFT)
  379. #define CS53L30_ADCx_NG_BOOST_SHIFT 5
  380. #define CS53L30_ADCx_NG_BOOST_MASK (1 << CS53L30_ADCx_NG_BOOST_SHIFT)
  381. #define CS53L30_ADCx_NG_BOOST (1 << CS53L30_ADCx_NG_BOOST_SHIFT)
  382. #define CS53L30_ADCx_NG_THRESH_SHIFT 2
  383. #define CS53L30_ADCx_NG_THRESH_WIDTH 3
  384. #define CS53L30_ADCx_NG_THRESH_MASK (((1 << CS53L30_ADCx_NG_THRESH_WIDTH) - 1) << CS53L30_ADCx_NG_THRESH_SHIFT)
  385. #define CS53L30_ADCx_NG_DELAY_SHIFT 0
  386. #define CS53L30_ADCx_NG_DELAY_WIDTH 2
  387. #define CS53L30_ADCx_NG_DELAY_MASK (((1 << CS53L30_ADCx_NG_DELAY_WIDTH) - 1) << CS53L30_ADCx_NG_DELAY_SHIFT)
  388. #define CS53L30_ADCx_NG_CTL_DEFAULT (0)
  389. /* R41/R42/R49/R50 (0x29/0x2A/0x31/0x32) CS53L30_ADCxy_AFE_CTL - ADC1A/1B/2A/2B AFE Control */
  390. #define CS53L30_ADCxy_PREAMP_SHIFT 6
  391. #define CS53L30_ADCxy_PREAMP_WIDTH 2
  392. #define CS53L30_ADCxy_PREAMP_MASK (((1 << CS53L30_ADCxy_PREAMP_WIDTH) - 1) << CS53L30_ADCxy_PREAMP_SHIFT)
  393. #define CS53L30_ADCxy_PGA_VOL_SHIFT 0
  394. #define CS53L30_ADCxy_PGA_VOL_WIDTH 6
  395. #define CS53L30_ADCxy_PGA_VOL_MASK (((1 << CS53L30_ADCxy_PGA_VOL_WIDTH) - 1) << CS53L30_ADCxy_PGA_VOL_SHIFT)
  396. #define CS53L30_ADCxy_AFE_CTL_DEFAULT (0)
  397. /* R43/R44/R51/R52 (0x2B/0x2C/0x33/0x34) CS53L30_ADCxy_DIG_VOL - ADC1A/1B/2A/2B Digital Volume */
  398. #define CS53L30_ADCxy_VOL_MUTE (0x80)
  399. #define CS53L30_ADCxy_DIG_VOL_DEFAULT (0x0)
  400. /* CS53L30_INT */
  401. #define CS53L30_PDN_DONE (1 << 7)
  402. #define CS53L30_THMS_TRIP (1 << 6)
  403. #define CS53L30_SYNC_DONE (1 << 5)
  404. #define CS53L30_ADC2B_OVFL (1 << 4)
  405. #define CS53L30_ADC2A_OVFL (1 << 3)
  406. #define CS53L30_ADC1B_OVFL (1 << 2)
  407. #define CS53L30_ADC1A_OVFL (1 << 1)
  408. #define CS53L30_MUTE_PIN (1 << 0)
  409. #define CS53L30_DEVICE_INT_MASK 0xFF
  410. #endif /* __CS53L30_H__ */