internal.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  3. */
  4. #ifndef _WCD937X_INTERNAL_H
  5. #define _WCD937X_INTERNAL_H
  6. #include <asoc/wcd-clsh.h>
  7. #include <asoc/wcd-mbhc-v2.h>
  8. #include <asoc/wcd-irq.h>
  9. #include "wcd937x-mbhc.h"
  10. #include "wcd937x.h"
  11. #define WCD937X_MAX_MICBIAS 3
  12. /* Convert from vout ctl to micbias voltage in mV */
  13. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  14. #define MAX_PORT 8
  15. #define MAX_CH_PER_PORT 8
  16. #define MAX_TX_PWR_CH 2
  17. #define WCD937X_MAX_SLAVE_PORT_TYPES 10
  18. extern struct regmap_config wcd937x_regmap_config;
  19. struct codec_port_info {
  20. u32 slave_port_type;
  21. u32 master_port_type;
  22. u32 ch_mask;
  23. u32 num_ch;
  24. u32 ch_rate;
  25. };
  26. struct wcd937x_priv {
  27. struct device *dev;
  28. int variant;
  29. struct snd_soc_component *component;
  30. struct device_node *rst_np;
  31. struct regmap *regmap;
  32. struct swr_device *rx_swr_dev;
  33. struct swr_device *tx_swr_dev;
  34. s32 micb_ref[WCD937X_MAX_MICBIAS];
  35. s32 pullup_ref[WCD937X_MAX_MICBIAS];
  36. struct fw_info *fw_data;
  37. struct device_node *wcd_rst_np;
  38. struct mutex micb_lock;
  39. s32 dmic_0_1_clk_cnt;
  40. s32 dmic_2_3_clk_cnt;
  41. s32 dmic_4_5_clk_cnt;
  42. /* class h specific info */
  43. struct wcd_clsh_cdc_info clsh_info;
  44. /* mbhc module */
  45. struct wcd937x_mbhc *mbhc;
  46. u32 hph_mode;
  47. bool comp1_enable;
  48. bool comp2_enable;
  49. struct irq_domain *virq;
  50. struct wcd_irq_info irq_info;
  51. u32 rx_clk_cnt;
  52. int num_irq_regs;
  53. /* to track the status */
  54. unsigned long status_mask;
  55. u8 num_tx_ports;
  56. u8 num_rx_ports;
  57. struct codec_port_info
  58. tx_port_mapping[MAX_PORT][MAX_CH_PER_PORT];
  59. struct codec_port_info
  60. rx_port_mapping[MAX_PORT][MAX_CH_PER_PORT];
  61. struct regulator_bulk_data *supplies;
  62. struct notifier_block nblock;
  63. /* wcd callback to bolero */
  64. void *handle;
  65. int (*update_wcd_event)(void *handle, u16 event, u32 data);
  66. int (*register_notifier)(void *handle,
  67. struct notifier_block *nblock,
  68. bool enable);
  69. int (*wakeup)(void *handle, bool enable);
  70. u32 version;
  71. /* Entry for version info */
  72. struct snd_info_entry *entry;
  73. struct snd_info_entry *version_entry;
  74. /*Entry for Variant info*/
  75. struct snd_info_entry *variant_entry;
  76. int ear_rx_path;
  77. int ana_clk_count;
  78. struct mutex ana_tx_clk_lock;
  79. u8 tx_master_ch_map[WCD937X_MAX_SLAVE_CH_TYPES];
  80. bool usbc_hs_status;
  81. u32 tx_ch_pwr[MAX_TX_PWR_CH];
  82. };
  83. struct wcd937x_micbias_setting {
  84. u8 ldoh_v;
  85. u32 cfilt1_mv;
  86. u32 micb1_mv;
  87. u32 micb2_mv;
  88. u32 micb3_mv;
  89. u8 bias1_cfilt_sel;
  90. };
  91. struct wcd937x_pdata {
  92. struct device_node *rst_np;
  93. struct device_node *rx_slave;
  94. struct device_node *tx_slave;
  95. struct wcd937x_micbias_setting micbias;
  96. struct cdc_regulator *regulator;
  97. int num_supplies;
  98. };
  99. struct wcd_ctrl_platform_data {
  100. void *handle;
  101. int (*update_wcd_event)(void *handle, u16 event, u32 data);
  102. int (*register_notifier)(void *handle,
  103. struct notifier_block *nblock,
  104. bool enable);
  105. };
  106. enum {
  107. WCD_RX1,
  108. WCD_RX2,
  109. WCD_RX3
  110. };
  111. enum {
  112. BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR = 1,
  113. BOLERO_WCD_EVT_PA_OFF_PRE_SSR,
  114. BOLERO_WCD_EVT_SSR_DOWN,
  115. BOLERO_WCD_EVT_SSR_UP,
  116. };
  117. enum {
  118. WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
  119. WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */
  120. WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */
  121. WCD_BOLERO_EVT_RX_COMPANDER_SOFT_RST,
  122. WCD_BOLERO_EVT_BCS_CLK_OFF,
  123. };
  124. enum {
  125. /* INTR_CTRL_INT_MASK_0 */
  126. WCD937X_IRQ_MBHC_BUTTON_PRESS_DET = 0,
  127. WCD937X_IRQ_MBHC_BUTTON_RELEASE_DET,
  128. WCD937X_IRQ_MBHC_ELECT_INS_REM_DET,
  129. WCD937X_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  130. WCD937X_IRQ_MBHC_SW_DET,
  131. WCD937X_IRQ_HPHR_OCP_INT,
  132. WCD937X_IRQ_HPHR_CNP_INT,
  133. WCD937X_IRQ_HPHL_OCP_INT,
  134. /* INTR_CTRL_INT_MASK_1 */
  135. WCD937X_IRQ_HPHL_CNP_INT,
  136. WCD937X_IRQ_EAR_CNP_INT,
  137. WCD937X_IRQ_EAR_SCD_INT,
  138. WCD937X_IRQ_AUX_CNP_INT,
  139. WCD937X_IRQ_AUX_SCD_INT,
  140. WCD937X_IRQ_HPHL_PDM_WD_INT,
  141. WCD937X_IRQ_HPHR_PDM_WD_INT,
  142. WCD937X_IRQ_AUX_PDM_WD_INT,
  143. /* INTR_CTRL_INT_MASK_2 */
  144. WCD937X_IRQ_LDORT_SCD_INT,
  145. WCD937X_IRQ_MBHC_MOISTURE_INT,
  146. WCD937X_IRQ_HPHL_SURGE_DET_INT,
  147. WCD937X_IRQ_HPHR_SURGE_DET_INT,
  148. WCD937X_NUM_IRQS,
  149. };
  150. extern void wcd937x_disable_bcs_before_slow_insert(
  151. struct snd_soc_component *component,
  152. bool bcs_disable);
  153. extern struct wcd937x_mbhc *wcd937x_soc_get_mbhc(
  154. struct snd_soc_component *component);
  155. extern int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
  156. int volt, int micb_num);
  157. extern int wcd937x_get_micb_vout_ctl_val(u32 micb_mv);
  158. extern int wcd937x_micbias_control(struct snd_soc_component *component,
  159. int micb_num, int req, bool is_dapm);
  160. #endif