internal.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2020, The Linux Foundation. All rights reserved.
  3. */
  4. #ifndef _ROULEUR_INTERNAL_H
  5. #define _ROULEUR_INTERNAL_H
  6. #include <asoc/wcd-clsh.h>
  7. #include <asoc/wcd-mbhc-v2.h>
  8. #include <asoc/wcd-irq.h>
  9. #include "rouleur-mbhc.h"
  10. #define ROULEUR_MAX_MICBIAS 3
  11. /* Convert from vout ctl to micbias voltage in mV */
  12. #define WCD_VOUT_CTL_TO_MICB(v) (1600 + v * 50)
  13. #define MAX_PORT 8
  14. #define MAX_CH_PER_PORT 8
  15. extern struct regmap_config rouleur_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 rouleur_priv {
  24. struct device *dev;
  25. int variant;
  26. struct snd_soc_component *component;
  27. struct device_node *spmi_np;
  28. struct regmap *regmap;
  29. struct swr_device *rx_swr_dev;
  30. struct swr_device *tx_swr_dev;
  31. s32 micb_ref[ROULEUR_MAX_MICBIAS];
  32. s32 pullup_ref[ROULEUR_MAX_MICBIAS];
  33. struct fw_info *fw_data;
  34. struct mutex micb_lock;
  35. s32 dmic_0_1_clk_cnt;
  36. /* mbhc module */
  37. struct rouleur_mbhc *mbhc;
  38. bool comp1_enable;
  39. bool comp2_enable;
  40. bool dapm_bias_off;
  41. struct irq_domain *virq;
  42. struct wcd_irq_info irq_info;
  43. u32 rx_clk_cnt;
  44. int num_irq_regs;
  45. /* to track the status */
  46. unsigned long status_mask;
  47. u8 num_tx_ports;
  48. u8 num_rx_ports;
  49. struct codec_port_info
  50. tx_port_mapping[MAX_PORT][MAX_CH_PER_PORT];
  51. struct codec_port_info
  52. rx_port_mapping[MAX_PORT][MAX_CH_PER_PORT];
  53. struct regulator_bulk_data *supplies;
  54. struct notifier_block nblock;
  55. /* wcd callback to bolero */
  56. void *handle;
  57. int (*update_wcd_event)(void *handle, u16 event, u32 data);
  58. int (*register_notifier)(void *handle,
  59. struct notifier_block *nblock,
  60. bool enable);
  61. int (*wakeup)(void *handle, bool enable);
  62. u32 version;
  63. /* Entry for version info */
  64. struct snd_info_entry *entry;
  65. struct snd_info_entry *version_entry;
  66. struct device *spmi_dev;
  67. int reset_reg;
  68. int mbias_cnt;
  69. struct mutex rx_clk_lock;
  70. struct mutex main_bias_lock;
  71. bool dev_up;
  72. bool usbc_hs_status;
  73. struct notifier_block psy_nb;
  74. struct work_struct soc_eval_work;
  75. bool low_soc;
  76. int foundry_id_reg;
  77. int foundry_id;
  78. };
  79. struct rouleur_micbias_setting {
  80. u32 micb1_mv;
  81. u32 micb2_mv;
  82. u32 micb3_mv;
  83. };
  84. struct rouleur_pdata {
  85. struct device_node *spmi_np;
  86. struct device_node *rx_slave;
  87. struct device_node *tx_slave;
  88. struct rouleur_micbias_setting micbias;
  89. struct cdc_regulator *regulator;
  90. int num_supplies;
  91. int reset_reg;
  92. int foundry_id_reg;
  93. };
  94. struct wcd_ctrl_platform_data {
  95. void *handle;
  96. int (*update_wcd_event)(void *handle, u16 event, u32 data);
  97. int (*register_notifier)(void *handle,
  98. struct notifier_block *nblock,
  99. bool enable);
  100. };
  101. enum {
  102. WCD_RX1,
  103. WCD_RX2,
  104. WCD_RX3
  105. };
  106. enum {
  107. /* INTR_CTRL_INT_MASK_0 */
  108. ROULEUR_IRQ_MBHC_BUTTON_PRESS_DET = 0,
  109. ROULEUR_IRQ_MBHC_BUTTON_RELEASE_DET,
  110. ROULEUR_IRQ_MBHC_ELECT_INS_REM_DET,
  111. ROULEUR_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  112. ROULEUR_IRQ_MBHC_SW_DET,
  113. ROULEUR_IRQ_HPHR_OCP_INT,
  114. ROULEUR_IRQ_HPHR_CNP_INT,
  115. ROULEUR_IRQ_HPHL_OCP_INT,
  116. /* INTR_CTRL_INT_MASK_1 */
  117. ROULEUR_IRQ_HPHL_CNP_INT,
  118. ROULEUR_IRQ_EAR_CNP_INT,
  119. ROULEUR_IRQ_EAR_OCP_INT,
  120. ROULEUR_IRQ_LO_CNP_INT,
  121. ROULEUR_IRQ_LO_OCP_INT,
  122. ROULEUR_IRQ_HPHL_PDM_WD_INT,
  123. ROULEUR_IRQ_HPHR_PDM_WD_INT,
  124. ROULEUR_IRQ_RESERVED_0,
  125. /* INTR_CTRL_INT_MASK_2 */
  126. ROULEUR_IRQ_RESERVED_1,
  127. ROULEUR_IRQ_RESERVED_2,
  128. ROULEUR_IRQ_HPHL_SURGE_DET_INT,
  129. ROULEUR_IRQ_HPHR_SURGE_DET_INT,
  130. ROULEUR_NUM_IRQS,
  131. };
  132. extern void rouleur_disable_bcs_before_slow_insert(
  133. struct snd_soc_component *component,
  134. bool bcs_disable);
  135. extern struct rouleur_mbhc *rouleur_soc_get_mbhc(
  136. struct snd_soc_component *component);
  137. extern int rouleur_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
  138. int volt, int micb_num);
  139. extern int rouleur_get_micb_vout_ctl_val(u32 micb_mv);
  140. extern int rouleur_micbias_control(struct snd_soc_component *component,
  141. int micb_num, int req, bool is_dapm);
  142. extern int rouleur_global_mbias_enable(struct snd_soc_component *component);
  143. extern int rouleur_global_mbias_disable(struct snd_soc_component *component);
  144. #endif