aqt1000.h 4.0 KB

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