bolero-cdc.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. #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. BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
  35. BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */
  36. BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */
  37. BOLERO_MACRO_EVT_SSR_DOWN,
  38. BOLERO_MACRO_EVT_SSR_UP,
  39. BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET,
  40. BOLERO_MACRO_EVT_CLK_RESET,
  41. BOLERO_MACRO_EVT_REG_WAKE_IRQ,
  42. BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST
  43. };
  44. struct macro_ops {
  45. int (*init)(struct snd_soc_component *component);
  46. int (*exit)(struct snd_soc_component *component);
  47. u16 num_dais;
  48. struct device *dev;
  49. struct snd_soc_dai_driver *dai_ptr;
  50. int (*mclk_fn)(struct device *dev, bool enable);
  51. int (*event_handler)(struct snd_soc_component *component, u16 event,
  52. u32 data);
  53. int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
  54. int (*set_port_map)(struct snd_soc_component *component, u32 uc,
  55. u32 size, void *data);
  56. int (*clk_switch)(struct snd_soc_component *component);
  57. int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
  58. char __iomem *io_base;
  59. u16 clk_id_req;
  60. u16 default_clk_id;
  61. };
  62. typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event);
  63. #if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
  64. int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb);
  65. void bolero_unregister_res_clk(struct device *dev);
  66. int bolero_register_macro(struct device *dev, u16 macro_id,
  67. struct macro_ops *ops);
  68. void bolero_unregister_macro(struct device *dev, u16 macro_id);
  69. struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
  70. struct device *bolero_get_rsc_clk_device_ptr(struct device *dev);
  71. int bolero_info_create_codec_entry(
  72. struct snd_info_entry *codec_root,
  73. struct snd_soc_component *component);
  74. int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
  75. void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
  76. int bolero_runtime_resume(struct device *dev);
  77. int bolero_runtime_suspend(struct device *dev);
  78. int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
  79. int bolero_tx_clk_switch(struct snd_soc_component *component);
  80. int bolero_register_event_listener(struct snd_soc_component *component,
  81. bool enable);
  82. void bolero_wsa_pa_on(struct device *dev);
  83. bool bolero_check_core_votes(struct device *dev);
  84. int bolero_get_version(struct device *dev);
  85. #else
  86. static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
  87. {
  88. return 0;
  89. }
  90. static inline void bolero_unregister_res_clk(struct device *dev)
  91. {
  92. }
  93. static inline int bolero_register_macro(struct device *dev,
  94. u16 macro_id,
  95. struct macro_ops *ops)
  96. {
  97. return 0;
  98. }
  99. static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
  100. {
  101. }
  102. static inline struct device *bolero_get_device_ptr(struct device *dev,
  103. u16 macro_id)
  104. {
  105. return NULL;
  106. }
  107. static int bolero_info_create_codec_entry(
  108. struct snd_info_entry *codec_root,
  109. struct snd_soc_component *component)
  110. {
  111. return 0;
  112. }
  113. static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
  114. {
  115. }
  116. static inline int bolero_register_wake_irq(struct snd_soc_component *component,
  117. u32 data)
  118. {
  119. return 0;
  120. }
  121. static inline int bolero_runtime_resume(struct device *dev)
  122. {
  123. return 0;
  124. }
  125. static int bolero_runtime_suspend(struct device *dev)
  126. {
  127. return 0;
  128. }
  129. static inline int bolero_set_port_map(struct snd_soc_component *component,
  130. u32 size, void *data)
  131. {
  132. return 0;
  133. }
  134. static inline int bolero_tx_clk_switch(struct snd_soc_component *component)
  135. {
  136. return 0;
  137. }
  138. static inline int bolero_register_event_listener(
  139. struct snd_soc_component *component,
  140. bool enable)
  141. {
  142. return 0;
  143. }
  144. static void bolero_wsa_pa_on(struct device *dev)
  145. {
  146. }
  147. static inline bool bolero_check_core_votes(struct device *dev)
  148. {
  149. return false;
  150. }
  151. static int bolero_get_version(struct device *dev)
  152. {
  153. return 0;
  154. }
  155. #endif /* CONFIG_SND_SOC_BOLERO */
  156. #endif /* BOLERO_CDC_H */