bolero-cdc.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018-2019, 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. enum {
  9. START_MACRO,
  10. TX_MACRO = START_MACRO,
  11. RX_MACRO,
  12. WSA_MACRO,
  13. VA_MACRO,
  14. MAX_MACRO
  15. };
  16. enum mclk_mux {
  17. MCLK_MUX0,
  18. MCLK_MUX1,
  19. MCLK_MUX_MAX
  20. };
  21. enum {
  22. BOLERO_ADC0 = 1,
  23. BOLERO_ADC1,
  24. BOLERO_ADC2,
  25. BOLERO_ADC3,
  26. BOLERO_ADC_MAX
  27. };
  28. enum {
  29. BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
  30. BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */
  31. BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */
  32. BOLERO_MACRO_EVT_SSR_DOWN,
  33. BOLERO_MACRO_EVT_SSR_UP,
  34. BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET,
  35. BOLERO_MACRO_EVT_CLK_RESET,
  36. BOLERO_MACRO_EVT_REG_WAKE_IRQ,
  37. BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST,
  38. BOLERO_MACRO_EVT_BCS_CLK_OFF
  39. };
  40. struct macro_ops {
  41. int (*init)(struct snd_soc_component *component);
  42. int (*exit)(struct snd_soc_component *component);
  43. u16 num_dais;
  44. struct device *dev;
  45. struct snd_soc_dai_driver *dai_ptr;
  46. int (*mclk_fn)(struct device *dev, bool enable);
  47. int (*event_handler)(struct snd_soc_component *component, u16 event,
  48. u32 data);
  49. int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
  50. int (*set_port_map)(struct snd_soc_component *component, u32 uc,
  51. u32 size, void *data);
  52. int (*clk_switch)(struct snd_soc_component *component);
  53. int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
  54. char __iomem *io_base;
  55. u16 clk_id_req;
  56. u16 default_clk_id;
  57. };
  58. typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event);
  59. #if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
  60. int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb);
  61. void bolero_unregister_res_clk(struct device *dev);
  62. int bolero_register_macro(struct device *dev, u16 macro_id,
  63. struct macro_ops *ops);
  64. void bolero_unregister_macro(struct device *dev, u16 macro_id);
  65. struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
  66. struct device *bolero_get_rsc_clk_device_ptr(struct device *dev);
  67. int bolero_info_create_codec_entry(
  68. struct snd_info_entry *codec_root,
  69. struct snd_soc_component *component);
  70. int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
  71. void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
  72. int bolero_runtime_resume(struct device *dev);
  73. int bolero_runtime_suspend(struct device *dev);
  74. int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
  75. int bolero_tx_clk_switch(struct snd_soc_component *component);
  76. int bolero_register_event_listener(struct snd_soc_component *component,
  77. bool enable);
  78. void bolero_wsa_pa_on(struct device *dev);
  79. bool bolero_check_core_votes(struct device *dev);
  80. #else
  81. static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
  82. {
  83. return 0;
  84. }
  85. static inline void bolero_unregister_res_clk(struct device *dev)
  86. {
  87. }
  88. static inline int bolero_register_macro(struct device *dev,
  89. u16 macro_id,
  90. struct macro_ops *ops)
  91. {
  92. return 0;
  93. }
  94. static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
  95. {
  96. }
  97. static inline struct device *bolero_get_device_ptr(struct device *dev,
  98. u16 macro_id)
  99. {
  100. return NULL;
  101. }
  102. static int bolero_info_create_codec_entry(
  103. struct snd_info_entry *codec_root,
  104. struct snd_soc_component *component)
  105. {
  106. return 0;
  107. }
  108. static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
  109. {
  110. }
  111. static inline int bolero_register_wake_irq(struct snd_soc_component *component,
  112. u32 data)
  113. {
  114. return 0;
  115. }
  116. static inline int bolero_runtime_resume(struct device *dev)
  117. {
  118. return 0;
  119. }
  120. static int bolero_runtime_suspend(struct device *dev)
  121. {
  122. return 0;
  123. }
  124. static inline int bolero_set_port_map(struct snd_soc_component *component,
  125. u32 size, void *data)
  126. {
  127. return 0;
  128. }
  129. static inline int bolero_tx_clk_switch(struct snd_soc_component *component)
  130. {
  131. return 0;
  132. }
  133. static inline int bolero_register_event_listener(
  134. struct snd_soc_component *component,
  135. bool enable)
  136. {
  137. return 0;
  138. }
  139. static void bolero_wsa_pa_on(struct device *dev)
  140. {
  141. }
  142. static inline bool bolero_check_core_votes(struct device *dev)
  143. {
  144. return false;
  145. }
  146. #endif /* CONFIG_SND_SOC_BOLERO */
  147. #endif /* BOLERO_CDC_H */