internal.h 3.8 KB

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