1 From 217fbbc122663c5a3dac752cebef44fb3e0cc179 Mon Sep 17 00:00:00 2001
2 From: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
3 Date: Fri, 10 Nov 2023 14:49:35 +0530
4 Subject: [PATCH] firmware: qcom_scm: ipq5332: add msa lock/unlock
7 IPQ5332 user pd remoteproc firmwares need to be locked
8 with MSA(modem secure access) features. This patch add
9 support to lock/unlock MSA features.
11 Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
13 drivers/firmware/qcom//qcom_scm.c | 78 ++++++++++++++++++++++++++
14 drivers/firmware/qcom//qcom_scm.h | 2 +
15 include/linux/firmware/qcom/qcom_scm.h | 2 +
16 3 files changed, 82 insertions(+)
18 --- a/include/linux/firmware/qcom/qcom_scm.h
19 +++ b/include/linux/firmware/qcom/qcom_scm.h
20 @@ -79,6 +79,8 @@ int qcom_scm_pas_mem_setup(u32 periphera
21 int qcom_scm_pas_auth_and_reset(u32 peripheral);
22 int qcom_scm_pas_shutdown(u32 peripheral);
23 bool qcom_scm_pas_supported(u32 peripheral);
24 +int qcom_scm_msa_lock(u32 peripheral);
25 +int qcom_scm_msa_unlock(u32 peripheral);
27 int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val);
28 int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);
29 --- a/drivers/firmware/qcom/qcom_scm.c
30 +++ b/drivers/firmware/qcom/qcom_scm.c
31 @@ -806,6 +806,84 @@ bool qcom_scm_pas_supported(u32 peripher
33 EXPORT_SYMBOL_GPL(qcom_scm_pas_supported);
36 + * qcom_scm_msa_lock() - Lock given peripheral firmware region as MSA
38 + * @peripheral: peripheral id
40 + * Return 0 on success.
42 +int qcom_scm_msa_lock(u32 peripheral)
45 + struct qcom_scm_desc desc = {
46 + .svc = QCOM_SCM_SVC_PIL,
47 + .cmd = QCOM_SCM_MSA_LOCK,
48 + .arginfo = QCOM_SCM_ARGS(1),
49 + .args[0] = peripheral,
50 + .owner = ARM_SMCCC_OWNER_SIP,
52 + struct qcom_scm_res res;
54 + if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
58 + ret = qcom_scm_clk_enable();
62 + ret = qcom_scm_bw_enable();
66 + ret = qcom_scm_call(__scm->dev, &desc, &res);
67 + qcom_scm_bw_disable();
68 + qcom_scm_clk_disable();
70 + return ret ? : res.result[0];
72 +EXPORT_SYMBOL_GPL(qcom_scm_msa_lock);
75 + * qcom_scm_msa_unlock() - Unlock given peripheral MSA firmware region
77 + * @peripheral: peripheral id
79 + * Return 0 on success.
81 +int qcom_scm_msa_unlock(u32 peripheral)
84 + struct qcom_scm_desc desc = {
85 + .svc = QCOM_SCM_SVC_PIL,
86 + .cmd = QCOM_SCM_MSA_UNLOCK,
87 + .arginfo = QCOM_SCM_ARGS(1),
88 + .args[0] = peripheral,
89 + .owner = ARM_SMCCC_OWNER_SIP,
91 + struct qcom_scm_res res;
93 + if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
94 + QCOM_SCM_MSA_UNLOCK))
97 + ret = qcom_scm_clk_enable();
101 + ret = qcom_scm_bw_enable();
105 + ret = qcom_scm_call(__scm->dev, &desc, &res);
106 + qcom_scm_bw_disable();
107 + qcom_scm_clk_disable();
109 + return ret ? : res.result[0];
111 +EXPORT_SYMBOL_GPL(qcom_scm_msa_unlock);
113 static int __qcom_scm_pas_mss_reset(struct device *dev, bool reset)
115 struct qcom_scm_desc desc = {
116 --- a/drivers/firmware/qcom/qcom_scm.h
117 +++ b/drivers/firmware/qcom/qcom_scm.h
118 @@ -102,6 +102,8 @@ struct qcom_tzmem_pool *qcom_scm_get_tzm
119 #define QCOM_SCM_PIL_PAS_SHUTDOWN 0x06
120 #define QCOM_SCM_PIL_PAS_IS_SUPPORTED 0x07
121 #define QCOM_SCM_PIL_PAS_MSS_RESET 0x0a
122 +#define QCOM_SCM_MSA_LOCK 0x24
123 +#define QCOM_SCM_MSA_UNLOCK 0x25
125 #define QCOM_SCM_SVC_IO 0x05
126 #define QCOM_SCM_IO_READ 0x01