@@ -4,6 +4,7 @@
* Author: Chaotian.Jing <chaotian.jing@mediatek.com>
*/
+#include <linux/arm-smccc.h>
#include <linux/module.h>
#include <linux/clk.h>
#include <linux/delay.h>
@@ -33,6 +34,7 @@
#include <linux/mmc/slot-gpio.h>
#include "cqhci.h"
+#include "mtk-sd.h"
#define MAX_BD_NUM 1024
#define MSDC_NR_CLOCKS 3
@@ -2467,6 +2469,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
struct mmc_host *mmc;
struct msdc_host *host;
struct resource *res;
+ struct arm_smccc_res smccc_res;
int ret;
if (!pdev->dev.of_node) {
@@ -2612,6 +2615,14 @@ static int msdc_drv_probe(struct platform_device *pdev)
/* 0 size, means 65536 so we don't have to -1 here */
mmc->max_seg_size = 64 * 1024;
}
+ /*
+ * 1: MSDC_AES_CTL_INIT
+ * 4: cap_id, no-meaning
+ * 1: cfg_id, we choose the second cfg group
+ */
+ if (mmc->caps2 & MMC_CAP2_CRYPTO)
+ arm_smccc_smc(MTK_SIP_MMC_CONTROL,
+ 1, 4, 1, 0, 0, 0, 0, &smccc_res);
host->timeout_clks = 3 * 1048576;
host->dma.gpd = dma_alloc_coherent(&pdev->dev,
@@ -2770,6 +2781,15 @@ static int __maybe_unused msdc_runtime_resume(struct device *dev)
msdc_ungate_clock(host);
msdc_restore_reg(host);
+
+ /*
+ * 1: MSDC_AES_CTL_INIT
+ * 4: cap_id, no-meaning
+ * 1: cfg_id, we choose the second cfg group
+ */
+ if (mmc->caps2 & MMC_CAP2_CRYPTO)
+ arm_smccc_smc(MTK_SIP_MMC_CONTROL,
+ 1, 4, 1, 0, 0, 0, 0, &smccc_res);
return 0;
}
new file mode 100755
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ */
+
+#include <linux/soc/mediatek/mtk_sip_svc.h>
+
+/*
+ * SiP commands
+ */
+#define MTK_SIP_MMC_CONTROL MTK_SIP_SMC_CMD(0x273)
Use SMC call enable hardware crypto engine due to it only be control in EL3. Change-Id: I5c6c8c534442e030bc5a4de23a317049924a8852 Signed-off-by: Peng Zhou <peng.zhou@mediatek.com> --- drivers/mmc/host/mtk-sd.c | 20 ++++++++++++++++++++ drivers/mmc/host/mtk-sd.h | 11 +++++++++++ 2 files changed, 31 insertions(+) create mode 100755 drivers/mmc/host/mtk-sd.h