audio_ssr.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (c) 2016, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/module.h>
  13. #include <soc/qcom/scm.h>
  14. #include <soc/qcom/subsystem_restart.h>
  15. #include <soc/qcom/subsystem_notif.h>
  16. #include "audio_ssr.h"
  17. #define SCM_Q6_NMI_CMD 0x1
  18. static char *audio_ssr_domains[] = {
  19. "adsp",
  20. "modem"
  21. };
  22. void *audio_ssr_register(int domain_id, struct notifier_block *nb)
  23. {
  24. if ((domain_id < 0) ||
  25. (domain_id >= AUDIO_SSR_DOMAIN_MAX)) {
  26. pr_err("%s: Invalid service ID %d\n", __func__, domain_id);
  27. return ERR_PTR(-EINVAL);
  28. }
  29. return subsys_notif_register_notifier(
  30. audio_ssr_domains[domain_id], nb);
  31. }
  32. EXPORT_SYMBOL(audio_ssr_register);
  33. int audio_ssr_deregister(void *handle, struct notifier_block *nb)
  34. {
  35. return subsys_notif_unregister_notifier(handle, nb);
  36. }
  37. EXPORT_SYMBOL(audio_ssr_deregister);
  38. void audio_ssr_send_nmi(void *ssr_cb_data)
  39. {
  40. struct notif_data *data = (struct notif_data *)ssr_cb_data;
  41. struct scm_desc desc;
  42. if (data && data->crashed) {
  43. /* Send NMI to QDSP6 via an SCM call. */
  44. if (!is_scm_armv8()) {
  45. scm_call_atomic1(SCM_SVC_UTIL,
  46. SCM_Q6_NMI_CMD, 0x1);
  47. } else {
  48. desc.args[0] = 0x1;
  49. desc.arginfo = SCM_ARGS(1);
  50. scm_call2_atomic(SCM_SIP_FNID(SCM_SVC_UTIL,
  51. SCM_Q6_NMI_CMD), &desc);
  52. }
  53. /* The write should go through before q6 is shutdown */
  54. mb();
  55. pr_debug("%s: Q6 NMI was sent.\n", __func__);
  56. }
  57. }
  58. EXPORT_SYMBOL(audio_ssr_send_nmi);