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@xxxxxxxxxxxx> --- drivers/mmc/host/mtk-sd.c | 19 +++++++++++++++++++ drivers/mmc/host/mtk-sd.h | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100755 drivers/mmc/host/mtk-sd.h diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index e870afd66ae8..923644b8fc1e 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -4,6 +4,7 @@ * Author: Chaotian.Jing <chaotian.jing@xxxxxxxxxxxx> */ +#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 @@ -2612,6 +2614,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 +2780,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; } diff --git a/drivers/mmc/host/mtk-sd.h b/drivers/mmc/host/mtk-sd.h new file mode 100755 index 000000000000..e9421ef7d880 --- /dev/null +++ b/drivers/mmc/host/mtk-sd.h @@ -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) -- 2.18.0