wcd934x-dsp-cntl.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __WCD934X_DSP_CNTL_H__
  6. #define __WCD934X_DSP_CNTL_H__
  7. #include <linux/miscdevice.h>
  8. #include <sound/soc.h>
  9. #include <sound/wcd-dsp-mgr.h>
  10. enum cdc_ssr_event {
  11. WCD_CDC_DOWN_EVENT,
  12. WCD_CDC_UP_EVENT,
  13. };
  14. struct wcd_dsp_cdc_cb {
  15. /* Callback to enable codec clock */
  16. int (*cdc_clk_en)(struct snd_soc_component *component, bool enable);
  17. /* Callback to vote and unvote for SVS2 mode */
  18. void (*cdc_vote_svs)(struct snd_soc_component *component, bool enable);
  19. };
  20. struct wcd_dsp_irq_info {
  21. /* IPC interrupt */
  22. int cpe_ipc1_irq;
  23. /* CPE error summary interrupt */
  24. int cpe_err_irq;
  25. /*
  26. * Bit mask to indicate which of the
  27. * error interrupts are to be considered
  28. * as fatal.
  29. */
  30. u16 fatal_irqs;
  31. };
  32. struct wcd_dsp_params {
  33. struct wcd_dsp_cdc_cb *cb;
  34. struct wcd_dsp_irq_info irqs;
  35. /* Rate at which the codec clock operates */
  36. u32 clk_rate;
  37. /*
  38. * Represents the dsp instance, will be used
  39. * to create sysfs and debugfs entries with
  40. * directory wdsp<dsp-instance>
  41. */
  42. u32 dsp_instance;
  43. };
  44. struct wdsp_ssr_entry {
  45. u8 offline;
  46. u8 offline_change;
  47. wait_queue_head_t offline_poll_wait;
  48. struct snd_info_entry *entry;
  49. };
  50. struct wcd_dsp_cntl {
  51. /* Handle to codec */
  52. struct snd_soc_component *component;
  53. /* Clk rate of the codec clock */
  54. u32 clk_rate;
  55. /* Callbacks to codec driver */
  56. const struct wcd_dsp_cdc_cb *cdc_cb;
  57. /* Completion to indicate WDSP boot done */
  58. struct completion boot_complete;
  59. struct wcd_dsp_irq_info irqs;
  60. u32 dsp_instance;
  61. /* Sysfs entries related */
  62. int boot_reqs;
  63. struct kobject wcd_kobj;
  64. /* Debugfs related */
  65. struct dentry *entry;
  66. u32 debug_mode;
  67. bool ramdump_enable;
  68. bool dbg_dmp_enable;
  69. /* WDSP manager drivers data */
  70. struct device *m_dev;
  71. struct wdsp_mgr_ops *m_ops;
  72. /* clk related */
  73. struct mutex clk_mutex;
  74. bool is_clk_enabled;
  75. /* Keep track of WDSP boot status */
  76. bool is_wdsp_booted;
  77. /* SSR related */
  78. struct wdsp_ssr_entry ssr_entry;
  79. struct mutex ssr_mutex;
  80. /* Misc device related */
  81. char miscdev_name[256];
  82. struct miscdevice miscdev;
  83. #ifdef CONFIG_DEBUG_FS
  84. /* Debug dump related */
  85. atomic_t err_irq_flag;
  86. #endif
  87. };
  88. void wcd_dsp_cntl_init(struct snd_soc_component *component,
  89. struct wcd_dsp_params *params,
  90. struct wcd_dsp_cntl **cntl);
  91. void wcd_dsp_cntl_deinit(struct wcd_dsp_cntl **cntl);
  92. int wcd_dsp_ssr_event(struct wcd_dsp_cntl *cntl, enum cdc_ssr_event event);
  93. #endif /* end __WCD_DSP_CONTROL_H__ */