From: Peng Zhou <peng.zhou@mediatek.com>
To: Eric Biggers <ebiggers@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
Chaotian Jing <chaotian.jing@mediatek.com>,
<linux-mmc@vger.kernel.org>
Cc: <devicetree@vger.kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Satya Tangirala <satyat@google.com>,
Wulin Li <wulin.li@mediatek.com>,
Peng Zhou <peng.zhou@mediatek.com>
Subject: [PATCH v2 2/4] mmc: Mediatek: enable crypto hardware engine
Date: Tue, 9 Mar 2021 09:57:51 +0800 [thread overview]
Message-ID: <20210309015750.6283-1-peng.zhou@mediatek.com> (raw)
Use SMC call enable hardware crypto engine
due to it only be changed in ATF(EL3).
Signed-off-by: Peng Zhou <peng.zhou@mediatek.com>
---
drivers/mmc/host/mtk-sd.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 1c90360d6cf2..225ef5519161 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -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>
@@ -20,6 +21,7 @@
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
+#include <linux/soc/mediatek/mtk_sip_svc.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/reset.h>
@@ -319,6 +321,12 @@
#define DEFAULT_DEBOUNCE (8) /* 8 cycles CD debounce */
#define PAD_DELAY_MAX 32 /* PAD delay cells */
+
+/*--------------------------------------------------------------------------*/
+/* SiP commands which used for crypto */
+/*--------------------------------------------------------------------------*/
+#define MTK_SIP_MMC_CONTROL MTK_SIP_SMC_CMD(0x273)
+
/*--------------------------------------------------------------------------*/
/* Descriptor Structure */
/*--------------------------------------------------------------------------*/
@@ -2467,6 +2475,7 @@ static int msdc_of_clock_parse(struct platform_device *pdev,
static int msdc_drv_probe(struct platform_device *pdev)
{
+ struct arm_smccc_res smccc_res;
struct mmc_host *mmc;
struct msdc_host *host;
struct resource *res;
@@ -2616,6 +2625,15 @@ static int msdc_drv_probe(struct platform_device *pdev)
mmc->max_seg_size = 64 * 1024;
}
+ /*
+ * 1: MSDC_AES_CTL_INIT
+ * 4: cap_id, no-meaning now
+ * 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,
2 * sizeof(struct mt_gpdma_desc),
@@ -2770,9 +2788,18 @@ static int __maybe_unused msdc_runtime_resume(struct device *dev)
{
struct mmc_host *mmc = dev_get_drvdata(dev);
struct msdc_host *host = mmc_priv(mmc);
+ struct arm_smccc_res smccc_res;
msdc_ungate_clock(host);
msdc_restore_reg(host);
+ /*
+ * 1: MSDC_AES_CTL_INIT
+ * 4: cap_id, no-meaning now
+ * 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;
}
--
2.18.0
next reply other threads:[~2021-03-09 2:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 1:57 Peng Zhou [this message]
2021-03-11 11:16 ` [PATCH v2 2/4] mmc: Mediatek: enable crypto hardware engine Ulf Hansson
2021-03-11 13:48 ` Linus Walleij
2021-03-11 19:08 ` Eric Biggers
2021-03-12 9:05 ` Ulf Hansson
2021-03-12 10:47 ` Arnd Bergmann
[not found] ` <1615884533.21508.118.camel@mbjsdccf07>
2021-03-16 10:09 ` Ulf Hansson
[not found] ` <1615893329.21508.128.camel@mbjsdccf07>
2021-03-16 13:55 ` Ulf Hansson
2021-03-22 13:45 ` Linus Walleij
2021-03-23 13:37 ` Ulf Hansson
2021-03-15 13:41 ` Linus Walleij
2021-03-15 23:02 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210309015750.6283-1-peng.zhou@mediatek.com \
--to=peng.zhou@mediatek.com \
--cc=adrian.hunter@intel.com \
--cc=chaotian.jing@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=ebiggers@kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=satyat@google.com \
--cc=ulf.hansson@linaro.org \
--cc=wulin.li@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox