wcd9335.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (c) 2015-2017, 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 WCD9335_H
  14. #define WCD9335_H
  15. #include <sound/soc.h>
  16. #include <sound/jack.h>
  17. #include <dsp/apr_audio-v2.h>
  18. #include "wcd9xxx-slimslave.h"
  19. #include "wcd-mbhc-v2.h"
  20. #define TASHA_REG_VAL(reg, val) {reg, 0, val}
  21. #define TASHA_REGISTER_START_OFFSET 0x800
  22. #define TASHA_SB_PGD_PORT_RX_BASE 0x40
  23. #define TASHA_SB_PGD_PORT_TX_BASE 0x50
  24. #define TASHA_ZDET_SUPPORTED true
  25. /* z value defined in milliohm */
  26. #define TASHA_ZDET_VAL_32 32000
  27. #define TASHA_ZDET_VAL_400 400000
  28. #define TASHA_ZDET_VAL_1200 1200000
  29. #define TASHA_ZDET_VAL_100K 100000000
  30. /* z floating defined in ohms */
  31. #define TASHA_ZDET_FLOATING_IMPEDANCE 0x0FFFFFFE
  32. #define WCD9335_DMIC_CLK_DIV_2 0x0
  33. #define WCD9335_DMIC_CLK_DIV_3 0x1
  34. #define WCD9335_DMIC_CLK_DIV_4 0x2
  35. #define WCD9335_DMIC_CLK_DIV_6 0x3
  36. #define WCD9335_DMIC_CLK_DIV_8 0x4
  37. #define WCD9335_DMIC_CLK_DIV_16 0x5
  38. #define WCD9335_DMIC_CLK_DRIVE_DEFAULT 0x02
  39. #define WCD9335_ANC_DMIC_X2_FULL_RATE 1
  40. #define WCD9335_ANC_DMIC_X2_HALF_RATE 0
  41. /* Number of input and output Slimbus port */
  42. enum {
  43. TASHA_RX0 = 0,
  44. TASHA_RX1,
  45. TASHA_RX2,
  46. TASHA_RX3,
  47. TASHA_RX4,
  48. TASHA_RX5,
  49. TASHA_RX6,
  50. TASHA_RX7,
  51. TASHA_RX8,
  52. TASHA_RX9,
  53. TASHA_RX10,
  54. TASHA_RX11,
  55. TASHA_RX12,
  56. TASHA_RX_MAX,
  57. };
  58. enum {
  59. TASHA_TX0 = 0,
  60. TASHA_TX1,
  61. TASHA_TX2,
  62. TASHA_TX3,
  63. TASHA_TX4,
  64. TASHA_TX5,
  65. TASHA_TX6,
  66. TASHA_TX7,
  67. TASHA_TX8,
  68. TASHA_TX9,
  69. TASHA_TX10,
  70. TASHA_TX11,
  71. TASHA_TX12,
  72. TASHA_TX13,
  73. TASHA_TX14,
  74. TASHA_TX15,
  75. TASHA_TX_MAX,
  76. };
  77. enum wcd9335_codec_event {
  78. WCD9335_CODEC_EVENT_CODEC_UP = 0,
  79. };
  80. enum tasha_on_demand_supply {
  81. ON_DEMAND_MICBIAS = 0,
  82. ON_DEMAND_SUPPLIES_MAX,
  83. };
  84. /* structure used to put the defined
  85. * ondemand supply for codec
  86. * and count being used.
  87. */
  88. struct on_demand_supply {
  89. struct regulator *supply;
  90. int ondemand_supply_count;
  91. };
  92. /* Dai data structure holds the
  93. * dai specific info like rate,
  94. * channel number etc.
  95. */
  96. struct tasha_codec_dai_data {
  97. u32 rate;
  98. u32 *ch_num;
  99. u32 ch_act;
  100. u32 ch_tot;
  101. };
  102. /* Structure used to update codec
  103. * register defaults after reset
  104. */
  105. struct tasha_reg_mask_val {
  106. u16 reg;
  107. u8 mask;
  108. u8 val;
  109. };
  110. /* Selects compander and smart boost settings
  111. * for a given speaker mode
  112. */
  113. enum {
  114. SPKR_MODE_DEFAULT,
  115. SPKR_MODE_1, /* COMP Gain = 12dB, Smartboost Max = 5.5V */
  116. };
  117. /*
  118. * Rx path gain offsets
  119. */
  120. enum {
  121. RX_GAIN_OFFSET_M1P5_DB,
  122. RX_GAIN_OFFSET_0_DB,
  123. };
  124. extern void *tasha_get_afe_config(struct snd_soc_codec *codec,
  125. enum afe_config_type config_type);
  126. extern int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable,
  127. bool dapm);
  128. extern int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable,
  129. bool dapm);
  130. extern int tasha_enable_efuse_sensing(struct snd_soc_codec *codec);
  131. extern int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  132. struct wcd_mbhc_config *mbhc_cfg);
  133. extern void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
  134. extern void tasha_mbhc_zdet_gpio_ctrl(
  135. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  136. struct snd_soc_codec *codec);
  137. extern int tasha_codec_info_create_codec_entry(
  138. struct snd_info_entry *codec_root,
  139. struct snd_soc_codec *codec);
  140. extern void tasha_event_register(
  141. int (*machine_event_cb)(struct snd_soc_codec *codec,
  142. enum wcd9335_codec_event),
  143. struct snd_soc_codec *codec);
  144. extern int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
  145. int micb_num,
  146. bool enable);
  147. extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode);
  148. extern int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
  149. extern enum codec_variant tasha_codec_ver(void);
  150. #endif