wcd9335.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef WCD9335_H
  6. #define WCD9335_H
  7. #include <sound/soc.h>
  8. #include <sound/jack.h>
  9. #include <dsp/apr_audio-v2.h>
  10. #include <asoc/wcd9xxx-slimslave.h>
  11. #include <asoc/wcd-mbhc-v2.h>
  12. #define TASHA_REG_VAL(reg, val) {reg, 0, val}
  13. #define TASHA_REGISTER_START_OFFSET 0x800
  14. #define TASHA_SB_PGD_PORT_RX_BASE 0x40
  15. #define TASHA_SB_PGD_PORT_TX_BASE 0x50
  16. #define TASHA_ZDET_SUPPORTED true
  17. /* z value defined in milliohm */
  18. #define TASHA_ZDET_VAL_32 32000
  19. #define TASHA_ZDET_VAL_400 400000
  20. #define TASHA_ZDET_VAL_1200 1200000
  21. #define TASHA_ZDET_VAL_100K 100000000
  22. /* z floating defined in ohms */
  23. #define TASHA_ZDET_FLOATING_IMPEDANCE 0x0FFFFFFE
  24. #define WCD9335_DMIC_CLK_DIV_2 0x0
  25. #define WCD9335_DMIC_CLK_DIV_3 0x1
  26. #define WCD9335_DMIC_CLK_DIV_4 0x2
  27. #define WCD9335_DMIC_CLK_DIV_6 0x3
  28. #define WCD9335_DMIC_CLK_DIV_8 0x4
  29. #define WCD9335_DMIC_CLK_DIV_16 0x5
  30. #define WCD9335_DMIC_CLK_DRIVE_DEFAULT 0x02
  31. #define WCD9335_ANC_DMIC_X2_FULL_RATE 1
  32. #define WCD9335_ANC_DMIC_X2_HALF_RATE 0
  33. /* Number of input and output Slimbus port */
  34. enum {
  35. TASHA_RX0 = 0,
  36. TASHA_RX1,
  37. TASHA_RX2,
  38. TASHA_RX3,
  39. TASHA_RX4,
  40. TASHA_RX5,
  41. TASHA_RX6,
  42. TASHA_RX7,
  43. TASHA_RX8,
  44. TASHA_RX9,
  45. TASHA_RX10,
  46. TASHA_RX11,
  47. TASHA_RX12,
  48. TASHA_RX_MAX,
  49. };
  50. enum {
  51. TASHA_TX0 = 0,
  52. TASHA_TX1,
  53. TASHA_TX2,
  54. TASHA_TX3,
  55. TASHA_TX4,
  56. TASHA_TX5,
  57. TASHA_TX6,
  58. TASHA_TX7,
  59. TASHA_TX8,
  60. TASHA_TX9,
  61. TASHA_TX10,
  62. TASHA_TX11,
  63. TASHA_TX12,
  64. TASHA_TX13,
  65. TASHA_TX14,
  66. TASHA_TX15,
  67. TASHA_TX_MAX,
  68. };
  69. enum wcd9335_codec_event {
  70. WCD9335_CODEC_EVENT_CODEC_UP = 0,
  71. };
  72. enum tasha_on_demand_supply {
  73. ON_DEMAND_MICBIAS = 0,
  74. ON_DEMAND_TX_SUPPLY,
  75. ON_DEMAND_RX_SUPPLY,
  76. ON_DEMAND_SUPPLIES_MAX,
  77. };
  78. /* structure used to put the defined
  79. * ondemand supply for codec
  80. * and count being used.
  81. */
  82. struct on_demand_supply {
  83. struct regulator *supply;
  84. int ondemand_supply_count;
  85. };
  86. /* Dai data structure holds the
  87. * dai specific info like rate,
  88. * channel number etc.
  89. */
  90. struct tasha_codec_dai_data {
  91. u32 rate;
  92. u32 *ch_num;
  93. u32 ch_act;
  94. u32 ch_tot;
  95. };
  96. /* Structure used to update codec
  97. * register defaults after reset
  98. */
  99. struct tasha_reg_mask_val {
  100. u16 reg;
  101. u8 mask;
  102. u8 val;
  103. };
  104. /* Selects compander and smart boost settings
  105. * for a given speaker mode
  106. */
  107. enum {
  108. SPKR_MODE_DEFAULT,
  109. SPKR_MODE_1, /* COMP Gain = 12dB, Smartboost Max = 5.5V */
  110. };
  111. /*
  112. * Rx path gain offsets
  113. */
  114. enum {
  115. RX_GAIN_OFFSET_M1P5_DB,
  116. RX_GAIN_OFFSET_0_DB,
  117. };
  118. #if IS_ENABLED(CONFIG_SND_SOC_WCD9335)
  119. extern void *tasha_get_afe_config(struct snd_soc_component *component,
  120. enum afe_config_type config_type);
  121. extern int tasha_cdc_mclk_enable(struct snd_soc_component *component,
  122. int enable, bool dapm);
  123. extern int tasha_cdc_mclk_tx_enable(struct snd_soc_component *component,
  124. int enable, bool dapm);
  125. extern int tasha_enable_efuse_sensing(struct snd_soc_component *component);
  126. extern int tasha_mbhc_hs_detect(struct snd_soc_component *component,
  127. struct wcd_mbhc_config *mbhc_cfg);
  128. extern void tasha_mbhc_hs_detect_exit(struct snd_soc_component *component);
  129. extern void tasha_mbhc_zdet_gpio_ctrl(
  130. int (*zdet_gpio_cb)(struct snd_soc_component *component,
  131. bool high), struct snd_soc_component *component);
  132. extern int tasha_codec_info_create_codec_entry(
  133. struct snd_info_entry *codec_root,
  134. struct snd_soc_component *component);
  135. extern void tasha_event_register(
  136. int (*machine_event_cb)(struct snd_soc_component *component,
  137. enum wcd9335_codec_event),
  138. struct snd_soc_component *component);
  139. extern int tasha_codec_enable_standalone_micbias(
  140. struct snd_soc_component *component,
  141. int micb_num,
  142. bool enable);
  143. extern int tasha_set_spkr_mode(struct snd_soc_component *component, int mode);
  144. extern int tasha_set_spkr_gain_offset(struct snd_soc_component *component,
  145. int offset);
  146. extern enum codec_variant tasha_codec_ver(void);
  147. #else /* CONFIG_SND_SOC_WCD9335 */
  148. static inline void *tasha_get_afe_config(struct snd_soc_component *component,
  149. enum afe_config_type config_type)
  150. {
  151. return NULL;
  152. }
  153. static inline int tasha_cdc_mclk_enable(struct snd_soc_component *component,
  154. int enable,
  155. bool dapm)
  156. {
  157. return 0;
  158. }
  159. static inline int tasha_cdc_mclk_tx_enable(struct snd_soc_component *component,
  160. int enable,
  161. bool dapm)
  162. {
  163. return 0;
  164. }
  165. static inline int tasha_enable_efuse_sensing(
  166. struct snd_soc_component *component)
  167. {
  168. return 0;
  169. }
  170. static inline int tasha_mbhc_hs_detect(struct snd_soc_component *component,
  171. struct wcd_mbhc_config *mbhc_cfg)
  172. {
  173. return 0;
  174. }
  175. static inline void tasha_mbhc_hs_detect_exit(
  176. struct snd_soc_component *component)
  177. {
  178. }
  179. static inline void tasha_mbhc_zdet_gpio_ctrl(
  180. int (*zdet_gpio_cb)(struct snd_soc_component *component,
  181. bool high),
  182. struct snd_soc_component *component)
  183. {
  184. }
  185. static inline int tasha_codec_info_create_codec_entry(
  186. struct snd_info_entry *codec_root,
  187. struct snd_soc_component *component)
  188. {
  189. return 0;
  190. }
  191. static inline void tasha_event_register(
  192. int (*machine_event_cb)(struct snd_soc_component *component,
  193. enum wcd9335_codec_event),
  194. struct snd_soc_component *component)
  195. {
  196. }
  197. static inline int tasha_codec_enable_standalone_micbias(
  198. struct snd_soc_component *component,
  199. int micb_num,
  200. bool enable)
  201. {
  202. return 0;
  203. }
  204. static inline int tasha_set_spkr_mode(struct snd_soc_component *component,
  205. int mode)
  206. {
  207. return 0;
  208. }
  209. static inline int tasha_set_spkr_gain_offset(
  210. struct snd_soc_component *component,
  211. int offset)
  212. {
  213. return 0;
  214. }
  215. static inline enum codec_variant tasha_codec_ver(void)
  216. {
  217. return 0;
  218. }
  219. #endif /* CONFIG_SND_SOC_WCD9335 */
  220. #endif