wcd9360.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __WCD9360_H__
  14. #define __WCD9360_H__
  15. #include <dsp/apr_audio-v2.h>
  16. #include "../wcd9xxx-slimslave.h"
  17. #include "../wcd9xxx-common-v2.h"
  18. #define WCD9360_REGISTER_START_OFFSET 0x800
  19. #define WCD9360_SB_PGD_PORT_RX_BASE 0x40
  20. #define WCD9360_SB_PGD_PORT_TX_BASE 0x50
  21. #define WCD9360_RX_PORT_START_NUMBER 16
  22. #define WCD9360_DMIC_CLK_DIV_2 0x0
  23. #define WCD9360_DMIC_CLK_DIV_3 0x1
  24. #define WCD9360_DMIC_CLK_DIV_4 0x2
  25. #define WCD9360_DMIC_CLK_DIV_6 0x3
  26. #define WCD9360_DMIC_CLK_DIV_8 0x4
  27. #define WCD9360_DMIC_CLK_DIV_16 0x5
  28. #define WCD9360_DMIC_CLK_DRIVE_DEFAULT 0x02
  29. #define WCD9360_ANC_DMIC_X2_FULL_RATE 1
  30. #define WCD9360_ANC_DMIC_X2_HALF_RATE 0
  31. #define PAHU_MAX_MICBIAS 4
  32. #define PAHU_NUM_INTERPOLATORS 10
  33. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  34. /* Convert from vout ctl to micbias voltage in mV */
  35. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  36. /* Number of input and output Slimbus port */
  37. enum {
  38. WCD9360_RX0 = 0,
  39. WCD9360_RX1,
  40. WCD9360_RX2,
  41. WCD9360_RX3,
  42. WCD9360_RX4,
  43. WCD9360_RX5,
  44. WCD9360_RX6,
  45. WCD9360_RX7,
  46. WCD9360_RX_MAX,
  47. };
  48. enum {
  49. WCD9360_TX0 = 0,
  50. WCD9360_TX1,
  51. WCD9360_TX2,
  52. WCD9360_TX3,
  53. WCD9360_TX4,
  54. WCD9360_TX5,
  55. WCD9360_TX6,
  56. WCD9360_TX7,
  57. WCD9360_TX8,
  58. WCD9360_TX9,
  59. WCD9360_TX10,
  60. WCD9360_TX11,
  61. WCD9360_TX12,
  62. WCD9360_TX13,
  63. WCD9360_TX14,
  64. WCD9360_TX15,
  65. WCD9360_TX_MAX,
  66. };
  67. /*
  68. * Selects compander and smart boost settings
  69. * for a given speaker mode
  70. */
  71. enum {
  72. WCD9360_SPKR_MODE_DEFAULT,
  73. WCD9360_SPKR_MODE_1, /* COMP Gain = 12dB, Smartboost Max = 5.5V */
  74. };
  75. /*
  76. * Rx path gain offsets
  77. */
  78. enum {
  79. WCD9360_RX_GAIN_OFFSET_M1P5_DB,
  80. WCD9360_RX_GAIN_OFFSET_0_DB,
  81. };
  82. enum {
  83. WCD9360_MIC_BIAS_1 = 1,
  84. WCD9360_MIC_BIAS_2,
  85. WCD9360_MIC_BIAS_3,
  86. WCD9360_MIC_BIAS_4
  87. };
  88. enum {
  89. WCD9360_MICB_PULLUP_ENABLE,
  90. WCD9360_MICB_PULLUP_DISABLE,
  91. WCD9360_MICB_ENABLE,
  92. WCD9360_MICB_DISABLE,
  93. };
  94. /*
  95. * Dai data structure holds the
  96. * dai specific info like rate,
  97. * channel number etc.
  98. */
  99. struct pahu_codec_dai_data {
  100. u32 rate;
  101. u32 *ch_num;
  102. u32 ch_act;
  103. u32 ch_tot;
  104. };
  105. /*
  106. * Structure used to update codec
  107. * register defaults after reset
  108. */
  109. struct pahu_reg_mask_val {
  110. u16 reg;
  111. u8 mask;
  112. u8 val;
  113. };
  114. #if IS_ENABLED(CONFIG_SND_SOC_WCD9360)
  115. extern void *pahu_get_afe_config(struct snd_soc_codec *codec,
  116. enum afe_config_type config_type);
  117. extern int pahu_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable);
  118. extern int pahu_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable);
  119. extern int pahu_set_spkr_mode(struct snd_soc_codec *codec, int mode);
  120. extern int pahu_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
  121. extern void *pahu_get_wcd_dsp_cntl(struct device *dev);
  122. extern int wcd9360_get_micb_vout_ctl_val(u32 micb_mv);
  123. extern int pahu_codec_info_create_codec_entry(
  124. struct snd_info_entry *codec_root,
  125. struct snd_soc_codec *codec);
  126. #else
  127. extern void *pahu_get_afe_config(struct snd_soc_codec *codec,
  128. enum afe_config_type config_type)
  129. {
  130. return NULL;
  131. }
  132. extern int pahu_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable)
  133. {
  134. return 0;
  135. }
  136. extern int pahu_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable)
  137. {
  138. return 0;
  139. }
  140. extern int pahu_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  141. {
  142. return 0;
  143. }
  144. extern int pahu_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
  145. {
  146. return 0;
  147. }
  148. extern void *pahu_get_wcd_dsp_cntl(struct device *dev)
  149. {
  150. return NULL;
  151. }
  152. extern int wcd9360_get_micb_vout_ctl_val(u32 micb_mv)
  153. {
  154. return 0;
  155. }
  156. extern int pahu_codec_info_create_codec_entry(
  157. struct snd_info_entry *codec_root,
  158. struct snd_soc_codec *codec)
  159. {
  160. return 0;
  161. }
  162. #endif
  163. #endif