firmware: qcom: scm: Add function to set IOMMU pagetable addressing
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
Wed, 8 Dec 2021 08:34:23 +0000 (09:34 +0100)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Mon, 31 Jan 2022 21:00:46 +0000 (15:00 -0600)
Add a function to change the IOMMU pagetable addressing to
AArch32 LPAE or AArch64. If doing that, then this must be
done for each IOMMU context (not necessarily at the same time).

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
[Marijn: ported from 5.3 to the unified architecture in 5.11]
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20211208083423.22037-4-marijn.suijten@somainline.org
drivers/firmware/qcom_scm.c
drivers/firmware/qcom_scm.h
include/linux/qcom_scm.h

index d5a9ba1..6f70961 100644 (file)
@@ -1140,6 +1140,22 @@ int qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt, u32 *resp)
 }
 EXPORT_SYMBOL(qcom_scm_hdcp_req);
 
+int qcom_scm_iommu_set_pt_format(u32 sec_id, u32 ctx_num, u32 pt_fmt)
+{
+       struct qcom_scm_desc desc = {
+               .svc = QCOM_SCM_SVC_SMMU_PROGRAM,
+               .cmd = QCOM_SCM_SMMU_PT_FORMAT,
+               .arginfo = QCOM_SCM_ARGS(3),
+               .args[0] = sec_id,
+               .args[1] = ctx_num,
+               .args[2] = pt_fmt, /* 0: LPAE AArch32 - 1: AArch64 */
+               .owner = ARM_SMCCC_OWNER_SIP,
+       };
+
+       return qcom_scm_call(__scm->dev, &desc, NULL);
+}
+EXPORT_SYMBOL(qcom_scm_iommu_set_pt_format);
+
 int qcom_scm_qsmmu500_wait_safe_toggle(bool en)
 {
        struct qcom_scm_desc desc = {
index bb62794..a348f2c 100644 (file)
@@ -120,6 +120,7 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc,
 #define QCOM_SCM_LMH_LIMIT_DCVSH               0x10
 
 #define QCOM_SCM_SVC_SMMU_PROGRAM              0x15
+#define QCOM_SCM_SMMU_PT_FORMAT                        0x01
 #define QCOM_SCM_SMMU_CONFIG_ERRATA1           0x03
 #define QCOM_SCM_SMMU_CONFIG_ERRATA1_CLIENT_ALL        0x02
 
index 8a065f8..ca4a88d 100644 (file)
@@ -108,6 +108,7 @@ extern bool qcom_scm_hdcp_available(void);
 extern int qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt,
                             u32 *resp);
 
+extern int qcom_scm_iommu_set_pt_format(u32 sec_id, u32 ctx_num, u32 pt_fmt);
 extern int qcom_scm_qsmmu500_wait_safe_toggle(bool en);
 
 extern int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val,