[PATCH] i.MX8 crypto/fsl: Enable fsl CAAM rng driver

Stefano Babic sbabic at denx.de
Thu Apr 21 22:59:29 CEST 2022


Hi Gaurav,

Il 19.04.22 16:04, Gaurav Jain ha scritto:
> 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;
>   

This breaks the kontron_sl28 board. Can you check and fix it, please ? 
Thanks !

Best regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================


More information about the U-Boot mailing list