wcd934x.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef WCD934X_H
  6. #define WCD934X_H
  7. #include <dsp/apr_audio-v2.h>
  8. #include "wcd934x-dsp-cntl.h"
  9. #include "../wcd9xxx-slimslave.h"
  10. #include "../wcd9xxx-common-v2.h"
  11. #include "../wcd-mbhc-v2.h"
  12. #define WCD934X_REGISTER_START_OFFSET 0x800
  13. #define WCD934X_SB_PGD_PORT_RX_BASE 0x40
  14. #define WCD934X_SB_PGD_PORT_TX_BASE 0x50
  15. #define WCD934X_RX_PORT_START_NUMBER 16
  16. #define WCD934X_DMIC_CLK_DIV_2 0x0
  17. #define WCD934X_DMIC_CLK_DIV_3 0x1
  18. #define WCD934X_DMIC_CLK_DIV_4 0x2
  19. #define WCD934X_DMIC_CLK_DIV_6 0x3
  20. #define WCD934X_DMIC_CLK_DIV_8 0x4
  21. #define WCD934X_DMIC_CLK_DIV_16 0x5
  22. #define WCD934X_DMIC_CLK_DRIVE_DEFAULT 0x02
  23. #define WCD934X_ANC_DMIC_X2_FULL_RATE 1
  24. #define WCD934X_ANC_DMIC_X2_HALF_RATE 0
  25. #define TAVIL_MAX_MICBIAS 4
  26. #define TAVIL_NUM_INTERPOLATORS 9
  27. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  28. /* Convert from vout ctl to micbias voltage in mV */
  29. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  30. /* Feature masks to distinguish codec version */
  31. #define DSD_DISABLED_MASK 0
  32. #define SLNQ_DISABLED_MASK 1
  33. #define DSD_DISABLED (1 << DSD_DISABLED_MASK)
  34. #define SLNQ_DISABLED (1 << SLNQ_DISABLED_MASK)
  35. /* Number of input and output Slimbus port */
  36. enum {
  37. WCD934X_RX0 = 0,
  38. WCD934X_RX1,
  39. WCD934X_RX2,
  40. WCD934X_RX3,
  41. WCD934X_RX4,
  42. WCD934X_RX5,
  43. WCD934X_RX6,
  44. WCD934X_RX7,
  45. WCD934X_RX_MAX,
  46. };
  47. enum {
  48. WCD934X_TX0 = 0,
  49. WCD934X_TX1,
  50. WCD934X_TX2,
  51. WCD934X_TX3,
  52. WCD934X_TX4,
  53. WCD934X_TX5,
  54. WCD934X_TX6,
  55. WCD934X_TX7,
  56. WCD934X_TX8,
  57. WCD934X_TX9,
  58. WCD934X_TX10,
  59. WCD934X_TX11,
  60. WCD934X_TX12,
  61. WCD934X_TX13,
  62. WCD934X_TX14,
  63. WCD934X_TX15,
  64. WCD934X_TX_MAX,
  65. };
  66. enum {
  67. INTERP_EAR = 0,
  68. INTERP_HPHL,
  69. INTERP_HPHR,
  70. INTERP_LO1,
  71. INTERP_LO2,
  72. INTERP_LO3_NA, /* LO3 not avalible in Tavil*/
  73. INTERP_LO4_NA,
  74. INTERP_SPKR1,
  75. INTERP_SPKR2,
  76. INTERP_MAX,
  77. };
  78. /*
  79. * Selects compander and smart boost settings
  80. * for a given speaker mode
  81. */
  82. enum {
  83. WCD934X_SPKR_MODE_DEFAULT,
  84. WCD934X_SPKR_MODE_1, /* COMP Gain = 12dB, Smartboost Max = 5.5V */
  85. };
  86. /*
  87. * Rx path gain offsets
  88. */
  89. enum {
  90. WCD934X_RX_GAIN_OFFSET_M1P5_DB,
  91. WCD934X_RX_GAIN_OFFSET_0_DB,
  92. };
  93. /*
  94. * Dai data structure holds the
  95. * dai specific info like rate,
  96. * channel number etc.
  97. */
  98. struct tavil_codec_dai_data {
  99. u32 rate;
  100. u32 *ch_num;
  101. u32 ch_act;
  102. u32 ch_tot;
  103. };
  104. /*
  105. * Structure used to update codec
  106. * register defaults after reset
  107. */
  108. struct tavil_reg_mask_val {
  109. u16 reg;
  110. u8 mask;
  111. u8 val;
  112. };
  113. #if IS_ENABLED(CONFIG_SND_SOC_WCD934X)
  114. extern void *tavil_get_afe_config(struct snd_soc_codec *codec,
  115. enum afe_config_type config_type);
  116. extern int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable);
  117. extern int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable);
  118. extern int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode);
  119. extern int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
  120. extern struct wcd_dsp_cntl *tavil_get_wcd_dsp_cntl(struct device *dev);
  121. extern int wcd934x_get_micb_vout_ctl_val(u32 micb_mv);
  122. extern int tavil_micbias_control(struct snd_soc_codec *codec,
  123. int micb_num,
  124. int req, bool is_dapm);
  125. extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  126. int req_volt,
  127. int micb_num);
  128. extern struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec);
  129. extern int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
  130. int event, int intp_idx);
  131. extern struct tavil_dsd_config *tavil_get_dsd_config(
  132. struct snd_soc_codec *codec);
  133. extern int tavil_codec_info_create_codec_entry(
  134. struct snd_info_entry *codec_root,
  135. struct snd_soc_codec *codec);
  136. #else
  137. extern void *tavil_get_afe_config(struct snd_soc_codec *codec,
  138. enum afe_config_type config_type)
  139. {
  140. return NULL;
  141. }
  142. extern int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable)
  143. {
  144. return 0;
  145. }
  146. extern int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable)
  147. {
  148. return 0;
  149. }
  150. extern int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  151. {
  152. return 0;
  153. }
  154. extern int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
  155. {
  156. return 0;
  157. }
  158. extern struct wcd_dsp_cntl *tavil_get_wcd_dsp_cntl(struct device *dev)
  159. {
  160. return NULL;
  161. }
  162. extern int wcd934x_get_micb_vout_ctl_val(u32 micb_mv)
  163. {
  164. return 0;
  165. }
  166. extern int tavil_micbias_control(struct snd_soc_codec *codec,
  167. int micb_num,
  168. int req, bool is_dapm)
  169. {
  170. return 0;
  171. }
  172. extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  173. int req_volt,
  174. int micb_num)
  175. {
  176. return 0;
  177. }
  178. extern struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec)
  179. {
  180. return NULL;
  181. }
  182. extern int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
  183. int event, int intp_idx)
  184. {
  185. return 0;
  186. }
  187. extern struct tavil_dsd_config *tavil_get_dsd_config(
  188. struct snd_soc_codec *codec)
  189. {
  190. return NULL;
  191. }
  192. extern int tavil_codec_info_create_codec_entry(
  193. struct snd_info_entry *codec_root,
  194. struct snd_soc_codec *codec)
  195. {
  196. return 0;
  197. }
  198. #endif
  199. #endif