wm8994.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * wm8994.h -- WM8994 Soc Audio driver
  4. */
  5. #ifndef _WM8994_H
  6. #define _WM8994_H
  7. #include <linux/clk.h>
  8. #include <sound/soc.h>
  9. #include <linux/firmware.h>
  10. #include <linux/completion.h>
  11. #include <linux/workqueue.h>
  12. #include <linux/mutex.h>
  13. #include "wm_hubs.h"
  14. enum {
  15. WM8994_MCLK1,
  16. WM8994_MCLK2,
  17. WM8994_NUM_MCLK
  18. };
  19. /* Sources for AIF1/2 SYSCLK - use with set_dai_sysclk() */
  20. #define WM8994_SYSCLK_MCLK1 1
  21. #define WM8994_SYSCLK_MCLK2 2
  22. #define WM8994_SYSCLK_FLL1 3
  23. #define WM8994_SYSCLK_FLL2 4
  24. /* OPCLK is also configured with set_dai_sysclk, specify division*10 as rate. */
  25. #define WM8994_SYSCLK_OPCLK 5
  26. #define WM8994_FLL1 1
  27. #define WM8994_FLL2 2
  28. #define WM8994_FLL_SRC_MCLK1 1
  29. #define WM8994_FLL_SRC_MCLK2 2
  30. #define WM8994_FLL_SRC_LRCLK 3
  31. #define WM8994_FLL_SRC_BCLK 4
  32. #define WM8994_FLL_SRC_INTERNAL 5
  33. enum wm8994_vmid_mode {
  34. WM8994_VMID_NORMAL,
  35. WM8994_VMID_FORCE,
  36. };
  37. typedef void (*wm1811_micdet_cb)(void *data);
  38. typedef void (*wm1811_mic_id_cb)(void *data, u16 status);
  39. int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
  40. int micbias);
  41. int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
  42. wm1811_micdet_cb cb, void *det_cb_data,
  43. wm1811_mic_id_cb id_cb, void *id_cb_data);
  44. int wm8994_vmid_mode(struct snd_soc_component *component, enum wm8994_vmid_mode mode);
  45. int wm8958_aif_ev(struct snd_soc_dapm_widget *w,
  46. struct snd_kcontrol *kcontrol, int event);
  47. void wm8958_dsp2_init(struct snd_soc_component *component);
  48. struct wm8994_micdet {
  49. struct snd_soc_jack *jack;
  50. bool detecting;
  51. };
  52. /* codec private data */
  53. struct wm8994_fll_config {
  54. int src;
  55. int in;
  56. int out;
  57. };
  58. #define WM8994_NUM_DRC 3
  59. #define WM8994_NUM_EQ 3
  60. struct wm8994;
  61. struct wm8994_priv {
  62. struct wm_hubs_data hubs;
  63. struct wm8994 *wm8994;
  64. struct clk_bulk_data mclk[WM8994_NUM_MCLK];
  65. int sysclk[2];
  66. int sysclk_rate[2];
  67. int mclk_rate[2];
  68. int aifclk[2];
  69. int aifdiv[2];
  70. int channels[2];
  71. struct wm8994_fll_config fll[2], fll_suspend[2];
  72. struct completion fll_locked[2];
  73. bool fll_locked_irq;
  74. bool fll_byp;
  75. bool clk_has_run;
  76. int vmid_refcount;
  77. int active_refcount;
  78. enum wm8994_vmid_mode vmid_mode;
  79. int dac_rates[2];
  80. int lrclk_shared[2];
  81. int mbc_ena[3];
  82. int hpf1_ena[3];
  83. int hpf2_ena[3];
  84. int vss_ena[3];
  85. int enh_eq_ena[3];
  86. /* Platform dependant DRC configuration */
  87. const char **drc_texts;
  88. int drc_cfg[WM8994_NUM_DRC];
  89. struct soc_enum drc_enum;
  90. /* Platform dependant ReTune mobile configuration */
  91. int num_retune_mobile_texts;
  92. const char **retune_mobile_texts;
  93. int retune_mobile_cfg[WM8994_NUM_EQ];
  94. struct soc_enum retune_mobile_enum;
  95. /* Platform dependant MBC configuration */
  96. int mbc_cfg;
  97. const char **mbc_texts;
  98. struct soc_enum mbc_enum;
  99. /* Platform dependant VSS configuration */
  100. int vss_cfg;
  101. const char **vss_texts;
  102. struct soc_enum vss_enum;
  103. /* Platform dependant VSS HPF configuration */
  104. int vss_hpf_cfg;
  105. const char **vss_hpf_texts;
  106. struct soc_enum vss_hpf_enum;
  107. /* Platform dependant enhanced EQ configuration */
  108. int enh_eq_cfg;
  109. const char **enh_eq_texts;
  110. struct soc_enum enh_eq_enum;
  111. struct mutex accdet_lock;
  112. struct wm8994_micdet micdet[2];
  113. struct delayed_work mic_work;
  114. struct delayed_work open_circuit_work;
  115. struct delayed_work mic_complete_work;
  116. u16 mic_status;
  117. bool mic_detecting;
  118. bool jack_mic;
  119. int btn_mask;
  120. bool jackdet;
  121. int jackdet_mode;
  122. struct delayed_work jackdet_bootstrap;
  123. int micdet_irq;
  124. wm1811_micdet_cb micd_cb;
  125. void *micd_cb_data;
  126. wm1811_mic_id_cb mic_id_cb;
  127. void *mic_id_cb_data;
  128. unsigned int aif1clk_enable:1;
  129. unsigned int aif2clk_enable:1;
  130. unsigned int aif1clk_disable:1;
  131. unsigned int aif2clk_disable:1;
  132. struct mutex fw_lock;
  133. int dsp_active;
  134. const struct firmware *cur_fw;
  135. const struct firmware *mbc;
  136. const struct firmware *mbc_vss;
  137. const struct firmware *enh_eq;
  138. };
  139. #endif