All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i.MX8 crypto/fsl: Enable fsl CAAM rng driver
@ 2022-04-19 14:04 Gaurav Jain
  2022-04-21 20:59 ` Stefano Babic
  0 siblings, 1 reply; 3+ messages in thread
From: Gaurav Jain @ 2022-04-19 14:04 UTC (permalink / raw)
  To: Stefano Babic, u-boot
  Cc: Fabio Estevam, Priyanka Jain, Ye Li, Horia Geanta,
	Silvano Di Ninno, Varun Sethi, NXP i . MX U-Boot Team,
	Gaurav Jain

rng driver enabled to read random number using caam.

Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
---
 drivers/crypto/fsl/jr.c  | 8 +++++++-
 drivers/crypto/fsl/rng.c | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 85a3dac796..acd29924f7 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -767,8 +767,14 @@ init:
 		return -1;
 	}
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-	if (ofnode_valid(scu_node))
+	if (ofnode_valid(scu_node)) {
+		if (IS_ENABLED(CONFIG_DM_RNG)) {
+			ret = device_bind_driver(NULL, "caam-rng", "caam-rng", NULL);
+			if (ret)
+				printf("Couldn't bind rng driver (%d)\n", ret);
+		}
 		return ret;
+	}
 #endif
 
 #ifdef CONFIG_FSL_CORENET
diff --git a/drivers/crypto/fsl/rng.c b/drivers/crypto/fsl/rng.c
index 0636494805..b568c337a6 100644
--- a/drivers/crypto/fsl/rng.c
+++ b/drivers/crypto/fsl/rng.c
@@ -26,10 +26,16 @@ struct caam_rng_priv {
 
 static int caam_rng_read_one(struct caam_rng_priv *priv)
 {
+	struct udevice *dev;
 	int size = ALIGN(CAAM_RNG_MAX_FIFO_STORE_SIZE, ARCH_DMA_MINALIGN);
 	int ret;
 
-	ret = run_descriptor_jr(priv->desc);
+	if (uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(caam_jr), &dev) || !dev) {
+		printf("No CAAM device\n");
+		return -ENODEV;
+	}
+
+	ret = misc_ioctl(dev, CAAM_JR_RUN_DESC, priv->desc);
 	if (ret < 0)
 		return -EIO;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-22 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 14:04 [PATCH] i.MX8 crypto/fsl: Enable fsl CAAM rng driver Gaurav Jain
2022-04-21 20:59 ` Stefano Babic
2022-04-22 11:11   ` [EXT] " Gaurav Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.