MediaTek eMMC inline encryption support
Subsystems (3)
v3 cover MediaTek eMMC inline encryption support
Hello,
Mediatek eMMC hardware IP has Inline Crypto Engine (ICE), we support inline encryption now.
For Inline Crypto Engine (ICE), see:
- https://lore.kernel.org/linux-arm-msm/
[email protected]/T/
This patchset supports Mediatek eMMC inline encryption which meets the upcoming version of the eMMC specification such as v5.1 or v5.2.
Patch 1-2, add crypto property and crypto clock, patch 3, document the device tree description about crypto clock.
Please noted that there is a special way of on/off crypto hardware IP in our SoCs, the enable bit must be controlled under ARM highest security level, that means must in ARM trusted firmware(ATF).
Changed in v3:
- Removed "mmc: Mediatek: enable crypto hardware engine" patch temporarily. Needs finding a better way for enable crypto hardware IP through ATF, so remove "mmc: Mediatek: enable crypto hardware engine" patch temporarily, we could enable it in ATF directly when boot up which will be a workaround solution. Discussing about this, see: https://lore.kernel.org/linux-mmc/
YE%[email protected]/T/#t
- We will put the above mentioned patch in a single patch
Peng Zhou (3):
mmc: Mediatek: add Inline Crypto Engine support
arm64: dts: Mediatek: MT6779: add mmc node with ICE setting
dt-bingdings: mmc: Mediatek: add ICE clock
Documentation/devicetree/bindings/mmc/mtk-sd.yaml | 6 ++++-- arch/arm64/boot/dts/mediatek/mt6779.dtsi | 14 ++++++++++++++ drivers/mmc/host/mtk-sd.c | 15 ++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-)
PATCH v3 1/3 mmc: Mediatek: add Inline Crypto Engine support
From: Peng Zhou <[email protected]>
1. add crypto clock control and ungate it before CQHCI init
2. set MMC_CAP2_CRYPTO property of eMMC
--- drivers/mmc/host/mtk-sd.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/mmc/host/mtk-sd.c +14 -1
@@ -442,6 +442,7 @@ struct msdc_host {struct clk *src_clk_cg;/* msdc source clock control gate */ struct clk *sys_clk_cg;/* msdc subsys clock control gate */ struct clk_bulk_data bulk_clks[MSDC_NR_CLOCKS ]; +struct clk *crypto_clk;/* msdc crypto clock */ u32 mclk;/* mmc subsystem clock frequency */ u32 src_clk_freq;/* source clock frequency */ unsigned char timing;
@@ -802,6 +803,7 @@ static void msdc_set_busy_timeout(struct msdc_host *host, u64 ns, u64 clks)static void msdc_gate_clock (struct msdc_host *host) { +clk_disable_unprepare (host->crypto_clk);clk_bulk_disable_unprepare (MSDC_NR_CLOCKS , host->bulk_clks);clk_disable_unprepare (host->src_clk_cg);clk_disable_unprepare (host->src_clk);
@@ -822,6 +824,7 @@ static void msdc_ungate_clock(struct msdc_host *host)dev_err (host->dev,"Cannot enable pclk/axi/ahb clock gates\n" );return ; } +clk_prepare_enable (host->crypto_clk);while (!(readl (host->base +MSDC_CFG ) &MSDC_CFG_CKSTB ))cpu_relax ();
@@ -2512,6 +2515,15 @@ static int msdc_drv_probe(struct platform_device *pdev) goto host_free; } +/* only eMMC has crypto property */ +if ((mmc->caps2 &MMC_CAP2_NO_SD ) && (mmc->caps2 &MMC_CAP2_NO_SDIO )) { + host->crypto_clk =devm_clk_get (&pdev->dev,"crypto" ); +if (IS_ERR (host->crypto_clk)) + host->crypto_clk =NULL ; +else + mmc->caps2 |=MMC_CAP2_CRYPTO ; + } + host->irq =platform_get_irq (pdev,0 );if (host->irq <0 ) { ret = -EINVAL ;
@@ -2582,6 +2594,8 @@ static int msdc_drv_probe(struct platform_device *pdev) host->dma_mask =DMA_BIT_MASK (32 );mmc_dev (mmc)->dma_mask = &host->dma_mask; +/* here ungate due to cqhci init will access registers */ +msdc_ungate_clock (host);if (mmc->caps2 &MMC_CAP2_CQE ) { host->cq_host = devm_kzalloc(mmc->parent, sizeof(*host->cq_host),
@@ -2618,7 +2632,6 @@ static int msdc_drv_probe(struct platform_device *pdev)spin_lock_init (&host->lock);platform_set_drvdata (pdev, mmc); -msdc_ungate_clock (host);msdc_init_hw (host); ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq,
Signature · 1 line
2.18.0