bolero-cdc.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef BOLERO_CDC_H
  6. #define BOLERO_CDC_H
  7. #include <sound/soc.h>
  8. #include <linux/regmap.h>
  9. #define BOLERO_VERSION_1_0 0x0001
  10. #define BOLERO_VERSION_1_1 0x0002
  11. #define BOLERO_VERSION_1_2 0x0003
  12. #define BOLERO_VERSION_2_0 0x0004
  13. #define BOLERO_VERSION_2_1 0x0005
  14. #define BOLERO_VERSION_2_2 0x0006
  15. enum {
  16. START_MACRO,
  17. TX_MACRO = START_MACRO,
  18. RX_MACRO,
  19. WSA_MACRO,
  20. VA_MACRO,
  21. MAX_MACRO
  22. };
  23. enum mclk_mux {
  24. MCLK_MUX0,
  25. MCLK_MUX1,
  26. MCLK_MUX_MAX
  27. };
  28. enum {
  29. BOLERO_ADC0 = 1,
  30. BOLERO_ADC1,
  31. BOLERO_ADC2,
  32. BOLERO_ADC3,
  33. BOLERO_ADC_MAX
  34. };
  35. enum {
  36. CLK_SRC_TX_RCG = 0,
  37. CLK_SRC_VA_RCG,
  38. };
  39. enum {
  40. BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
  41. BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */
  42. BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */
  43. BOLERO_MACRO_EVT_SSR_DOWN,
  44. BOLERO_MACRO_EVT_SSR_UP,
  45. BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET,
  46. BOLERO_MACRO_EVT_CLK_RESET,
  47. BOLERO_MACRO_EVT_REG_WAKE_IRQ,
  48. BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST,
  49. BOLERO_MACRO_EVT_BCS_CLK_OFF,
  50. BOLERO_MACRO_EVT_SSR_GFMUX_UP,
  51. BOLERO_MACRO_EVT_PRE_SSR_UP,
  52. BOLERO_MACRO_EVT_RX_PA_GAIN_UPDATE,
  53. BOLERO_MACRO_EVT_HPHL_HD2_ENABLE, /* Enable HD2 cfg for HPHL */
  54. BOLERO_MACRO_EVT_HPHR_HD2_ENABLE, /* Enable HD2 cfg for HPHR */
  55. };
  56. enum {
  57. DMIC_TX = 0,
  58. DMIC_VA = 1,
  59. };
  60. struct macro_ops {
  61. int (*init)(struct snd_soc_component *component);
  62. int (*exit)(struct snd_soc_component *component);
  63. u16 num_dais;
  64. struct device *dev;
  65. struct snd_soc_dai_driver *dai_ptr;
  66. int (*mclk_fn)(struct device *dev, bool enable);
  67. int (*event_handler)(struct snd_soc_component *component, u16 event,
  68. u32 data);
  69. int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
  70. int (*set_port_map)(struct snd_soc_component *component, u32 uc,
  71. u32 size, void *data);
  72. int (*clk_div_get)(struct snd_soc_component *component);
  73. int (*clk_switch)(struct snd_soc_component *component, int clk_src);
  74. int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
  75. int (*clk_enable)(struct snd_soc_component *c, bool en);
  76. char __iomem *io_base;
  77. u16 clk_id_req;
  78. u16 default_clk_id;
  79. };
  80. typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event);
  81. #if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
  82. int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb);
  83. void bolero_unregister_res_clk(struct device *dev);
  84. bool bolero_is_va_macro_registered(struct device *dev);
  85. int bolero_register_macro(struct device *dev, u16 macro_id,
  86. struct macro_ops *ops);
  87. void bolero_unregister_macro(struct device *dev, u16 macro_id);
  88. struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
  89. struct device *bolero_get_rsc_clk_device_ptr(struct device *dev);
  90. int bolero_info_create_codec_entry(
  91. struct snd_info_entry *codec_root,
  92. struct snd_soc_component *component);
  93. int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
  94. void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
  95. int bolero_runtime_resume(struct device *dev);
  96. int bolero_runtime_suspend(struct device *dev);
  97. int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
  98. int bolero_tx_clk_switch(struct snd_soc_component *component, int clk_src);
  99. int bolero_register_event_listener(struct snd_soc_component *component,
  100. bool enable);
  101. void bolero_wsa_pa_on(struct device *dev, bool adie_lb);
  102. bool bolero_check_core_votes(struct device *dev);
  103. int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable);
  104. int bolero_get_version(struct device *dev);
  105. int bolero_dmic_clk_enable(struct snd_soc_component *component,
  106. u32 dmic, u32 tx_mode, bool enable);
  107. void bolero_rx_pa_on(struct device *dev);
  108. #else
  109. static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
  110. {
  111. return 0;
  112. }
  113. static inline void bolero_unregister_res_clk(struct device *dev)
  114. {
  115. }
  116. static bool bolero_is_va_macro_registered(struct device *dev)
  117. {
  118. return false;
  119. }
  120. static inline int bolero_register_macro(struct device *dev,
  121. u16 macro_id,
  122. struct macro_ops *ops)
  123. {
  124. return 0;
  125. }
  126. static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
  127. {
  128. }
  129. static inline struct device *bolero_get_device_ptr(struct device *dev,
  130. u16 macro_id)
  131. {
  132. return NULL;
  133. }
  134. static int bolero_info_create_codec_entry(
  135. struct snd_info_entry *codec_root,
  136. struct snd_soc_component *component)
  137. {
  138. return 0;
  139. }
  140. static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
  141. {
  142. }
  143. static inline int bolero_register_wake_irq(struct snd_soc_component *component,
  144. u32 data)
  145. {
  146. return 0;
  147. }
  148. static inline int bolero_runtime_resume(struct device *dev)
  149. {
  150. return 0;
  151. }
  152. static int bolero_runtime_suspend(struct device *dev)
  153. {
  154. return 0;
  155. }
  156. static inline int bolero_set_port_map(struct snd_soc_component *component,
  157. u32 size, void *data)
  158. {
  159. return 0;
  160. }
  161. static inline int bolero_tx_clk_switch(struct snd_soc_component *component,
  162. int clk_src)
  163. {
  164. return 0;
  165. }
  166. static inline int bolero_register_event_listener(
  167. struct snd_soc_component *component,
  168. bool enable)
  169. {
  170. return 0;
  171. }
  172. static void bolero_wsa_pa_on(struct device *dev, bool adie_lb)
  173. {
  174. }
  175. static inline bool bolero_check_core_votes(struct device *dev)
  176. {
  177. return false;
  178. }
  179. static int bolero_get_version(struct device *dev)
  180. {
  181. return 0;
  182. }
  183. static int bolero_dmic_clk_enable(struct snd_soc_component *component,
  184. u32 dmic, u32 tx_mode, bool enable)
  185. {
  186. return 0;
  187. }
  188. static int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable)
  189. {
  190. return 0;
  191. }
  192. static inline void bolero_rx_pa_on(struct device *dev)
  193. {
  194. return 0;
  195. }
  196. #endif /* CONFIG_SND_SOC_BOLERO */
  197. #endif /* BOLERO_CDC_H */