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 Change-Id: Icf480991b4b7847cd872ab7286ed1132facff0a4 Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org> Signed-off-by: Divya Narayanan Poojary <dnaray@codeaurora.org>
This commit is contained in:
parent
fb308c0002
commit
2e6a457e55
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2012-2014, 2016 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
|
||||
|
@ -155,4 +155,21 @@ struct avcs_cmdrsp_get_license_validation_result {
|
|||
int32_t core_set_license(uint32_t key, uint32_t module_id);
|
||||
int32_t core_get_license_status(uint32_t module_id);
|
||||
|
||||
#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
|
||||
|
||||
enum q6_subsys_image {
|
||||
Q6_SUBSYS_AVS2_6,
|
||||
Q6_SUBSYS_AVS2_7,
|
||||
Q6_SUBSYS_INVALID,
|
||||
};
|
||||
enum q6_subsys_image q6core_get_avs_version(void);
|
||||
int core_get_adsp_ver(void);
|
||||
#endif /* __Q6CORE_H__ */
|
||||
|
|
|
@ -40,7 +40,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;
|
||||
struct mutex cmd_lock;
|
||||
union {
|
||||
|
@ -50,6 +51,7 @@ struct q6core_str {
|
|||
struct avcs_cmd_rsp_get_low_power_segments_info_t lp_ocm_payload;
|
||||
u32 param;
|
||||
struct cal_type_data *cal_data;
|
||||
u32 q6_core_avs_version;
|
||||
};
|
||||
|
||||
static struct q6core_str q6core_lcl;
|
||||
|
@ -147,7 +149,29 @@ 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 (AVCS_CMDRSP_Q6_ID_2_6 == payload1[3]) {
|
||||
q6core_lcl.q6_core_avs_version = Q6_SUBSYS_AVS2_6;
|
||||
pr_debug("%s: Received ADSP version as 2.6\n",
|
||||
__func__);
|
||||
} else if (AVCS_CMDRSP_Q6_ID_2_7 == payload1[3]) {
|
||||
q6core_lcl.q6_core_avs_version = Q6_SUBSYS_AVS2_7;
|
||||
pr_debug("%s: Received ADSP version as 2.7\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]);
|
||||
|
@ -173,7 +197,6 @@ static int32_t aprv2_core_fn_q(struct apr_client_data *data, void *priv)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -282,6 +305,64 @@ 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;
|
||||
|
||||
q6core_lcl.cmd_resp_received_flag &= ~(FLAG_AVCS_GET_VERSIONS_RESULT);
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
@ -308,7 +389,7 @@ int32_t core_get_license_status(uint32_t module_id)
|
|||
get_lvr_cmd.hdr.opcode = AVCS_CMD_GET_LICENSE_VALIDATION_RESULT;
|
||||
get_lvr_cmd.id = module_id;
|
||||
|
||||
|
||||
q6core_lcl.cmd_resp_received_flag &= ~(FLAG_CMDRSP_LICENSE_RESULT);
|
||||
ret = apr_send_pkt(q6core_lcl.core_handle_q, (uint32_t *) &get_lvr_cmd);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: license_validation request failed, err %d\n",
|
||||
|
@ -317,7 +398,6 @@ int32_t core_get_license_status(uint32_t module_id)
|
|||
goto fail_cmd;
|
||||
}
|
||||
|
||||
q6core_lcl.cmd_resp_received_flag &= ~(FLAG_CMDRSP_LICENSE_RESULT);
|
||||
mutex_unlock(&(q6core_lcl.cmd_lock));
|
||||
ret = wait_event_timeout(q6core_lcl.cmd_req_wait,
|
||||
(q6core_lcl.cmd_resp_received_flag ==
|
||||
|
|
Loading…
Reference in New Issue