wcd9335.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2015-2017, 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 "wcd9xxx-slimslave.h"
  11. #include "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_SUPPLIES_MAX,
  75. };
  76. /* structure used to put the defined
  77. * ondemand supply for codec
  78. * and count being used.
  79. */
  80. struct on_demand_supply {
  81. struct regulator *supply;
  82. int ondemand_supply_count;
  83. };
  84. /* Dai data structure holds the
  85. * dai specific info like rate,
  86. * channel number etc.
  87. */
  88. struct tasha_codec_dai_data {
  89. u32 rate;
  90. u32 *ch_num;
  91. u32 ch_act;
  92. u32 ch_tot;
  93. };
  94. /* Structure used to update codec
  95. * register defaults after reset
  96. */
  97. struct tasha_reg_mask_val {
  98. u16 reg;
  99. u8 mask;
  100. u8 val;
  101. };
  102. /* Selects compander and smart boost settings
  103. * for a given speaker mode
  104. */
  105. enum {
  106. SPKR_MODE_DEFAULT,
  107. SPKR_MODE_1, /* COMP Gain = 12dB, Smartboost Max = 5.5V */
  108. };
  109. /*
  110. * Rx path gain offsets
  111. */
  112. enum {
  113. RX_GAIN_OFFSET_M1P5_DB,
  114. RX_GAIN_OFFSET_0_DB,
  115. };
  116. #if IS_ENABLED(CONFIG_SND_SOC_WCD9335)
  117. extern void *tasha_get_afe_config(struct snd_soc_codec *codec,
  118. enum afe_config_type config_type);
  119. extern int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable,
  120. bool dapm);
  121. extern int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable,
  122. bool dapm);
  123. extern int tasha_enable_efuse_sensing(struct snd_soc_codec *codec);
  124. extern int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  125. struct wcd_mbhc_config *mbhc_cfg);
  126. extern void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
  127. extern void tasha_mbhc_zdet_gpio_ctrl(
  128. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  129. struct snd_soc_codec *codec);
  130. extern int tasha_codec_info_create_codec_entry(
  131. struct snd_info_entry *codec_root,
  132. struct snd_soc_codec *codec);
  133. extern void tasha_event_register(
  134. int (*machine_event_cb)(struct snd_soc_codec *codec,
  135. enum wcd9335_codec_event),
  136. struct snd_soc_codec *codec);
  137. extern int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
  138. int micb_num,
  139. bool enable);
  140. extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode);
  141. extern int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
  142. extern enum codec_variant tasha_codec_ver(void);
  143. #else /* CONFIG_SND_SOC_WCD9335 */
  144. static inline void *tasha_get_afe_config(struct snd_soc_codec *codec,
  145. enum afe_config_type config_type)
  146. {
  147. return NULL;
  148. }
  149. static inline int tasha_cdc_mclk_enable(struct snd_soc_codec *codec,
  150. int enable,
  151. bool dapm)
  152. {
  153. return 0;
  154. }
  155. static inline int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec,
  156. int enable,
  157. bool dapm)
  158. {
  159. return 0;
  160. }
  161. static inline int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
  162. {
  163. return 0;
  164. }
  165. static inline int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  166. struct wcd_mbhc_config *mbhc_cfg)
  167. {
  168. return 0;
  169. }
  170. static inline void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  171. {
  172. }
  173. static inline void tasha_mbhc_zdet_gpio_ctrl(
  174. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  175. struct snd_soc_codec *codec)
  176. {
  177. }
  178. static inline int tasha_codec_info_create_codec_entry(
  179. struct snd_info_entry *codec_root,
  180. struct snd_soc_codec *codec)
  181. {
  182. return 0;
  183. }
  184. static inline void tasha_event_register(
  185. int (*machine_event_cb)(struct snd_soc_codec *codec,
  186. enum wcd9335_codec_event),
  187. struct snd_soc_codec *codec)
  188. {
  189. }
  190. static inline int tasha_codec_enable_standalone_micbias(
  191. struct snd_soc_codec *codec,
  192. int micb_num,
  193. bool enable)
  194. {
  195. return 0;
  196. }
  197. static inline int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  198. {
  199. return 0;
  200. }
  201. static inline int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec,
  202. int offset)
  203. {
  204. return 0;
  205. }
  206. static inline enum codec_variant tasha_codec_ver(void)
  207. {
  208. return 0;
  209. }
  210. #endif /* CONFIG_SND_SOC_WCD9335 */
  211. #endif