bolero-cdc.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018, 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_REG_WAKE_IRQ
  36. };
  37. struct macro_ops {
  38. int (*init)(struct snd_soc_component *component);
  39. int (*exit)(struct snd_soc_component *component);
  40. u16 num_dais;
  41. struct device *dev;
  42. struct snd_soc_dai_driver *dai_ptr;
  43. int (*mclk_fn)(struct device *dev, bool enable);
  44. int (*event_handler)(struct snd_soc_component *component, u16 event,
  45. u32 data);
  46. int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
  47. int (*set_port_map)(struct snd_soc_component *component, u32 uc,
  48. u32 size, void *data);
  49. char __iomem *io_base;
  50. };
  51. #if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
  52. int bolero_register_macro(struct device *dev, u16 macro_id,
  53. struct macro_ops *ops);
  54. void bolero_unregister_macro(struct device *dev, u16 macro_id);
  55. struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
  56. int bolero_request_clock(struct device *dev, u16 macro_id,
  57. enum mclk_mux mclk_mux_id,
  58. bool enable);
  59. int bolero_info_create_codec_entry(
  60. struct snd_info_entry *codec_root,
  61. struct snd_soc_component *component);
  62. int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
  63. void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
  64. int bolero_runtime_resume(struct device *dev);
  65. int bolero_runtime_suspend(struct device *dev);
  66. int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
  67. #else
  68. static inline int bolero_register_macro(struct device *dev,
  69. u16 macro_id,
  70. struct macro_ops *ops)
  71. {
  72. return 0;
  73. }
  74. static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
  75. {
  76. }
  77. static inline struct device *bolero_get_device_ptr(struct device *dev,
  78. u16 macro_id)
  79. {
  80. return NULL;
  81. }
  82. static inline int bolero_request_clock(struct device *dev, u16 macro_id,
  83. enum mclk_mux mclk_mux_id,
  84. bool enable)
  85. {
  86. return 0;
  87. }
  88. static int bolero_info_create_codec_entry(
  89. struct snd_info_entry *codec_root,
  90. struct snd_soc_component *component)
  91. {
  92. return 0;
  93. }
  94. static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
  95. {
  96. }
  97. static inline int bolero_register_wake_irq(struct snd_soc_component *component,
  98. u32 data)
  99. {
  100. return 0;
  101. }
  102. static inline int bolero_runtime_resume(struct device *dev)
  103. {
  104. return 0;
  105. }
  106. static int bolero_runtime_suspend(struct device *dev)
  107. {
  108. return 0;
  109. }
  110. static inline int bolero_set_port_map(struct snd_soc_component *component,
  111. u32 size, void *data)
  112. {
  113. return 0;
  114. }
  115. #endif /* CONFIG_SND_SOC_BOLERO */
  116. #endif /* BOLERO_CDC_H */