wcd934x.h 5.2 KB

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