aqt1000.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  3. */
  4. #ifndef AQT1000_H
  5. #define AQT1000_H
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/of_device.h>
  9. #include <linux/i2c.h>
  10. #include "pdata.h"
  11. #include "aqt1000-clsh.h"
  12. #define AQT1000_MAX_MICBIAS 1
  13. #define AQT1000_NUM_INTERPOLATORS 2
  14. #define AQT1000_NUM_DECIMATORS 3
  15. #define AQT1000_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  16. #define AQT1000_RX_PATH_CTL_OFFSET 20
  17. #define AQT1000_CLK_24P576MHZ 24576000
  18. #define AQT1000_CLK_19P2MHZ 19200000
  19. #define AQT1000_CLK_12P288MHZ 12288000
  20. #define AQT1000_CLK_9P6MHZ 9600000
  21. #define AQT1000_ST_IIR_COEFF_MAX 5
  22. enum {
  23. AQT1000_RX0 = 0,
  24. AQT1000_RX1,
  25. AQT1000_RX_MAX,
  26. };
  27. enum {
  28. AQT_NONE,
  29. AQT_MCLK,
  30. AQT_RCO,
  31. };
  32. enum {
  33. AQT_TX0 = 0,
  34. AQT_TX1,
  35. };
  36. enum {
  37. ASRC0,
  38. ASRC1,
  39. ASRC_MAX,
  40. };
  41. /* Each IIR has 5 Filter Stages */
  42. enum {
  43. BAND1 = 0,
  44. BAND2,
  45. BAND3,
  46. BAND4,
  47. BAND5,
  48. BAND_MAX,
  49. };
  50. enum {
  51. AQT1000_TX0 = 0,
  52. AQT1000_TX1,
  53. AQT1000_TX2,
  54. AQT1000_TX_MAX,
  55. };
  56. enum {
  57. INTERP_HPHL,
  58. INTERP_HPHR,
  59. INTERP_MAX,
  60. };
  61. enum {
  62. INTERP_MAIN_PATH,
  63. INTERP_MIX_PATH,
  64. };
  65. enum {
  66. COMPANDER_1, /* HPH_L */
  67. COMPANDER_2, /* HPH_R */
  68. COMPANDER_MAX,
  69. };
  70. enum {
  71. AIF1_PB = 0,
  72. AIF1_CAP,
  73. NUM_CODEC_DAIS,
  74. };
  75. struct aqt_codec_dai_data {
  76. u32 rate;
  77. u32 *ch_num;
  78. u32 ch_act;
  79. u32 ch_tot;
  80. };
  81. struct aqt_idle_detect_config {
  82. u8 hph_idle_thr;
  83. u8 hph_idle_detect_en;
  84. };
  85. struct aqt1000_i2c {
  86. struct i2c_client *client;
  87. struct i2c_msg xfer_msg[2];
  88. struct mutex xfer_lock;
  89. int mod_id;
  90. };
  91. struct aqt1000_cdc_dai_data {
  92. u32 rate; /* sample rate */
  93. u32 bit_width; /* sit width 16,24,32 */
  94. struct list_head ch_list;
  95. wait_queue_head_t dai_wait;
  96. };
  97. struct tx_mute_work {
  98. struct aqt1000 *aqt;
  99. u8 decimator;
  100. struct delayed_work dwork;
  101. };
  102. struct hpf_work {
  103. struct aqt1000 *aqt;
  104. u8 decimator;
  105. u8 hpf_cut_off_freq;
  106. struct delayed_work dwork;
  107. };
  108. struct aqt1000 {
  109. struct device *dev;
  110. struct mutex io_lock;
  111. struct mutex xfer_lock;
  112. struct mutex reset_lock;
  113. struct device_node *aqt_rst_np;
  114. int (*read_dev)(struct aqt1000 *aqt, unsigned short reg,
  115. void *dest, int bytes);
  116. int (*write_dev)(struct aqt1000 *aqt, unsigned short reg,
  117. void *src, int bytes);
  118. u32 num_of_supplies;
  119. struct regulator_bulk_data *supplies;
  120. u32 mclk_rate;
  121. struct regmap *regmap;
  122. struct snd_soc_component *component;
  123. bool dev_up;
  124. bool prev_pg_valid;
  125. u8 prev_pg;
  126. struct aqt1000_i2c i2c_dev;
  127. /* Codec params */
  128. /* ANC related */
  129. u32 anc_slot;
  130. bool anc_func;
  131. /* compander */
  132. int comp_enabled[COMPANDER_MAX];
  133. /* class h specific data */
  134. struct aqt_clsh_cdc_data clsh_d;
  135. /* Interpolator Mode Select for HPH_L and HPH_R */
  136. u32 hph_mode;
  137. unsigned long status_mask;
  138. struct aqt1000_cdc_dai_data dai[NUM_CODEC_DAIS];
  139. struct mutex micb_lock;
  140. struct clk *ext_clk;
  141. /* mbhc module */
  142. struct aqt1000_mbhc *mbhc;
  143. struct mutex codec_mutex;
  144. /* cal info for codec */
  145. struct fw_info *fw_data;
  146. int native_clk_users;
  147. /* ASRC users count */
  148. int asrc_users[ASRC_MAX];
  149. int asrc_output_mode[ASRC_MAX];
  150. /* Main path clock users count */
  151. int main_clk_users[AQT1000_NUM_INTERPOLATORS];
  152. struct aqt_idle_detect_config idle_det_cfg;
  153. u32 rx_bias_count;
  154. s32 micb_ref;
  155. s32 pullup_ref;
  156. int master_bias_users;
  157. int mclk_users;
  158. int i2s_users;
  159. struct hpf_work tx_hpf_work[AQT1000_NUM_DECIMATORS];
  160. struct tx_mute_work tx_mute_dwork[AQT1000_NUM_DECIMATORS];
  161. struct mutex master_bias_lock;
  162. struct mutex cdc_bg_clk_lock;
  163. struct mutex i2s_lock;
  164. /* Interrupt */
  165. struct regmap_irq_chip_data *irq_chip;
  166. int num_irq_regs;
  167. struct irq_domain *virq;
  168. int irq;
  169. int irq_base;
  170. /* Entry for version info */
  171. struct snd_info_entry *entry;
  172. struct snd_info_entry *version_entry;
  173. };
  174. #endif /* AQT1000_H */