Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 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 | |
| 13 | #include <linux/module.h> |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 14 | #include <soc/qcom/scm.h> |
| 15 | #include <soc/qcom/subsystem_restart.h> |
| 16 | #include <soc/qcom/subsystem_notif.h> |
Laxminath Kasam | 605b42f | 2017-08-01 22:02:15 +0530 | [diff] [blame^] | 17 | #include "audio_ssr.h" |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 18 | |
| 19 | #define SCM_Q6_NMI_CMD 0x1 |
| 20 | |
| 21 | static char *audio_ssr_domains[] = { |
| 22 | "adsp", |
| 23 | "modem" |
| 24 | }; |
| 25 | |
| 26 | void *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 | } |
| 37 | EXPORT_SYMBOL(audio_ssr_register); |
| 38 | |
| 39 | int audio_ssr_deregister(void *handle, struct notifier_block *nb) |
| 40 | { |
| 41 | return subsys_notif_unregister_notifier(handle, nb); |
| 42 | } |
| 43 | EXPORT_SYMBOL(audio_ssr_deregister); |
| 44 | |
| 45 | void 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 | } |
| 66 | EXPORT_SYMBOL(audio_ssr_send_nmi); |