blob: a66fb2a63fae0ae9dcf642f1ea12be89c9d21879 [file] [log] [blame]
Banajit Goswami0530e2f2016-12-09 21:34:37 -08001/* 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
13#include <linux/module.h>
14#include <linux/qdsp6v2/audio_ssr.h>
15#include <soc/qcom/scm.h>
16#include <soc/qcom/subsystem_restart.h>
17#include <soc/qcom/subsystem_notif.h>
18
19#define SCM_Q6_NMI_CMD 0x1
20
21static char *audio_ssr_domains[] = {
22 "adsp",
23 "modem"
24};
25
26void *audio_ssr_register(int domain_id, struct notifier_block *nb)
27{
28 if ((domain_id < 0) ||
29 (domain_id >= AUDIO_SSR_DOMAIN_MAX)) {
30 pr_err("%s: Invalid service ID %d\n", __func__, domain_id);
31 return ERR_PTR(-EINVAL);
32 }
33
34 return subsys_notif_register_notifier(
35 audio_ssr_domains[domain_id], nb);
36}
37EXPORT_SYMBOL(audio_ssr_register);
38
39int audio_ssr_deregister(void *handle, struct notifier_block *nb)
40{
41 return subsys_notif_unregister_notifier(handle, nb);
42}
43EXPORT_SYMBOL(audio_ssr_deregister);
44
45void audio_ssr_send_nmi(void *ssr_cb_data)
46{
47 struct notif_data *data = (struct notif_data *)ssr_cb_data;
48 struct scm_desc desc;
49
50 if (data && data->crashed) {
51 /* Send NMI to QDSP6 via an SCM call. */
52 if (!is_scm_armv8()) {
53 scm_call_atomic1(SCM_SVC_UTIL,
54 SCM_Q6_NMI_CMD, 0x1);
55 } else {
56 desc.args[0] = 0x1;
57 desc.arginfo = SCM_ARGS(1);
58 scm_call2_atomic(SCM_SIP_FNID(SCM_SVC_UTIL,
59 SCM_Q6_NMI_CMD), &desc);
60 }
61 /* The write should go through before q6 is shutdown */
62 mb();
63 pr_debug("%s: Q6 NMI was sent.\n", __func__);
64 }
65}
66EXPORT_SYMBOL(audio_ssr_send_nmi);