[PATCH] i.MX8 crypto/fsl: Enable fsl CAAM rng driver
Gaurav Jain
gaurav.jain at nxp.com
Tue Apr 19 16:04:24 CEST 2022
rng driver enabled to read random number using caam.
Signed-off-by: Gaurav Jain <gaurav.jain at 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
More information about the U-Boot
mailing list