浏览代码

crypto: sa2ul: Export function to enable trng

The trng module has enable bit in the sa2ul register
space. Hence Export a function for trng driver to enable
the trng module.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Keerthy 6 年之前
父节点
当前提交
1f1ae3a63b
共有 3 个文件被更改,包括 32 次插入1 次删除
  1. 6 0
      drivers/char/hw_random/omap-rng.c
  2. 19 1
      drivers/crypto/sa2ul.c
  3. 7 0
      include/linux/k3_sa2ul.h

+ 6 - 0
drivers/char/hw_random/omap-rng.c

@@ -29,6 +29,7 @@
 #include <linux/of_address.h>
 #include <linux/interrupt.h>
 #include <linux/clk.h>
+#include <linux/k3_sa2ul.h>
 
 #include <asm/io.h>
 
@@ -440,6 +441,11 @@ static int omap_rng_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
+#if defined(CONFIG_CRYPTO_DEV_SA2UL_MODULE) || defined(CONFIG_CRYPTO_DEV_SA2UL)
+	ret = sa2ul_trng_enable(dev->parent);
+	if (ret)
+		return ret;
+#endif
 	priv->rng.read = omap_rng_do_read;
 	priv->rng.init = omap_rng_init;
 	priv->rng.cleanup = omap_rng_cleanup;

+ 19 - 1
drivers/crypto/sa2ul.c

@@ -2155,6 +2155,24 @@ err_dma_tx:
 	return ret;
 }
 
+int sa2ul_trng_enable(struct device *dev)
+{
+	struct sa_crypto_data *dev_data;
+	u32 val;
+
+	if (!dev)
+		return -ENODEV;
+
+	dev_data = dev_get_drvdata(dev);
+
+	val = readl_relaxed(dev_data->base + SA_ENGINE_ENABLE_CONTROL);
+	writel_relaxed(val | SA_EEC_TRNG_EN, dev_data->base +
+		       SA_ENGINE_ENABLE_CONTROL);
+
+	return 0;
+}
+EXPORT_SYMBOL(sa2ul_trng_enable);
+
 static int sa_ul_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -2185,7 +2203,7 @@ static int sa_ul_probe(struct platform_device *pdev)
 
 	dev_data->base = saul_base;
 	val = SA_EEC_ENCSS_EN | SA_EEC_AUTHSS_EN | SA_EEC_CTXCACH_EN |
-	    SA_EEC_CPPI_PORT_IN_EN | SA_EEC_CPPI_PORT_OUT_EN | SA_EEC_TRNG_EN;
+	    SA_EEC_CPPI_PORT_IN_EN | SA_EEC_CPPI_PORT_OUT_EN;
 
 	writel_relaxed(val, saul_base + SA_ENGINE_ENABLE_CONTROL);
 

+ 7 - 0
include/linux/k3_sa2ul.h

@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef	__K3_SA2UL_H
+#define	__K3_SA2UL_H
+
+int sa2ul_trng_enable(struct device *dev);
+
+#endif /* __K3_SA2UL_H */