wcd9360-dsp-cntl.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 __WCD9360_DSP_CNTL_H__
  14. #define __WCD9360_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. /* WDSP manager drivers data */
  77. struct device *m_dev;
  78. struct wdsp_mgr_ops *m_ops;
  79. /* clk related */
  80. struct mutex clk_mutex;
  81. bool is_clk_enabled;
  82. /* Keep track of WDSP boot status */
  83. bool is_wdsp_booted;
  84. /* SSR related */
  85. struct wdsp_ssr_entry ssr_entry;
  86. struct mutex ssr_mutex;
  87. /* Misc device related */
  88. char miscdev_name[256];
  89. struct miscdevice miscdev;
  90. };
  91. void wcd9360_dsp_cntl_init(struct snd_soc_codec *codec,
  92. struct wcd_dsp_params *params,
  93. struct wcd_dsp_cntl **cntl);
  94. void wcd9360_dsp_cntl_deinit(struct wcd_dsp_cntl **cntl);
  95. int wcd9360_dsp_ssr_event(struct wcd_dsp_cntl *cntl, enum cdc_ssr_event event);
  96. #endif /* end __WCD_DSP_CONTROL_H__ */