wcd934x-dsp-cntl.h 2.8 KB

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