bolero-cdc.h 5.4 KB

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