summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSurendar karka <sukark@codeaurora.org>2016-12-22 12:11:26 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2019-02-19 22:34:02 -0800
commit2f2349ed452999de87b7c588ba42d0d65c546d73 (patch)
tree0bb05e8dfe6a9e753af65e159546130bca702581
parent738661eb869c2873cfd595c5e68f5c0f554167e2 (diff)
ASoC: msm: qdsp6v2: Add support to query adsp version
Q6 core service provides API to query ADSP version. Update the apr with get()/set() to use this adsp version by platform/machine drivers. Signed-off-by: Surendar karka <sukark@codeaurora.org> Change-Id: I2466f4eba636ce41e5eb9a75e2e5e75a069fd0ee Signed-off-by: Dhanalakshmi Siddani <dsiddani@codeaurora.org>
-rw-r--r--include/sound/q6core.h21
-rw-r--r--sound/soc/msm/qdsp6v2/q6core.c93
2 files changed, 110 insertions, 4 deletions
diff --git a/include/sound/q6core.h b/include/sound/q6core.h
index 148df25cbd51..f4e048d0aa6f 100644
--- a/include/sound/q6core.h
+++ b/include/sound/q6core.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -175,4 +175,23 @@ struct avs_mem_assign_region {
u32 addr_msw;
} __packed;
+#define AVCS_GET_VERSIONS 0x00012905
+struct avcs_cmd_get_version_result {
+ struct apr_hdr hdr;
+ uint32_t id;
+};
+#define AVCS_GET_VERSIONS_RSP 0x00012906
+
+#define AVCS_CMDRSP_Q6_ID_2_6 0x00040000
+#define AVCS_CMDRSP_Q6_ID_2_7 0x00040001
+#define AVCS_CMDRSP_Q6_ID_2_8 0x00040002
+
+enum q6_subsys_image {
+ Q6_SUBSYS_AVS2_6 = 1,
+ Q6_SUBSYS_AVS2_7,
+ Q6_SUBSYS_AVS2_8,
+ Q6_SUBSYS_INVALID,
+};
+enum q6_subsys_image q6core_get_avs_version(void);
+int core_get_adsp_ver(void);
#endif /* __Q6CORE_H__ */
diff --git a/sound/soc/msm/qdsp6v2/q6core.c b/sound/soc/msm/qdsp6v2/q6core.c
index d736af0c35b0..c555a3562bd5 100644
--- a/sound/soc/msm/qdsp6v2/q6core.c
+++ b/sound/soc/msm/qdsp6v2/q6core.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -57,7 +57,8 @@ struct q6core_str {
u32 bus_bw_resp_received;
enum cmd_flags {
FLAG_NONE,
- FLAG_CMDRSP_LICENSE_RESULT
+ FLAG_CMDRSP_LICENSE_RESULT,
+ FLAG_AVCS_GET_VERSIONS_RESULT,
} cmd_resp_received_flag;
u32 avcs_fwk_ver_resp_received;
struct mutex cmd_lock;
@@ -71,6 +72,7 @@ struct q6core_str {
uint32_t mem_map_cal_handle;
int32_t adsp_status;
struct q6core_avcs_ver_info q6core_avcs_ver_info;
+ u32 q6_core_avs_version;
};
static struct q6core_str q6core_lcl;
@@ -230,7 +232,33 @@ static int32_t aprv2_core_fn_q(struct apr_client_data *data, void *priv)
q6core_lcl.bus_bw_resp_received = 1;
wake_up(&q6core_lcl.bus_bw_req_wait);
break;
- case AVCS_CMDRSP_GET_LICENSE_VALIDATION_RESULT:
+ case AVCS_GET_VERSIONS_RSP:
+ payload1 = data->payload;
+ pr_debug("%s: Received ADSP version response[3]0x%x\n",
+ __func__, payload1[3]);
+ q6core_lcl.cmd_resp_received_flag =
+ FLAG_AVCS_GET_VERSIONS_RESULT;
+ if (payload1[3] == AVCS_CMDRSP_Q6_ID_2_6) {
+ q6core_lcl.q6_core_avs_version = Q6_SUBSYS_AVS2_6;
+ pr_debug("%s: Received ADSP version as 2.6\n",
+ __func__);
+ } else if (payload1[3] == AVCS_CMDRSP_Q6_ID_2_7) {
+ q6core_lcl.q6_core_avs_version = Q6_SUBSYS_AVS2_7;
+ pr_debug("%s: Received ADSP version as 2.7\n",
+ __func__);
+ } else if (payload1[3] == AVCS_CMDRSP_Q6_ID_2_8) {
+ q6core_lcl.q6_core_avs_version = Q6_SUBSYS_AVS2_8;
+ pr_info("%s: Received ADSP version as 2.8\n",
+ __func__);
+ } else {
+ pr_err("%s: ADSP version is neither 2.6 nor 2.7\n",
+ __func__);
+ q6core_lcl.q6_core_avs_version = Q6_SUBSYS_INVALID;
+ }
+ wake_up(&q6core_lcl.cmd_req_wait);
+ break;
+
+ case AVCS_CMDRSP_GET_LICENSE_VALIDATION_RESULT:
payload1 = data->payload;
pr_debug("%s: cmd = LICENSE_VALIDATION_RESULT, result = 0x%x\n",
__func__, payload1[0]);
@@ -548,6 +576,65 @@ cmd_unlock:
return rc;
}
+int core_get_adsp_ver(void)
+{
+ struct avcs_cmd_get_version_result get_aver_cmd;
+ int ret = 0;
+
+ mutex_lock(&(q6core_lcl.cmd_lock));
+ ocm_core_open();
+ if (q6core_lcl.core_handle_q == NULL) {
+ pr_err("%s: apr registration for CORE failed\n", __func__);
+ ret = -ENODEV;
+ goto fail_cmd;
+ }
+
+ get_aver_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
+ APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
+ get_aver_cmd.hdr.pkt_size = sizeof(get_aver_cmd);
+ get_aver_cmd.hdr.src_port = 0;
+ get_aver_cmd.hdr.dest_port = 0;
+ get_aver_cmd.hdr.token = 0;
+ get_aver_cmd.hdr.opcode = AVCS_GET_VERSIONS;
+
+ ret = apr_send_pkt(q6core_lcl.core_handle_q,
+ (uint32_t *) &get_aver_cmd);
+ if (ret < 0) {
+ pr_err("%s: Core get DSP version request failed, err %d\n",
+ __func__, ret);
+ ret = -EREMOTE;
+ goto fail_cmd;
+ }
+
+ q6core_lcl.cmd_resp_received_flag &= ~(FLAG_AVCS_GET_VERSIONS_RESULT);
+ mutex_unlock(&(q6core_lcl.cmd_lock));
+ ret = wait_event_timeout(q6core_lcl.cmd_req_wait,
+ (q6core_lcl.cmd_resp_received_flag ==
+ FLAG_AVCS_GET_VERSIONS_RESULT),
+ msecs_to_jiffies(TIMEOUT_MS));
+ mutex_lock(&(q6core_lcl.cmd_lock));
+ if (!ret) {
+ pr_err("%s: wait_event timeout for AVCS_GET_VERSIONS_RESULT\n",
+ __func__);
+ ret = -ETIMEDOUT;
+ goto fail_cmd;
+ }
+ q6core_lcl.cmd_resp_received_flag &= ~(FLAG_AVCS_GET_VERSIONS_RESULT);
+
+fail_cmd:
+ if (ret < 0)
+ q6core_lcl.q6_core_avs_version = Q6_SUBSYS_INVALID;
+ mutex_unlock(&(q6core_lcl.cmd_lock));
+ return ret;
+}
+
+enum q6_subsys_image q6core_get_avs_version(void)
+{
+ if (q6core_lcl.q6_core_avs_version == 0)
+ core_get_adsp_ver();
+ return q6core_lcl.q6_core_avs_version;
+}
+
int32_t core_get_license_status(uint32_t module_id)
{
struct avcs_cmd_get_license_validation_result get_lvr_cmd;