lpass-cdc.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  3. */
  4. #ifndef LPASS_CDC_H
  5. #define LPASS_CDC_H
  6. #include <sound/soc.h>
  7. #include <linux/regmap.h>
  8. #define LPASS_CDC_VERSION_1_0 0x0001
  9. #define LPASS_CDC_VERSION_1_1 0x0002
  10. #define LPASS_CDC_VERSION_1_2 0x0003
  11. #define LPASS_CDC_VERSION_2_0 0x0004
  12. #define LPASS_CDC_VERSION_2_1 0x0005
  13. #define LPASS_CDC_VERSION_2_5 0x0006
  14. #define LPASS_CDC_VERSION_2_6 0x0007
  15. enum {
  16. START_MACRO,
  17. TX_MACRO = START_MACRO,
  18. RX_MACRO,
  19. WSA_MACRO,
  20. VA_MACRO,
  21. WSA2_MACRO,
  22. MAX_MACRO
  23. };
  24. enum mclk_mux {
  25. MCLK_MUX0,
  26. MCLK_MUX1,
  27. MCLK_MUX_MAX
  28. };
  29. enum {
  30. LPASS_CDC_ADC0 = 1,
  31. LPASS_CDC_ADC1,
  32. LPASS_CDC_ADC2,
  33. LPASS_CDC_ADC3,
  34. LPASS_CDC_ADC_MAX
  35. };
  36. enum {
  37. LPASS_CDC_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
  38. LPASS_CDC_MACRO_EVT_IMPED_TRUE, /* for imped true */
  39. LPASS_CDC_MACRO_EVT_IMPED_FALSE, /* for imped false */
  40. LPASS_CDC_MACRO_EVT_SSR_DOWN,
  41. LPASS_CDC_MACRO_EVT_SSR_UP,
  42. LPASS_CDC_MACRO_EVT_WAIT_VA_CLK_RESET,
  43. LPASS_CDC_MACRO_EVT_CLK_RESET,
  44. LPASS_CDC_MACRO_EVT_REG_WAKE_IRQ,
  45. LPASS_CDC_MACRO_EVT_RX_COMPANDER_SOFT_RST,
  46. LPASS_CDC_MACRO_EVT_BCS_CLK_OFF,
  47. LPASS_CDC_MACRO_EVT_SSR_GFMUX_UP,
  48. LPASS_CDC_MACRO_EVT_PRE_SSR_UP,
  49. LPASS_CDC_MACRO_EVT_RX_PA_GAIN_UPDATE,
  50. LPASS_CDC_MACRO_EVT_HPHL_HD2_ENABLE, /* Enable HD2 cfg for HPHL */
  51. LPASS_CDC_MACRO_EVT_HPHR_HD2_ENABLE, /* Enable HD2 cfg for HPHR */
  52. };
  53. enum {
  54. DMIC_TX = 0,
  55. DMIC_VA = 1,
  56. };
  57. struct macro_ops {
  58. int (*init)(struct snd_soc_component *component);
  59. int (*exit)(struct snd_soc_component *component);
  60. u16 num_dais;
  61. struct device *dev;
  62. struct snd_soc_dai_driver *dai_ptr;
  63. int (*mclk_fn)(struct device *dev, bool enable);
  64. int (*event_handler)(struct snd_soc_component *component, u16 event,
  65. u32 data);
  66. int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
  67. int (*set_port_map)(struct snd_soc_component *component, u32 uc,
  68. u32 size, void *data);
  69. int (*clk_div_get)(struct snd_soc_component *component);
  70. int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
  71. int (*clk_enable)(struct snd_soc_component *c, bool en);
  72. char __iomem *io_base;
  73. u16 clk_id_req;
  74. u16 default_clk_id;
  75. };
  76. typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event);
  77. #if IS_ENABLED(CONFIG_SND_SOC_LPASS_CDC)
  78. int lpass_cdc_register_res_clk(struct device *dev, rsc_clk_cb_t cb);
  79. void lpass_cdc_unregister_res_clk(struct device *dev);
  80. bool lpass_cdc_is_va_macro_registered(struct device *dev);
  81. int lpass_cdc_register_macro(struct device *dev, u16 macro_id,
  82. struct macro_ops *ops);
  83. void lpass_cdc_unregister_macro(struct device *dev, u16 macro_id);
  84. struct device *lpass_cdc_get_device_ptr(struct device *dev, u16 macro_id);
  85. struct device *lpass_cdc_get_rsc_clk_device_ptr(struct device *dev);
  86. int lpass_cdc_info_create_codec_entry(
  87. struct snd_info_entry *codec_root,
  88. struct snd_soc_component *component);
  89. int lpass_cdc_register_wake_irq(struct snd_soc_component *component, u32 data);
  90. void lpass_cdc_clear_amic_tx_hold(struct device *dev, u16 adc_n);
  91. int lpass_cdc_runtime_resume(struct device *dev);
  92. int lpass_cdc_runtime_suspend(struct device *dev);
  93. int lpass_cdc_set_port_map(struct snd_soc_component *component, u32 size, void *data);
  94. int lpass_cdc_register_event_listener(struct snd_soc_component *component,
  95. bool enable);
  96. void lpass_cdc_wsa_pa_on(struct device *dev, bool adie_lb);
  97. bool lpass_cdc_check_core_votes(struct device *dev);
  98. int lpass_cdc_tx_mclk_enable(struct snd_soc_component *c, bool enable);
  99. int lpass_cdc_get_version(struct device *dev);
  100. int lpass_cdc_dmic_clk_enable(struct snd_soc_component *component,
  101. u32 dmic, u32 tx_mode, bool enable);
  102. /* RX MACRO utilities */
  103. int lpass_cdc_rx_set_fir_capability(struct snd_soc_component *component,
  104. bool capable);
  105. #else
  106. static inline int lpass_cdc_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
  107. {
  108. return 0;
  109. }
  110. static inline void lpass_cdc_unregister_res_clk(struct device *dev)
  111. {
  112. }
  113. static bool lpass_cdc_is_va_macro_registered(struct device *dev)
  114. {
  115. return false;
  116. }
  117. static inline int lpass_cdc_register_macro(struct device *dev,
  118. u16 macro_id,
  119. struct macro_ops *ops)
  120. {
  121. return 0;
  122. }
  123. static inline void lpass_cdc_unregister_macro(struct device *dev, u16 macro_id)
  124. {
  125. }
  126. static inline struct device *lpass_cdc_get_device_ptr(struct device *dev,
  127. u16 macro_id)
  128. {
  129. return NULL;
  130. }
  131. static int lpass_cdc_info_create_codec_entry(
  132. struct snd_info_entry *codec_root,
  133. struct snd_soc_component *component)
  134. {
  135. return 0;
  136. }
  137. static inline void lpass_cdc_clear_amic_tx_hold(struct device *dev, u16 adc_n)
  138. {
  139. }
  140. static inline int lpass_cdc_register_wake_irq(struct snd_soc_component *component,
  141. u32 data)
  142. {
  143. return 0;
  144. }
  145. static inline int lpass_cdc_runtime_resume(struct device *dev)
  146. {
  147. return 0;
  148. }
  149. static int lpass_cdc_runtime_suspend(struct device *dev)
  150. {
  151. return 0;
  152. }
  153. static inline int lpass_cdc_set_port_map(struct snd_soc_component *component,
  154. u32 size, void *data)
  155. {
  156. return 0;
  157. }
  158. static inline int lpass_cdc_register_event_listener(
  159. struct snd_soc_component *component,
  160. bool enable)
  161. {
  162. return 0;
  163. }
  164. static void lpass_cdc_wsa_pa_on(struct device *dev, bool adie_lb)
  165. {
  166. }
  167. static inline bool lpass_cdc_check_core_votes(struct device *dev)
  168. {
  169. return false;
  170. }
  171. static int lpass_cdc_get_version(struct device *dev)
  172. {
  173. return 0;
  174. }
  175. static int lpass_cdc_dmic_clk_enable(struct snd_soc_component *component,
  176. u32 dmic, u32 tx_mode, bool enable)
  177. {
  178. return 0;
  179. }
  180. static int lpass_cdc_tx_mclk_enable(struct snd_soc_component *c, bool enable)
  181. {
  182. return 0;
  183. }
  184. /* RX MACRO utilities */
  185. static int lpass_cdc_rx_set_fir_capability(struct snd_soc_component *component,
  186. bool capable)
  187. {
  188. return 0;
  189. }
  190. #endif /* CONFIG_SND_SOC_LPASS_CDC */
  191. #endif /* LPASS_CDC_H */