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_scm.c | 78 ++++++++++++++++++++++++++
14 drivers/firmware/qcom_scm.h | 2 +
15 include/linux/firmware/qcom/qcom_scm.h | 2 +
16 3 files changed, 82 insertions(+)
18 --- a/drivers/firmware/qcom_scm.c
19 +++ b/drivers/firmware/qcom_scm.c
20 @@ -712,6 +712,84 @@ bool qcom_scm_pas_supported(u32 peripher
22 EXPORT_SYMBOL_GPL(qcom_scm_pas_supported);
25 + * qcom_scm_msa_lock() - Lock given peripheral firmware region as MSA
27 + * @peripheral: peripheral id
29 + * Return 0 on success.
31 +int qcom_scm_msa_lock(u32 peripheral)
34 + struct qcom_scm_desc desc = {
35 + .svc = QCOM_SCM_SVC_PIL,
36 + .cmd = QCOM_SCM_MSA_LOCK,
37 + .arginfo = QCOM_SCM_ARGS(1),
38 + .args[0] = peripheral,
39 + .owner = ARM_SMCCC_OWNER_SIP,
41 + struct qcom_scm_res res;
43 + if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
47 + ret = qcom_scm_clk_enable();
51 + ret = qcom_scm_bw_enable();
55 + ret = qcom_scm_call(__scm->dev, &desc, &res);
56 + qcom_scm_bw_disable();
57 + qcom_scm_clk_disable();
59 + return ret ? : res.result[0];
61 +EXPORT_SYMBOL_GPL(qcom_scm_msa_lock);
64 + * qcom_scm_msa_unlock() - Unlock given peripheral MSA firmware region
66 + * @peripheral: peripheral id
68 + * Return 0 on success.
70 +int qcom_scm_msa_unlock(u32 peripheral)
73 + struct qcom_scm_desc desc = {
74 + .svc = QCOM_SCM_SVC_PIL,
75 + .cmd = QCOM_SCM_MSA_UNLOCK,
76 + .arginfo = QCOM_SCM_ARGS(1),
77 + .args[0] = peripheral,
78 + .owner = ARM_SMCCC_OWNER_SIP,
80 + struct qcom_scm_res res;
82 + if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
83 + QCOM_SCM_MSA_UNLOCK))
86 + ret = qcom_scm_clk_enable();
90 + ret = qcom_scm_bw_enable();
94 + ret = qcom_scm_call(__scm->dev, &desc, &res);
95 + qcom_scm_bw_disable();
96 + qcom_scm_clk_disable();
98 + return ret ? : res.result[0];
100 +EXPORT_SYMBOL_GPL(qcom_scm_msa_unlock);
102 static int __qcom_scm_pas_mss_reset(struct device *dev, bool reset)
104 struct qcom_scm_desc desc = {
105 --- a/drivers/firmware/qcom_scm.h
106 +++ b/drivers/firmware/qcom_scm.h
107 @@ -98,6 +98,8 @@ extern int scm_legacy_call(struct device
108 #define QCOM_SCM_PIL_PAS_SHUTDOWN 0x06
109 #define QCOM_SCM_PIL_PAS_IS_SUPPORTED 0x07
110 #define QCOM_SCM_PIL_PAS_MSS_RESET 0x0a
111 +#define QCOM_SCM_MSA_LOCK 0x24
112 +#define QCOM_SCM_MSA_UNLOCK 0x25
114 #define QCOM_SCM_SVC_IO 0x05
115 #define QCOM_SCM_IO_READ 0x01
116 --- a/include/linux/firmware/qcom/qcom_scm.h
117 +++ b/include/linux/firmware/qcom/qcom_scm.h
118 @@ -81,6 +81,8 @@ extern int qcom_scm_pas_mem_setup(u32 pe
119 extern int qcom_scm_pas_auth_and_reset(u32 peripheral);
120 extern int qcom_scm_pas_shutdown(u32 peripheral);
121 extern bool qcom_scm_pas_supported(u32 peripheral);
122 +extern int qcom_scm_msa_lock(u32 peripheral);
123 +extern int qcom_scm_msa_unlock(u32 peripheral);
125 extern int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val);
126 extern int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);