hpm_sgtl5000.h 39 KB

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