hpm_sgtl5000.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2019 NXP
  4. * Copyright (c) 2021 hpmicro
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. *
  8. */
  9. #ifndef _HPM_SGTL5000_H_
  10. #define _HPM_SGTL5000_H_
  11. #include <rtthread.h>
  12. #include <rtdevice.h>
  13. #include "rtt_board.h"
  14. #include "drivers/i2c.h"
  15. /*!
  16. * @addtogroup sgtl5000
  17. * @ingroup codec
  18. * @{
  19. */
  20. /*******************************************************************************
  21. * Definitions
  22. ******************************************************************************/
  23. /*! @brief Define the register address of sgtl5000. */
  24. #define CHIP_ID 0x0000U
  25. #define CHIP_DIG_POWER 0x0002U
  26. #define CHIP_CLK_CTRL 0x0004U
  27. #define CHIP_I2S_CTRL 0x0006U
  28. #define CHIP_SSS_CTRL 0x000AU
  29. #define CHIP_ADCDAC_CTRL 0x000EU
  30. #define CHIP_DAC_VOL 0x0010U
  31. #define CHIP_PAD_STRENGTH 0x0014U
  32. #define CHIP_ANA_ADC_CTRL 0x0020U
  33. #define CHIP_ANA_HP_CTRL 0x0022U
  34. #define CHIP_ANA_CTRL 0x0024U
  35. #define CHIP_LINREG_CTRL 0x0026U
  36. #define CHIP_REF_CTRL 0x0028U
  37. #define CHIP_MIC_CTRL 0x002AU
  38. #define CHIP_LINE_OUT_CTRL 0x002CU
  39. #define CHIP_LINE_OUT_VOL 0x002EU
  40. #define CHIP_ANA_POWER 0x0030U
  41. #define CHIP_PLL_CTRL 0x0032U
  42. #define CHIP_CLK_TOP_CTRL 0x0034U
  43. #define CHIP_ANA_STATUS 0x0036U
  44. #define CHIP_ANA_TEST2 0x003AU
  45. #define CHIP_SHORT_CTRL 0x003CU
  46. #define SGTL5000_DAP_CONTROL 0x0100U
  47. #define SGTL5000_DAP_PEQ 0x0102U
  48. #define SGTL5000_DAP_BASS_ENHANCE 0x0104U
  49. #define SGTL5000_DAP_BASS_ENHANCE_CTRL 0x0106U
  50. #define SGTL5000_DAP_AUDIO_EQ 0x0108U
  51. #define SGTL5000_DAP_SGTL_SURROUND 0x010AU
  52. #define SGTL5000_DAP_FILTER_COEF_ACCESS 0x010CU
  53. #define SGTL5000_DAP_COEF_WR_B0_MSB 0x010EU
  54. #define SGTL5000_DAP_COEF_WR_B0_LSB 0x0110U
  55. #define SGTL5000_DAP_AUDIO_EQ_BASS_BAND0 0x0116U
  56. #define SGTL5000_DAP_AUDIO_EQ_BAND1 0x0118U
  57. #define SGTL5000_DAP_AUDIO_EQ_BAND2 0x011AU
  58. #define SGTL5000_DAP_AUDIO_EQ_BAND3 0x011CU
  59. #define SGTL5000_DAP_AUDIO_EQ_TREBLE_BAND4 0x011EU
  60. #define SGTL5000_DAP_MAIN_CHAN 0x0120U
  61. #define SGTL5000_DAP_MIX_CHAN 0x0122U
  62. #define SGTL5000_DAP_AVC_CTRL 0x0124U
  63. #define SGTL5000_DAP_AVC_THRESHOLD 0x0126U
  64. #define SGTL5000_DAP_AVC_ATTACK 0x0128U
  65. #define SGTL5000_DAP_AVC_DECAY 0x012AU
  66. #define SGTL5000_DAP_COEF_WR_B1_MSB 0x012CU
  67. #define SGTL5000_DAP_COEF_WR_B1_LSB 0x012EU
  68. #define SGTL5000_DAP_COEF_WR_B2_MSB 0x0130U
  69. #define SGTL5000_DAP_COEF_WR_B2_LSB 0x0132U
  70. #define SGTL5000_DAP_COEF_WR_A1_MSB 0x0134U
  71. #define SGTL5000_DAP_COEF_WR_A1_LSB 0x0136U
  72. #define SGTL5000_DAP_COEF_WR_A2_MSB 0x0138U
  73. #define SGTL5000_DAP_COEF_WR_A2_LSB 0x013AU
  74. /*
  75. * Field Definitions.
  76. */
  77. /*
  78. * SGTL5000_CHIP_DIG_POWER
  79. */
  80. #define SGTL5000_ADC_ENABLE_CLR_MASK 0xFFBFU
  81. #define SGTL5000_ADC_ENABLE_GET_MASK 0x0040U
  82. #define SGTL5000_ADC_ENABLE_SHIFT 0x6U
  83. #define SGTL5000_DAC_ENABLE_CLR_MASK 0xFFDFU
  84. #define SGTL5000_DAC_ENABLE_GET_MASK 0x0020U
  85. #define SGTL5000_DAC_ENABLE_SHIFT 0x5U
  86. #define SGTL5000_DAP_ENABLE_CLR_MASK 0xFFEFU
  87. #define SGTL5000_DAP_ENABLE_GET_MASK 0x0010U
  88. #define SGTL5000_DAP_ENABLE_SHIFT 0x4U
  89. #define SGTL5000_I2S_OUT_ENABLE_CLR_MASK 0xFFFDU
  90. #define SGTL5000_I2S_OUT_ENABLE_GET_MASK 0x0002U
  91. #define SGTL5000_I2S_OUT_ENABLE_SHIFT 0x1U
  92. #define SGTL5000_I2S_IN_ENABLE_CLR_MASK 0xFFFEU
  93. #define SGTL5000_I2S_IN_ENABLE_GET_MASK 0x0001U
  94. #define SGTL5000_I2S_IN_ENABLE_SHIFT 0x0U
  95. /*
  96. * SGTL5000_CHIP_CLK_CTRL
  97. */
  98. #define SGTL5000_RATE_MODE_CLR_MASK 0xFFCFU
  99. #define SGTL5000_RATE_MODE_GET_MASK 0x0030U
  100. #define SGTL5000_RATE_MODE_SHIFT 0x4U
  101. #define SGTL5000_RATE_MODE_DIV_1 0x0000U
  102. #define SGTL5000_RATE_MODE_DIV_2 0x0010U
  103. #define SGTL5000_RATE_MODE_DIV_4 0x0020U
  104. #define SGTL5000_RATE_MODE_DIV_6 0x0030U
  105. #define SGTL5000_SYS_FS_CLR_MASK 0xFFF3U
  106. #define SGTL5000_SYS_FS_GET_MASK 0x000CU
  107. #define SGTL5000_SYS_FS_SHIFT 0x2U
  108. #define SGTL5000_SYS_FS_32k 0x0000U
  109. #define SGTL5000_SYS_FS_44_1k 0x0004U
  110. #define SGTL5000_SYS_FS_48k 0x0008U
  111. #define SGTL5000_SYS_FS_96k 0x000CU
  112. #define SGTL5000_MCLK_FREQ_CLR_MASK 0xFFFCU
  113. #define SGTL5000_MCLK_FREQ_GET_MASK 0x0003U
  114. #define SGTL5000_MCLK_FREQ_SHIFT 0x0U
  115. #define SGTL5000_MCLK_FREQ_256FS 0x0000U
  116. #define SGTL5000_MCLK_FREQ_384FS 0x0001U
  117. #define SGTL5000_MCLK_FREQ_512FS 0x0002U
  118. #define SGTL5000_MCLK_FREQ_PLL 0x0003U
  119. /*
  120. * SGTL5000_CHIP_I2S_CTRL
  121. */
  122. #define SGTL5000_I2S_SLCKFREQ_CLR_MASK 0xFEFFU
  123. #define SGTL5000_I2S_SCLKFREQ_GET_MASK 0x0100U
  124. #define SGTL5000_I2S_SCLKFREQ_SHIFT 0x8U
  125. #define SGTL5000_I2S_SCLKFREQ_64FS 0x0000U
  126. #define SGTL5000_I2S_SCLKFREQ_32FS 0x0100U /* Not for RJ mode */
  127. #define SGTL5000_I2S_MS_CLR_MASK 0xFF7FU
  128. #define SGTL5000_I2S_MS_GET_MASK 0x0080U
  129. #define SGTL5000_I2S_MS_SHIFT 0x7U
  130. #define SGTL5000_I2S_MASTER 0x0080U
  131. #define SGTL5000_I2S_SLAVE 0x0000U
  132. #define SGTL5000_I2S_SCLK_INV_CLR_MASK 0xFFBFU
  133. #define SGTL5000_I2S_SCLK_INV_GET_MASK 0x0040U
  134. #define SGTL5000_I2S_SCLK_INV_SHIFT 0x6U
  135. #define SGTL5000_I2S_VAILD_FALLING_EDGE 0x0040U
  136. #define SGTL5000_I2S_VAILD_RISING_EDGE 0x0000U
  137. #define SGTL5000_I2S_DLEN_CLR_MASK 0xFFCFU
  138. #define SGTL5000_I2S_DLEN_GET_MASK 0x0030U
  139. #define SGTL5000_I2S_DLEN_SHIFT 0x4U
  140. #define SGTL5000_I2S_DLEN_32 0x0000U
  141. #define SGTL5000_I2S_DLEN_24 0x0010U
  142. #define SGTL5000_I2S_DLEN_20 0x0020U
  143. #define SGTL5000_I2S_DLEN_16 0x0030U
  144. #define SGTL5000_I2S_MODE_CLR_MASK 0xFFF3U
  145. #define SGTL5000_I2S_MODE_GET_MASK 0x000CU
  146. #define SGTL5000_I2S_MODE_SHIFT 0x2U
  147. #define SGTL5000_I2S_MODE_I2S_LJ 0x0000U
  148. #define SGTL5000_I2S_MODE_RJ 0x0004U
  149. #define SGTL5000_I2S_MODE_PCM 0x0008U
  150. #define SGTL5000_I2S_LRALIGN_CLR_MASK 0xFFFDU
  151. #define SGTL5000_I2S_LRALIGN_GET_MASK 0x0002U
  152. #define SGTL5000_I2S_LRALIGN_SHIFT 0x1U
  153. #define SGTL5000_I2S_ONE_BIT_DELAY 0x0000U
  154. #define SGTL5000_I2S_NO_DELAY 0x0002U
  155. #define SGTL5000_I2S_LRPOL_CLR_MASK 0xFFFEU
  156. #define SGTL5000_I2S_LRPOL_GET_MASK 0x0001U
  157. #define SGTL5000_I2S_LRPOL_SHIFT 0x0U
  158. #define SGTL5000_I2S_LEFT_FIRST 0x0000U
  159. #define SGTL5000_I2S_RIGHT_FIRST 0x0001U
  160. /*
  161. * SGTL5000_CHIP_SSS_CTRL
  162. */
  163. #define SGTL5000_DAP_MIX_LRSWAP_CLR_MASK 0xBFFFU
  164. #define SGTL5000_DAP_MIX_LRSWAP_GET_MASK 0x4000U
  165. #define SGTL5000_DAP_MIX_LRSWAP_SHIFT 0xEU
  166. #define SGTL5000_DAP_LRSWAP_CLR_MASK 0xDFFFU
  167. #define SGTL5000_DAP_LRSWAP_GET_MASK 0x2000U
  168. #define SGTL5000_DAP_LRSWAP_SHIFT 0xDU
  169. #define SGTL5000_DAC_LRSWAP_CLR_MASK 0xEFFFU
  170. #define SGTL5000_DAC_LRSWAP_GET_MASK 0x1000U
  171. #define SGTL5000_DAC_LRSWAP_SHIFT 0xCU
  172. #define SGTL5000_I2S_LRSWAP_CLR_MASK 0xFBFFU
  173. #define SGTL5000_I2S_LRSWAP_GET_MASK 0x0400U
  174. #define SGTL5000_I2S_LRSWAP_SHIFT 0xAU
  175. #define SGTL5000_DAP_MIX_SEL_CLR_MASK 0xFCFFU
  176. #define SGTL5000_DAP_MIX_SEL_GET_MASK 0x0300U
  177. #define SGTL5000_DAP_MIX_SEL_SHIFT 0x8U
  178. #define SGTL5000_DAP_MIX_SEL_ADC 0x0000U
  179. #define SGTL5000_DAP_MIX_SEL_I2S_IN 0x0100U
  180. #define SGTL5000_DAP_SEL_CLR_MASK 0xFF3FU
  181. #define SGTL5000_DAP_SEL_GET_MASK 0x00C0U
  182. #define SGTL5000_DAP_SEL_SHIFT 0x6U
  183. #define SGTL5000_DAP_SEL_ADC 0x0000U
  184. #define SGTL5000_DAP_SEL_I2S_IN 0x0040U
  185. #define SGTL5000_DAC_SEL_CLR_MASK 0xFFCFU
  186. #define SGTL5000_DAC_SEL_GET_MASK 0x0030U
  187. #define SGTL5000_DAC_SEL_SHIFT 0x4U
  188. #define SGTL5000_DAC_SEL_ADC 0x0000U
  189. #define SGTL5000_DAC_SEL_I2S_IN 0x0010U
  190. #define SGTL5000_DAC_SEL_DAP 0x0030U
  191. #define SGTL5000_I2S_OUT_SEL_CLR_MASK 0xFFFCU
  192. #define SGTL5000_I2S_OUT_SEL_GET_MASK 0x0003U
  193. #define SGTL5000_I2S_OUT_SEL_SHIFT 0x0U
  194. #define SGTL5000_I2S_OUT_SEL_ADC 0x0000U
  195. #define SGTL5000_I2S_OUT_SEL_I2S_IN 0x0001U
  196. #define SGTL5000_I2S_OUT_SEL_DAP 0x0003U
  197. /*
  198. * SGTL5000_CHIP_ADCDAC_CTRL
  199. */
  200. #define SGTL5000_VOL_BUSY_DAC_RIGHT 0x2000U
  201. #define SGTL5000_VOL_BUSY_DAC_LEFT 0x1000U
  202. #define SGTL5000_DAC_VOL_RAMP_EN_CLR_MASK 0xFDFFU
  203. #define SGTL5000_DAC_VOL_RAMP_EN_GET_MASK 0x0200U
  204. #define SGTL5000_DAC_VOL_RAMP_EN_SHIFT 0x9U
  205. #define SGTL5000_DAC_VOL_RAMP_EXPO_CLR_MASK 0xFEFFU
  206. #define SGTL5000_DAC_VOL_RAMP_EXPO_GET_MASK 0x0100U
  207. #define SGTL5000_DAC_VOL_RAMP_EXPO_SHIFT 0x8U
  208. #define SGTL5000_DAC_MUTE_RIGHT_CLR_MASK 0xFFF7U
  209. #define SGTL5000_DAC_MUTE_RIGHT_GET_MASK 0x0008U
  210. #define SGTL5000_DAC_MUTE_RIGHT_SHIFT 0x3U
  211. #define SGTL5000_DAC_MUTE_LEFT_CLR_MASK 0xFFFBU
  212. #define SGTL5000_DAC_MUTE_LEFT_GET_MASK 0x0004U
  213. #define SGTL5000_DAC_MUTE_LEFT_SHIFT 0x2U
  214. #define SGTL5000_ADC_HPF_FREEZE_CLR_MASK 0xFFFDU
  215. #define SGTL5000_ADC_HPF_FREEZE_GET_MASK 0x0002U
  216. #define SGTL5000_ADC_HPF_FREEZE_SHIFT 0x1U
  217. #define SGTL5000_ADC_HPF_BYPASS_CLR_MASK 0xFFFEU
  218. #define SGTL5000_ADC_HPF_BYPASS_GET_MASK 0x0001U
  219. #define SGTL5000_ADC_HPF_BYPASS_SHIFT 0x0U
  220. /*
  221. * SGTL5000_CHIP_DAC_VOL
  222. */
  223. #define SGTL5000_DAC_VOL_RIGHT_CLR_MASK 0x00FFU
  224. #define SGTL5000_DAC_VOL_RIGHT_GET_MASK 0xFF00U
  225. #define SGTL5000_DAC_VOL_RIGHT_SHIFT 0x8U
  226. #define SGTL5000_DAC_VOL_LEFT_CLR_MASK 0xFF00U
  227. #define SGTL5000_DAC_VOL_LEFT_GET_MASK 0x00FFU
  228. #define SGTL5000_DAC_VOL_LEFT_SHIFT 0x0U
  229. /*
  230. * SGTL5000_CHIP_PAD_STRENGTH
  231. */
  232. #define SGTL5000_PAD_I2S_LRCLK_CLR_MASK 0xFCFFU
  233. #define SGTL5000_PAD_I2S_LRCLK_GET_MASK 0x0300U
  234. #define SGTL5000_PAD_I2S_LRCLK_SHIFT 0x8U
  235. #define SGTL5000_PAD_I2S_SCLK_CLR_MASK 0xFF3FU
  236. #define SGTL5000_PAD_I2S_SCLK_GET_MASK 0x00C0U
  237. #define SGTL5000_PAD_I2S_SCLK_SHIFT 0x6U
  238. #define SGTL5000_PAD_I2S_DOUT_CLR_MASK 0xFFCFU
  239. #define SGTL5000_PAD_I2S_DOUT_GET_MASK 0x0030U
  240. #define SGTL5000_PAD_I2S_DOUT_SHIFT 0x4U
  241. #define SGTL5000_PAD_I2C_SDA_CLR_MASK 0xFFF3U
  242. #define SGTL5000_PAD_I2C_SDA_GET_MASK 0x000CU
  243. #define SGTL5000_PAD_I2C_SDA_SHIFT 0x2U
  244. #define SGTL5000_PAD_I2C_SCL_CLR_MASK 0xFFFCU
  245. #define SGTL5000_PAD_I2C_SCL_GET_MASK 0x0003U
  246. #define SGTL5000_PAD_I2C_SCL_SHIFT 0x0U
  247. /*
  248. * SGTL5000_CHIP_ANA_ADC_CTRL
  249. */
  250. #define SGTL5000_ADC_VOL_M6DB_CLR_MASK 0xFEFFU
  251. #define SGTL5000_ADC_VOL_M6DB_GET_MASK 0x0100U
  252. #define SGTL5000_ADC_VOL_M6DB_SHIFT 0x8U
  253. #define SGTL5000_ADC_VOL_RIGHT_CLR_MASK 0xFF0FU
  254. #define SGTL5000_ADC_VOL_RIGHT_GET_MASK 0x00F0U
  255. #define SGTL5000_ADC_VOL_RIGHT_SHIFT 0x4U
  256. #define SGTL5000_ADC_VOL_LEFT_CLR_MASK 0xFFF0U
  257. #define SGTL5000_ADC_VOL_LEFT_GET_MASK 0x000FU
  258. #define SGTL5000_ADC_VOL_LEFT_SHIFT 0x0U
  259. /*
  260. * SGTL5000_CHIP_ANA_HP_CTRL
  261. */
  262. #define SGTL5000_HP_VOL_RIGHT_CLR_MASK 0x80FFU
  263. #define SGTL5000_HP_VOL_RIGHT_GET_MASK 0x7F00U
  264. #define SGTL5000_HP_VOL_RIGHT_SHIFT 0x8U
  265. #define SGTL5000_HP_VOL_LEFT_CLR_MASK 0xFF80U
  266. #define SGTL5000_HP_VOL_LEFT_GET_MASK 0x007FU
  267. #define SGTL5000_HP_VOL_LEFT_SHIFT 0x0U
  268. /*
  269. * SGTL5000_CHIP_ANA_CTRL
  270. */
  271. #define SGTL5000_MUTE_LO_GET_MASK 0x0100U
  272. #define SGTL5000_MUTE_LO_CLR_MASK 0xFEFFU
  273. #define SGTL5000_MUTE_LO_SHIFT 0x8U
  274. #define SGTL5000_SEL_HP_GET_MASK 0x0040U
  275. #define SGTL5000_SEL_HP_CLR_MASK 0xFFBFU
  276. #define SGTL5000_SEL_HP_SHIFT 0x6U
  277. #define SGTL5000_SEL_HP_DAC 0x0000U
  278. #define SGTL5000_SEL_HP_LINEIN 0x0040U
  279. #define SGTL5000_EN_ZCD_HP_GET_MASK 0x0020U
  280. #define SGTL5000_EN_ZCD_HP_CLR_MASK 0xFFDFU
  281. #define SGTL5000_EN_ZCD_HP_SHIFT 0x5U
  282. #define SGTL5000_MUTE_HP_GET_MASK 0x0010U
  283. #define SGTL5000_MUTE_HP_CLR_MASK 0xFFEFU
  284. #define SGTL5000_MUTE_HP_SHIFT 0x4U
  285. #define SGTL5000_SEL_ADC_GET_MASK 0x0004U
  286. #define SGTL5000_SEL_ADC_CLR_MASK 0xFFFBU
  287. #define SGTL5000_SEL_ADC_SHIFT 0x2U
  288. #define SGTL5000_SEL_ADC_MIC 0x0000U
  289. #define SGTL5000_SEL_ADC_LINEIN 0x0004U
  290. #define SGTL5000_EN_ZCD_ADC_GET_MASK 0x0002U
  291. #define SGTL5000_EN_ZCD_ADC_CLR_MASK 0xFFFDU
  292. #define SGTL5000_EN_ZCD_ADC_SHIFT 0x1U
  293. #define SGTL5000_MUTE_ADC_GET_MASK 0x0001U
  294. #define SGTL5000_MUTE_ADC_CLR_MASK 0xFFFEU
  295. #define SGTL5000_MUTE_ADC_SHIFT 0x0U
  296. /*
  297. * SGTL5000_CHIP_LINREG_CTRL
  298. */
  299. #define SGTL5000_VDDC_MAN_ASSN_CLR_MASK 0xFFBFU
  300. #define SGTL5000_VDDC_MAN_ASSN_GET_MASK 0x0040U
  301. #define SGTL5000_VDDC_MAN_ASSN_SHIFT 0x6U
  302. #define SGTL5000_VDDC_MAN_ASSN_VDDA 0x0000U
  303. #define SGTL5000_VDDC_MAN_ASSN_VDDIO 0x0040U
  304. #define SGTL5000_VDDC_ASSN_OVRD 0x0020U
  305. #define SGTL5000_LINREG_VDDD_CLR_MASK 0xFFF0U
  306. #define SGTL5000_LINREG_VDDD_GET_MASK 0x000FU
  307. #define SGTL5000_LINREG_VDDD_SHIFT 0x0U
  308. /*
  309. * SGTL5000_CHIP_REF_CTRL
  310. */
  311. #define SGTL5000_ANA_GND_MASK 0x01f0U
  312. #define SGTL5000_ANA_GND_SHIFT 0x4U
  313. #define SGTL5000_ANA_GND_WIDTH 0x5U
  314. #define SGTL5000_ANA_GND_BASE 0x320U /* mv */
  315. #define SGTL5000_ANA_GND_STP 0x19U /*mv */
  316. #define SGTL5000_BIAS_CTRL_MASK 0x000eU
  317. #define SGTL5000_BIAS_CTRL_SHIFT 0x1U
  318. #define SGTL5000_BIAS_CTRL_WIDTH 0x3U
  319. #define SGTL5000_SMALL_POP 0x0001U
  320. /*
  321. * SGTL5000_CHIP_MIC_CTRL
  322. */
  323. #define SGTL5000_BIAS_R__CLR_MASK 0xFCFFU
  324. #define SGTL5000_BIAS_R_GET_MASK 0x0300U
  325. #define SGTL5000_BIAS_R_SHIFT 0x8U
  326. #define SGTL5000_BIAS_R_off 0x0000U
  327. #define SGTL5000_BIAS_R_2K 0x0100U
  328. #define SGTL5000_BIAS_R_4k 0x0200U
  329. #define SGTL5000_BIAS_R_8k 0x0300U
  330. #define SGTL5000_BIAS_VOLT_CLR_MASK 0xFF8FU
  331. #define SGTL5000_BIAS_VOLT_GET_MASK 0x0070U
  332. #define SGTL5000_BIAS_VOLT_SHIFT 0x4U
  333. #define SGTL5000_MIC_GAIN_CLR_MASK 0xFFFCU
  334. #define SGTL5000_MIC_GAIN_GET_MASK 0x0003U
  335. #define SGTL5000_MIC_GAIN_SHIFT 0x0U
  336. /*
  337. * SGTL5000_CHIP_LINE_OUT_CTRL
  338. */
  339. #define SGTL5000_LINE_OUT_CURRENT_CLR_MASK 0xF0FFU
  340. #define SGTL5000_LINE_OUT_CURRENT_GET_MASK 0x0F00U
  341. #define SGTL5000_LINE_OUT_CURRENT_SHIFT 0x8U
  342. #define SGTL5000_LINE_OUT_CURRENT_180u 0x0000U
  343. #define SGTL5000_LINE_OUT_CURRENT_270u 0x0100U
  344. #define SGTL5000_LINE_OUT_CURRENT_360u 0x0300U
  345. #define SGTL5000_LINE_OUT_CURRENT_450u 0x0700U
  346. #define SGTL5000_LINE_OUT_CURRENT_540u 0x0F00U
  347. #define SGTL5000_LINE_OUT_GND_CLR_MASK 0xFFC0U
  348. #define SGTL5000_LINE_OUT_GND_GET_MASK 0x003FU
  349. #define SGTL5000_LINE_OUT_GND_SHIFT 0x0U
  350. #define SGTL5000_LINE_OUT_GND_BASE 0x320U /* mv */
  351. #define SGTL5000_LINE_OUT_GND_STP 0x19U
  352. #define SGTL5000_LINE_OUT_GND_MAX 0x23U
  353. /*
  354. * SGTL5000_CHIP_LINE_OUT_VOL
  355. */
  356. #define SGTL5000_LINE_OUT_VOL_RIGHT_CLR_MASK 0xE0FFU
  357. #define SGTL5000_LINE_OUT_VOL_RIGHT_GET_MASK 0x1F00U
  358. #define SGTL5000_LINE_OUT_VOL_RIGHT_SHIFT 0x8U
  359. #define SGTL5000_LINE_OUT_VOL_LEFT_CLR_MASK 0xFFE0U
  360. #define SGTL5000_LINE_OUT_VOL_LEFT_GET_MASK 0x001FU
  361. #define SGTL5000_LINE_OUT_VOL_LEFT_SHIFT 0x0U
  362. /*
  363. * SGTL5000_CHIP_ANA_POWER
  364. */
  365. #define SGTL5000_RIGHT_DAC_POWERUP_GET_MASK 0x4000U
  366. #define SGTL5000_RIGHT_DAC_POWERUP_CLR_MASK 0xBFFFU
  367. #define SGTL5000_RIGHT_DAC_POWERUP_SHIFT 0xEU
  368. #define SGTL5000_LINREG_SIMPLE_POWERUP_GET_MASK 0x2000U
  369. #define SGTL5000_LINREG_SIMPLE_POWERUP_CLR_MASK 0xDFFFU
  370. #define SGTL5000_LINREG_SIMPLE_POWERUP_SHIFT 0xDU
  371. #define SGTL5000_STARTUP_POWERUP_GET_MASK 0x1000U
  372. #define SGTL5000_STARTUP_POWERUP_CLR_MASK 0xEFFFU
  373. #define SGTL5000_STARTUP_POWERUP_SHIFT 0xCU
  374. #define SGTL5000_VDDC_CHRGPMP_POWERUP_GET_MASK 0x0800U
  375. #define SGTL5000_VDDC_CHRGPMP_POWERUP_CLR_MASK 0xF7FFU
  376. #define SGTL5000_VDDC_CHRGPMP_POWERUP_SHIFT 0xBU
  377. #define SGTL5000_PLL_POWERUP_GET_MASK 0x0400U
  378. #define SGTL5000_PLL_POWERUP_CLR_MASK 0xFBFFU
  379. #define SGTL5000_PLL_POWERUP_SHIFT 0xAU
  380. #define SGTL5000_LINREG_D_POWERUP_GET_MASK 0x0200U
  381. #define SGTL5000_LINREG_D_POWERUP_CLR_MASK 0xFDFFU
  382. #define SGTL5000_LINREG_D_POWERUP_SHIFT 0x9U
  383. #define SGTL5000_VCOAMP_POWERUP_GET_MASK 0x0100U
  384. #define SGTL5000_VCOAMP_POWERUP_CLR_MASK 0xFEFFU
  385. #define SGTL5000_VCOAMP_POWERUP_SHIFT 0x8U
  386. #define SGTL5000_VAG_POWERUP_GET_MASK 0x0080U
  387. #define SGTL5000_VAG_POWERUP_CLR_MASK 0xFF7FU
  388. #define SGTL5000_VAG_POWERUP_SHIFT 0x7U
  389. #define SGTL5000_RIGHT_ADC_POWERUP_GET_MASK 0x0040U
  390. #define SGTL5000_RIGHT_ADC_POWERUP_CLR_MASK 0xFFBFU
  391. #define SGTL5000_RIGHT_ADC_POWERUP_SHIFT 0x6U
  392. #define SGTL5000_REFTOP_POWERUP_GET_MASK 0x0020U
  393. #define SGTL5000_REFTOP_POWERUP_CLR_MASK 0xFFDFU
  394. #define SGTL5000_REFTOP_POWERUP_SHIFT 0x5U
  395. #define SGTL5000_HEADPHONE_POWERUP_GET_MASK 0x0010U
  396. #define SGTL5000_HEADPHONE_POWERUP_CLR_MASK 0xFFEFU
  397. #define SGTL5000_HEADPHONE_POWERUP_SHIFT 0x4U
  398. #define SGTL5000_DAC_POWERUP_GET_MASK 0x0008U
  399. #define SGTL5000_DAC_POWERUP_CLR_MASK 0xFFF7U
  400. #define SGTL5000_DAC_POWERUP_SHIFT 0x3U
  401. #define SGTL5000_CAPLESS_HEADPHONE_POWERUP_GET_MASK 0x0004U
  402. #define SGTL5000_CAPLESS_HEADPHONE_POWERUP_CLR_MASK 0xFFFBU
  403. #define SGTL5000_CAPLESS_HEADPHONE_POWERUP_SHIFT 0x2U
  404. #define SGTL5000_ADC_POWERUP_GET_MASK 0x0002U
  405. #define SGTL5000_ADC_POWERUP_CLR_MASK 0xFFFDU
  406. #define SGTL5000_ADC_POWERUP_SHIFT 0x1U
  407. #define SGTL5000_LINEOUT_POWERUP_GET_MASK 0x0001U
  408. #define SGTL5000_LINEOUT_POWERUP_CLR_MASK 0xFFFEU
  409. #define SGTL5000_LINEOUT_POWERUP_SHIFT 0x0U
  410. /*
  411. * SGTL5000_CHIP_PLL_CTRL
  412. */
  413. #define SGTL5000_PLL_INT_DIV_CLR_MASK 0x07FFU
  414. #define SGTL5000_PLL_INT_DIV_GET_MASK 0xF800U
  415. #define SGTL5000_PLL_INT_DIV_SHIFT 0xBU
  416. #define SGTL5000_PLL_FRAC_DIV_CLR_MASK 0xF8FFU
  417. #define SGTL5000_PLL_FRAC_DIV_GET_MASK 0x0700U
  418. #define SGTL5000_PLL_FRAC_DIV_SHIFT 0x0U
  419. /*
  420. * SGTL5000_CHIP_CLK_TOP_CTRL
  421. */
  422. #define SGTL5000_ENABLE_INT_OSC_GET_MASK 0x0800U
  423. #define SGTL5000_ENABLE_INT_OSC_CLR_MASK 0xF7FFU
  424. #define SGTL5000_ENABLE_INT_OSC_SHIFT 0xBU
  425. #define SGTL5000_INPUT_FREQ_DIV2_GET_MASK 0x0008U
  426. #define SGTL5000_INPUT_FREQ_DIV2_CLR_MASK 0xFFF7U
  427. #define SGTL5000_INPUT_FREQ_DIV2_SHIFT 0x3U
  428. /*
  429. * SGTL5000_CHIP_ANA_STATUS
  430. */
  431. #define SGTL5000_HP_LRSHORT 0x0200U
  432. #define SGTL5000_CAPLESS_SHORT 0x0100U
  433. #define SGTL5000_PLL_LOCKED 0x0010U
  434. /*
  435. * SGTL5000_CHIP_SHORT_CTRL
  436. */
  437. #define SGTL5000_LVLADJR_CLR_MASK 0x8FFFU
  438. #define SGTL5000_LVLADJR_GET_MASK 0x7000U
  439. #define SGTL5000_LVLADJR_SHIFT 0xCU
  440. #define SGTL5000_LVLADJL_CLR_MASK 0xF8FFU
  441. #define SGTL5000_LVLADJL_GET_MASK 0x0700U
  442. #define SGTL5000_LVLADJL_SHIFT 0x8U
  443. #define SGTL5000_LVLADJC_CLR_MASK 0xFF8FU
  444. #define SGTL5000_LVLADJC_GET_MASK 0x0070U
  445. #define SGTL5000_LVLADJC_SHIFT 0x4U
  446. #define SGTL5000_LR_SHORT_MOD_CLR_MASK 0xFFF3U
  447. #define SGTL5000_LR_SHORT_MOD_GET_MASK 0x000CU
  448. #define SGTL5000_LR_SHORT_MOD_SHIFT 0x2U
  449. #define SGTL5000_CM_SHORT_MOD_CLR_MASK 0xFFFCU
  450. #define SGTL5000_CM_SHORT_MOD_GET_MASK 0x0003U
  451. #define SGTL5000_CM_SHORT_MOD_SHIFT 0x0U
  452. /* DAP control register */
  453. #define SGTL5000_DAP_CONTROL_MIX_EN_GET_MASK 0x0010U
  454. #define SGTL5000_DAP_CONTROL_MIX_EN_CLR_MASK 0xFFEFU
  455. #define SGTL5000_DAP_CONTROL_MIX_EN_SHIFT 0x4U
  456. #define SGTL5000_DAP_CONTROL_DAP_EN_GET_MASK 0x0001U
  457. #define SGTL5000_DAP_CONTROL_DAP_EN_CLR_MASK 0xFFFEU
  458. #define SGTL5000_DAP_CONTROL_DAP_EN_SHIFT 0x0U
  459. /*
  460. * DAP_PEQ_REG
  461. */
  462. #define SGTL5000_DAP_PEQ_EN_GET_MASK 0x0007U
  463. #define SGTL5000_DAP_PEQ_EN_CLR_MASK 0xFFF8U
  464. #define SGTL5000_DAP_PEQ_EN_SHIFT 0x0U
  465. /*
  466. * DAP_BASS_ENHANCE_REG
  467. */
  468. #define SGTL5000_DAP_BASS_ENHANCE_MULT_GET_MASK 0xC000U
  469. #define SGTL5000_DAP_BASS_ENHANCE_MULT_CLR_MASK 0x3FFFU
  470. #define SGTL5000_DAP_BASS_ENHANCE_MULT_SHIFT 0xEU
  471. #define SGTL5000_DAP_BASS_ENHANCE_CUTOFF_HPF_GET_MASK 0x0E00U
  472. #define SGTL5000_DAP_BASS_ENHANCE_CUTOFF_HPF_CLR_MASK 0xF1FFU
  473. #define SGTL5000_DAP_BASS_ENHANCE_CUTOFF_HPF_SHIFT 0x9U
  474. #define SGTL5000_DAP_BASS_ENHANCE_BYPASS_HPF_GET_MASK 0x0100U
  475. #define SGTL5000_DAP_BASS_ENHANCE_BYPASS_HPF_CLR_MASK 0xFEFFU
  476. #define SGTL5000_DAP_BASS_ENHANCE_BYPASS_HPF_SHIFT 0x8U
  477. #define SGTL5000_DAP_BASS_ENHANCE_CUTOFF_GET_MASK 0x0070U
  478. #define SGTL5000_DAP_BASS_ENHANCE_CUTOFF_CLR_MASK 0xFF8FU
  479. #define SGTL5000_DAP_BASS_ENHANCE_CUTOFF_SHIFT 0x4U
  480. #define SGTL5000_DAP_BASS_ENHANCE_EN_GET_MASK 0x0001U
  481. #define SGTL5000_DAP_BASS_ENHANCE_EN_CLR_MASK 0xFFFEU
  482. #define SGTL5000_DAP_BASS_ENHANCE_EN_SHIFT 0x0U
  483. /*
  484. * DAP_BASS_ENHANCE_CTRL_REG
  485. */
  486. #define SGTL5000_DAP_BASS_ENHANCE_CTRL_LR_LEVEL_GET_MASK 0x3F00U
  487. #define SGTL5000_DAP_BASS_ENHANCE_CTRL_LR_LEVEL_CLR_MASK 0xC0FFU
  488. #define SGTL5000_DAP_BASS_ENHANCE_CTRL_LR_LEVEL_SHIFT 0x8U
  489. #define SGTL5000_DAP_BASS_ENHANCE_CTRL_BASS_LEVEL_GET_MASK 0x007FU
  490. #define SGTL5000_DAP_BASS_ENHANCE_CTRL_BASS_LEVEL_CLR_MASK 0xFF80U
  491. #define SGTL5000_DAP_BASS_ENHANCE_CTRL_BASS_LEVEL_SHIFT 0x0U
  492. /*
  493. * DAP_AUDIO_EQ_REG
  494. */
  495. #define SGTL5000_DAP_AUDIO_EQ_EN_GET_MASK 0x0003U
  496. #define SGTL5000_DAP_AUDIO_EQ_EN_CLR_MASK 0xFFFCU
  497. #define SGTL5000_DAP_AUDIO_EQ_EN_SHIFT 0x0U
  498. /*
  499. * DAP_SGTL_SURROUND_REG
  500. */
  501. #define SGTL5000_DAP_SGTL_SURROUND_WIDTH_CONTROL_GET_MASK 0x0070U
  502. #define SGTL5000_DAP_SGTL_SURROUND_WIDTH_CONTROL_CLR_MASK 0xFF8FU
  503. #define SGTL5000_DAP_SGTL_SURROUND_WIDTH_CONTROL_SHIFT 0x4U
  504. #define SGTL5000_DAP_SGTL_SURROUND_SEL_GET_MASK 0x0003U
  505. #define SGTL5000_DAP_SGTL_SURROUND_SEL_CLR_MASK 0xFFFCU
  506. #define SGTL5000_DAP_SGTL_SURROUND_SEL_SHIFT 0x0U
  507. /*
  508. * DAP_FILTER_COEF_ACCESS_REG
  509. */
  510. #define SGTL5000_DAP_FILTER_COEF_ACCESS_DEBUG_GET_MASK 0x1000U
  511. #define SGTL5000_DAP_FILTER_COEF_ACCESS_DEBUG_CLR_MASK 0xEFFFU
  512. #define SGTL5000_DAP_FILTER_COEF_ACCESS_DEBUG_SHIFT 0xCU
  513. #define SGTL5000_DAP_FILTER_COEF_ACCESS_RD_GET_MASK 0x0200U
  514. #define SGTL5000_DAP_FILTER_COEF_ACCESS_RD_CLR_MASK 0xFDFFU
  515. #define SGTL5000_DAP_FILTER_COEF_ACCESS_RD_SHIFT 0x9U
  516. #define SGTL5000_DAP_FILTER_COEF_ACCESS_WR_GET_MASK 0x0100U
  517. #define SGTL5000_DAP_FILTER_COEF_ACCESS_WR_CLR_MASK 0xFEFFU
  518. #define SGTL5000_DAP_FILTER_COEF_ACCESS_WR_SHIFT 0x8U
  519. #define SGTL5000_DAP_FILTER_COEF_ACCESS_INDEX_GET_MASK 0x00FFU
  520. #define SGTL5000_DAP_FILTER_COEF_ACCESS_INDEX_CLR_MASK 0xFF00U
  521. #define SGTL5000_DAP_FILTER_COEF_ACCESS_INDEX_SHIFT 0x0U
  522. /*
  523. * DAP_COEF_WR_B0_MSB_REG
  524. */
  525. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_19_GET_MASK 0x8000U
  526. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_19_CLR_MASK 0x7FFFU
  527. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_19_SHIFT 0xFU
  528. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_18_GET_MASK 0x4000U
  529. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_18_CLR_MASK 0xBFFFU
  530. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_18_SHIFT 0xEU
  531. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_17_GET_MASK 0x2000U
  532. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_17_CLR_MASK 0xDFFFU
  533. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_17_SHIFT 0xDU
  534. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_16_GET_MASK 0x1000U
  535. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_16_CLR_MASK 0xEFFFU
  536. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_16_SHIFT 0xCU
  537. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_15_GET_MASK 0x0800U
  538. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_15_CLR_MASK 0xF7FFU
  539. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_15_SHIFT 0xBU
  540. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_14_GET_MASK 0x0400U
  541. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_14_CLR_MASK 0xFBFFU
  542. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_14_SHIFT 0xAU
  543. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_13_GET_MASK 0x0200U
  544. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_13_CLR_MASK 0xFDFFU
  545. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_13_SHIFT 0x9U
  546. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_12_GET_MASK 0x0100U
  547. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_12_CLR_MASK 0xFEFFU
  548. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_12_SHIFT 0x8U
  549. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_11_GET_MASK 0x0080U
  550. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_11_CLR_MASK 0xFF7FU
  551. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_11_SHIFT 0x7U
  552. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_10_GET_MASK 0x0040U
  553. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_10_CLR_MASK 0xFFBFU
  554. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_10_SHIFT 0x6U
  555. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_9_GET_MASK 0x0020U
  556. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_9_CLR_MASK 0xFFDFU
  557. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_9_SHIFT 0x5U
  558. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_8_GET_MASK 0x0010U
  559. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_8_CLR_MASK 0xFFEFU
  560. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_8_SHIFT 0x4U
  561. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_7_GET_MASK 0x0008U
  562. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_7_CLR_MASK 0xFFF7U
  563. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_7_SHIFT 0x3U
  564. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_6_GET_MASK 0x0004U
  565. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_6_CLR_MASK 0xFFFBU
  566. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_6_SHIFT 0x2U
  567. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_5_GET_MASK 0x0002U
  568. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_5_CLR_MASK 0xFFFDU
  569. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_5_SHIFT 0x1U
  570. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_4_GET_MASK 0x0001U
  571. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_4_CLR_MASK 0xFFFEU
  572. #define SGTL5000_DAP_COEF_WR_B0_MSB_BIT_4_SHIFT 0x0U
  573. /*
  574. * DAP_COEF_WR_B0_LSB_REG
  575. */
  576. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_3_GET_MASK 0x0008U
  577. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_3_CLR_MASK 0xFFF7U
  578. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_3_SHIFT 0x3U
  579. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_2_GET_MASK 0x0004U
  580. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_2_CLR_MASK 0xFFFBU
  581. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_2_SHIFT 0x2U
  582. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_1_GET_MASK 0x0002U
  583. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_1_CLR_MASK 0xFFFDU
  584. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_1_SHIFT 0x1U
  585. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_0_GET_MASK 0x0001U
  586. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_0_CLR_MASK 0xFFFEU
  587. #define SGTL5000_DAP_COEF_WR_B0_LSB_BIT_0_SHIFT 0x0U
  588. /*
  589. * DAP_AUDIO_EQ_BASS_BAND0_REG
  590. */
  591. #define SGTL5000_DAP_AUDIO_EQ_BASS_BAND0_VOLUME_GET_MASK 0x007FU
  592. #define SGTL5000_DAP_AUDIO_EQ_BASS_BAND0_VOLUME_CLR_MASK 0xFF80U
  593. #define SGTL5000_DAP_AUDIO_EQ_BASS_BAND0_VOLUME_SHIFT 0x0U
  594. /*
  595. * DAP_AUDIO_EQ_BAND1_REG
  596. */
  597. #define SGTL5000_DAP_AUDIO_EQ_BAND1_VOLUME_GET_MASK 0x007FU
  598. #define SGTL5000_DAP_AUDIO_EQ_BAND1_VOLUME_CLR_MASK 0xFF80U
  599. #define SGTL5000_DAP_AUDIO_EQ_BAND1_VOLUME_SHIFT 0x0U
  600. /*
  601. * DAP_AUDIO_EQ_BAND2_REG
  602. */
  603. #define SGTL5000_DAP_AUDIO_EQ_BAND2_VOLUME_GET_MASK 0x007FU
  604. #define SGTL5000_DAP_AUDIO_EQ_BAND2_VOLUME_CLR_MASK 0xFF80U
  605. #define SGTL5000_DAP_AUDIO_EQ_BAND2_VOLUME_SHIFT 0x0U
  606. /*
  607. * DAP_AUDIO_EQ_BAND3_REG
  608. */
  609. #define SGTL5000_DAP_AUDIO_EQ_BAND3_VOLUME_GET_MASK 0x007FU
  610. #define SGTL5000_DAP_AUDIO_EQ_BAND3_VOLUME_CLR_MASK 0xFF80U
  611. #define SGTL5000_DAP_AUDIO_EQ_BAND3_VOLUME_SHIFT 0x0U
  612. /*
  613. * DAP_AUDIO_EQ_TREBLE_BAND4_REG
  614. */
  615. #define SGTL5000_DAP_AUDIO_EQ_TREBLE_BAND4_VOLUME_GET_MASK 0x007FU
  616. #define SGTL5000_DAP_AUDIO_EQ_TREBLE_BAND4_VOLUME_CLR_MASK 0xFF80U
  617. #define SGTL5000_DAP_AUDIO_EQ_TREBLE_BAND4_VOLUME_SHIFT 0x0U
  618. /*
  619. * DAP_MAIN_CHAN_REG
  620. */
  621. #define SGTL5000_DAP_MAIN_CHAN_VOL_GET_MASK 0xFFFFU
  622. #define SGTL5000_DAP_MAIN_CHAN_VOL_CLR_MASK 0x0000U
  623. #define SGTL5000_DAP_MAIN_CHAN_VOL_SHIFT 0x0U
  624. /*
  625. * DAP_MIX_CHAN_REG
  626. */
  627. #define SGTL5000_DAP_MIX_CHAN_VOL_GET_MASK 0xFFFFU
  628. #define SGTL5000_DAP_MIX_CHAN_VOL_CLR_MASK 0x0000U
  629. #define SGTL5000_DAP_MIX_CHAN_VOL_SHIFT 0x0U
  630. /*
  631. * DAP_AVC_CTRL_REG
  632. */
  633. #define SGTL5000_DAP_AVC_CTRL_APOP_ENABLE_GET_MASK 0x4000U
  634. #define SGTL5000_DAP_AVC_CTRL_APOP_ENABLE_CLR_MASK 0xBFFFU
  635. #define SGTL5000_DAP_AVC_CTRL_APOP_ENABLE_SHIFT 0xEU
  636. #define SGTL5000_DAP_AVC_CTRL_MAX_GAIN_GET_MASK 0x3000U
  637. #define SGTL5000_DAP_AVC_CTRL_MAX_GAIN_CLR_MASK 0xCFFFU
  638. #define SGTL5000_DAP_AVC_CTRL_MAX_GAIN_SHIFT 0xCU
  639. #define SGTL5000_DAP_AVC_CTRL_LBI_RESPONSE_GET_MASK 0x0300U
  640. #define SGTL5000_DAP_AVC_CTRL_LBI_RESPONSE_CLR_MASK 0xFCFFU
  641. #define SGTL5000_DAP_AVC_CTRL_LBI_RESPONSE_SHIFT 0x8U
  642. #define SGTL5000_DAP_AVC_CTRL_HARD_LIMIT_EN_GET_MASK 0x0020U
  643. #define SGTL5000_DAP_AVC_CTRL_HARD_LIMIT_EN_CLR_MASK 0xFFDFU
  644. #define SGTL5000_DAP_AVC_CTRL_HARD_LIMIT_EN_SHIFT 0x5U
  645. #define SGTL5000_DAP_AVC_CTRL_STOP_GET_MASK 0x0004U
  646. #define SGTL5000_DAP_AVC_CTRL_STOP_SHIFT 0x2U
  647. #define SGTL5000_DAP_AVC_CTRL_RUNNING_GET_MASK 0x0002U
  648. #define SGTL5000_DAP_AVC_CTRL_RUNNING_SHIFT 0x1U
  649. #define SGTL5000_DAP_AVC_CTRL_EN_GET_MASK 0x0001U
  650. #define SGTL5000_DAP_AVC_CTRL_EN_CLR_MASK 0xFFFEU
  651. #define SGTL5000_DAP_AVC_CTRL_EN_SHIFT 0x0U
  652. /*
  653. * DAP_AVC_ATTACK_REG
  654. */
  655. #define SGTL5000_DAP_AVC_ATTACK_RATE_GET_MASK 0x0FFFU
  656. #define SGTL5000_DAP_AVC_ATTACK_RATE_CLR_MASK 0xF000U
  657. #define SGTL5000_DAP_AVC_ATTACK_RATE_SHIFT 0x0U
  658. /*
  659. * DAP_AVC_DECAY_REG
  660. */
  661. #define SGTL5000_DAP_AVC_DECAY_RATE_GET_MASK 0x0FFFU
  662. #define SGTL5000_DAP_AVC_DECAY_RATE_CLR_MASK 0xF000U
  663. #define SGTL5000_DAP_AVC_DECAY_RATE_SHIFT 0x0U
  664. /*
  665. * DAP_COEF_WR_B1_LSB_REG
  666. */
  667. #define SGTL5000_DAP_COEF_WR_B1_LSB_LSB_GET_MASK 0x000FU
  668. #define SGTL5000_DAP_COEF_WR_B1_LSB_LSB_CLR_MASK 0xFFF0U
  669. #define SGTL5000_DAP_COEF_WR_B1_LSB_LSB_SHIFT 0x0U
  670. /*
  671. * DAP_COEF_WR_B2_LSB_REG
  672. */
  673. #define SGTL5000_DAP_COEF_WR_B2_LSB_LSB_GET_MASK 0x000FU
  674. #define SGTL5000_DAP_COEF_WR_B2_LSB_LSB_CLR_MASK 0xFFF0U
  675. #define SGTL5000_DAP_COEF_WR_B2_LSB_LSB_SHIFT 0x0U
  676. /*
  677. * DAP_COEF_WR_A1_LSB_REG
  678. */
  679. #define SGTL5000_DAP_COEF_WR_A1_LSB_LSB_GET_MASK 0x000FU
  680. #define SGTL5000_DAP_COEF_WR_A1_LSB_LSB_CLR_MASK 0xFFF0U
  681. #define SGTL5000_DAP_COEF_WR_A1_LSB_LSB_SHIFT 0x0U
  682. /*
  683. * DAP_COEF_WR_A2_LSB_REG
  684. */
  685. #define SGTL5000_DAP_COEF_WR_A2_LSB_LSB_GET_MASK 0x000FU
  686. #define SGTL5000_DAP_COEF_WR_A2_LSB_LSB_CLR_MASK 0xFFF0U
  687. #define SGTL5000_DAP_COEF_WR_A2_LSB_LSB_SHIFT 0x0U
  688. /*! @brief SGTL5000 volume setting range */
  689. #define SGTL5000_HEADPHONE_MAX_VOLUME_VALUE 0x7FU
  690. #define SGTL5000_HEADPHONE_MIN_VOLUME_VALUE 0U
  691. #define SGTL5000_LINE_OUT_MAX_VOLUME_VALUE 0x1FU
  692. #define SGTL5000_LINE_OUT_MIN_VOLUME_VALUE 0U
  693. #define SGTL5000_ADC_MAX_VOLUME_VALUE 0xFU
  694. #define SGTL5000_ADC_MIN_VOLUME_VALUE 0U
  695. #define SGTL5000_DAC_MAX_VOLUME_VALUE 0xF0U
  696. #define SGTL5000_DAC_MIN_VOLUME_VALUE 0x3CU
  697. /*! @brief SGTL5000 I2C address. */
  698. #define SGTL5000_I2C_ADDR 0x0A
  699. /*! @brief sgtl i2c baudrate */
  700. #define SGTL_I2C_BITRATE 100000U
  701. /*! @brief Modules in Sgtl5000 board. */
  702. typedef enum _sgtl5000_module
  703. {
  704. sgtl_module_adc = 0x0, /*!< ADC module in SGTL5000 */
  705. sgtl_module_dac, /*!< DAC module in SGTL5000 */
  706. sgtl_module_dap, /*!< DAP module in SGTL5000 */
  707. sgtl_module_hp, /*!< Headphone module in SGTL5000 */
  708. sgtl_module_i2sin, /*!< I2S-IN module in SGTL5000 */
  709. sgtl_module_i2sout, /*!< I2S-OUT module in SGTL5000 */
  710. sgtl_module_linein, /*!< Line-in moudle in SGTL5000 */
  711. sgtl_module_lineout, /*!< Line-out module in SGTL5000 */
  712. sgtl_module_micin /*!< Micphone module in SGTL5000 */
  713. } sgtl_module_t;
  714. /*!
  715. * @brief Sgtl5000 data route.
  716. * @note Only provide some typical data route, not all route listed.
  717. * Users cannot combine any routes, once a new route is set, the precios one would be replaced.
  718. */
  719. typedef enum _sgtl_route
  720. {
  721. sgtl_route_bypass = 0x0, /*!< LINEIN->Headphone. */
  722. sgtl_route_playback, /*!< I2SIN->DAC->Headphone. */
  723. sgtl_route_playback_record, /*!< I2SIN->DAC->Headphone, LINEIN->ADC->I2SOUT. */
  724. sgtl_route_playback_with_dap, /*!< I2SIN->DAP->DAC->Headphone. */
  725. sgtl_route_playback_with_dap_record, /*!< I2SIN->DAP->DAC->HP, LINEIN->ADC->I2SOUT. */
  726. sgtl_route_record /*!< LINEIN->ADC->I2SOUT. */
  727. } sgtl_route_t;
  728. /*!
  729. * @brief The audio data transfer protocol choice.
  730. * Sgtl5000 only supports I2S format and PCM format.
  731. */
  732. typedef enum _sgtl_protocol
  733. {
  734. sgtl_bus_i2s = 0x0, /*!< I2S Type */
  735. sgtl_bus_left_justified, /*!< Left justified */
  736. sgtl_bus_right_justified, /*!< Right Justified */
  737. sgtl_bus_pcma, /*!< PCMA */
  738. sgtl_bus_pcmb /*!< PCMB */
  739. } sgtl_protocol_t;
  740. /*! @brief sgtl play channel
  741. * @anchor _sgtl_play_channel
  742. */
  743. enum
  744. {
  745. sgtl_headphone_left = 0, /*!< headphone left channel */
  746. sgtl_headphone_right = 1, /*!< headphone right channel */
  747. sgtl_lineout_left = 2, /*!< lineout left channel */
  748. sgtl_lineout_right = 3, /*!< lineout right channel */
  749. };
  750. /*! @brief sgtl record source
  751. * _sgtl_record_source
  752. */
  753. enum
  754. {
  755. sgtl_record_source_linein = 0U, /*!< record source line in */
  756. sgtl_record_source_mic = 1U, /*!< record source single end */
  757. };
  758. /*! @brief sgtl play source
  759. * _stgl_play_source
  760. */
  761. enum
  762. {
  763. sgtl_play_source_linein = 0U, /*!< play source line in */
  764. sgtl_play_source_dac = 1U, /*!< play source line in */
  765. };
  766. /*! @brief SGTL SCLK valid edge */
  767. typedef enum _sgtl_sclk_edge
  768. {
  769. sgtl_sclk_valid_edge_rising = 0U, /*!< SCLK valid edge */
  770. sgtl_sclk_valid_edge_failing = 1U, /*!< SCLK failling edge */
  771. } sgtl_sclk_edge_t;
  772. /*! @brief Audio format configuration. */
  773. typedef struct _sgtl_audio_format
  774. {
  775. uint32_t mclk_hz; /*!< master clock */
  776. uint32_t sample_rate; /*!< Sample rate */
  777. uint32_t bit_width; /*!< Bit width */
  778. sgtl_sclk_edge_t sclk_edge; /*!< sclk valid edge */
  779. } sgtl_audio_format_t;
  780. /*! @brief Initailize structure of sgtl5000 */
  781. typedef struct _sgtl_config
  782. {
  783. sgtl_route_t route; /*!< Audio data route.*/
  784. sgtl_protocol_t bus; /*!< Audio transfer protocol */
  785. bool master; /*!< Master or slave. True means master, false means slave. */
  786. sgtl_audio_format_t format; /*!< audio format */
  787. } sgtl_config_t;
  788. typedef struct
  789. {
  790. struct rt_i2c_bus_device *i2c_bus; /* I2C bus device */
  791. uint8_t slave_address; /*!< code device slave address */
  792. } sgtl_context_t;
  793. /*******************************************************************************
  794. * API
  795. ******************************************************************************/
  796. #if defined(__cplusplus)
  797. extern "C" {
  798. #endif
  799. /*!
  800. * @brief sgtl5000 initialize function.
  801. *
  802. * In this function, some configurations are fixed.
  803. * The second parameter can be NULL. If users want to change the SGTL5000 settings,
  804. * a configure structure should be prepared.
  805. * @note If the codec_config is NULL, it would initialize sgtl5000 using default settings.
  806. * The default setting:
  807. * @code
  808. * sgtl_init_t codec_config
  809. * codec_config.route = sgtl_route_playback_record
  810. * codec_config.bus = sgtl_bus_i2s
  811. * codec_config.master = slave
  812. * @endcode
  813. *
  814. * @param context Sgtl5000 context structure.
  815. * @param config sgtl5000 configuration structure. If this pointer equals to NULL,
  816. * it means using the default configuration.
  817. * @return Initialization status
  818. */
  819. hpm_stat_t sgtl_init(sgtl_context_t *context, sgtl_config_t *config);
  820. /*!
  821. * @brief Set audio data route in sgtl5000.
  822. *
  823. * This function would set the data route according to route. The route cannot be combined,
  824. * as all route would enable different modules.
  825. *
  826. * @note If a new route is set, the previous route would not work.
  827. * @param context Sgtl5000 context structure.
  828. * @param route Audio data route in sgtl5000.
  829. */
  830. hpm_stat_t sgtl_set_data_route(sgtl_context_t *context, sgtl_route_t route);
  831. /*!
  832. * @brief Set the audio transfer protocol.
  833. *
  834. * Sgtl5000 only supports I2S, I2S left, I2S right, PCM A, PCM B format.
  835. * @param context Sgtl5000 context structure.
  836. * @param protocol Audio data transfer protocol.
  837. */
  838. hpm_stat_t sgtl_set_protocol(sgtl_context_t *context, sgtl_protocol_t protocol);
  839. /*!
  840. * @brief Set sgtl5000 as master or slave.
  841. *
  842. * @param context Sgtl5000 context structure.
  843. * @param master 1 represent master, 0 represent slave.
  844. */
  845. void sgtl_set_master_mode(sgtl_context_t *context, bool master);
  846. /*!
  847. * @brief Set the volume of different modules in sgtl5000.
  848. *
  849. * This function would set the volume of sgtl5000 modules. This interface set module volume.
  850. * The function assume that left channel and right channel has the same volume.
  851. *
  852. * sgtl_module_adc volume range: 0 - 0xF, 0dB - 22.5dB
  853. * sgtl_module_dac volume range: 0x3C - 0xF0, 0dB - -90dB
  854. * sgtl_module_hp volume range: 0 - 0x7F, 12dB - -51.5dB
  855. * sgtl_module_lineout volume range: 0 - 0x1F, 0.5dB steps
  856. *
  857. * @param context Sgtl5000 context structure.
  858. * @param module Sgtl5000 module, such as DAC, ADC and etc.
  859. * @param volume Volume value need to be set. The value is the exact value in register.
  860. */
  861. hpm_stat_t sgtl_set_volume(sgtl_context_t *context, sgtl_module_t module, uint32_t volume);
  862. /*!
  863. * @brief Get the volume of different modules in sgtl5000.
  864. *
  865. * This function gets the volume of sgtl5000 modules. This interface get DAC module volume.
  866. * The function assume that left channel and right channel has the same volume.
  867. * @param context Sgtl5000 context structure.
  868. * @param module Sgtl5000 module, such as DAC, ADC and etc.
  869. * @return Module value, the value is exact value in register.
  870. */
  871. uint32_t sgtl_get_volume(sgtl_context_t *context, sgtl_module_t module);
  872. /*!
  873. * @brief Mute/unmute modules in sgtl5000.
  874. *
  875. * @param context Sgtl5000 context structure.
  876. * @param module Sgtl5000 module, such as DAC, ADC and etc.
  877. * @param mute True means mute, and false means unmute.
  878. */
  879. hpm_stat_t sgtl_set_mute(sgtl_context_t *context, sgtl_module_t module, bool mute);
  880. /*!
  881. * @brief Enable expected devices.
  882. * @param context Sgtl5000 context structure.
  883. * @param module Module expected to enable.
  884. */
  885. hpm_stat_t sgtl_enable_module(sgtl_context_t *context, sgtl_module_t module);
  886. /*!
  887. * @brief Disable expected devices.
  888. * @param context Sgtl5000 context structure.
  889. * @param module Module expected to enable.
  890. */
  891. hpm_stat_t sgtl_disable_module(sgtl_context_t *context, sgtl_module_t module);
  892. /*!
  893. * @brief Deinit the sgtl5000 codec. Shut down Sgtl5000 modules.
  894. * @param context Sgtl5000 context structure pointer.
  895. */
  896. hpm_stat_t sgtl_deint(sgtl_context_t *context);
  897. /*!
  898. * @brief Configure the data format of audio data.
  899. *
  900. * This function would configure the registers about the sample rate, bit depths.
  901. * @param context Sgtl5000 context structure pointer.
  902. * @param mclk Master clock frequency of I2S.
  903. * @param sample_rate Sample rate of audio file running in sgtl5000. Sgtl5000 now
  904. * supports 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k, 44.1k, 48k and 96k sample rate.
  905. * @param bits Bit depth of audio file (Sgtl5000 only supports 16bit, 20bit, 24bit
  906. * and 32 bit in HW).
  907. */
  908. hpm_stat_t sgtl_config_data_format(sgtl_context_t *context, uint32_t mclk, uint32_t sample_rate, uint32_t bits);
  909. /*!
  910. * @brief select SGTL codec play source.
  911. *
  912. * @param context Sgtl5000 context structure pointer.
  913. * @param playSource play source value, reference _sgtl_play_source.
  914. *
  915. * @return kStatus_Success, else failed.
  916. */
  917. hpm_stat_t sgtl_set_play(sgtl_context_t *context, uint32_t playSource);
  918. /*!
  919. * @brief select SGTL codec record source.
  920. *
  921. * @param context Sgtl5000 context structure pointer.
  922. * @param recordSource record source value, reference _sgtl_record_source.
  923. *
  924. * @return kStatus_Success, else failed.
  925. */
  926. hpm_stat_t sgtl_set_record(sgtl_context_t *context, uint32_t recordSource);
  927. /*!
  928. * @brief Write register to sgtl using I2C.
  929. * @param context Sgtl5000 context structure.
  930. * @param reg The register address in sgtl.
  931. * @param val Value needs to write into the register.
  932. */
  933. hpm_stat_t sgtl_write_reg(sgtl_context_t *context, uint16_t reg, uint16_t val);
  934. /*!
  935. * @brief Read register from sgtl using I2C.
  936. * @param context Sgtl5000 context structure.
  937. * @param reg The register address in sgtl.
  938. * @param val Value written to.
  939. */
  940. hpm_stat_t sgtl_read_reg(sgtl_context_t *context, uint16_t reg, uint16_t *val);
  941. /*!
  942. * @brief Modify some bits in the register using I2C.
  943. * @param context Sgtl5000 context structure.
  944. * @param reg The register address in sgtl.
  945. * @param clr_mask The mask code for the bits want to write. The bit you want to write should be 0.
  946. * @param val Value needs to write into the register.
  947. */
  948. hpm_stat_t sgtl_modify_reg(sgtl_context_t *context, uint16_t reg, uint16_t clr_mask, uint16_t val);
  949. #if defined(__cplusplus)
  950. }
  951. #endif
  952. /*! @} */
  953. #endif /* _HPM_SGTL5000_H_ */