MLK-18703: crypto: caam: Add TRNG init function call

Call the TRNG init function at the end of arch_cpu_init()
 Concerned SoCs are: i.MX6, i.MX7 and i.MX8M

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
This commit is contained in:
Aymen Sghaier 2018-07-03 10:14:37 +02:00
parent 1f4134c85f
commit 996329904c
8 changed files with 60 additions and 2 deletions

View File

@ -616,6 +616,7 @@ config ARCH_IMX8M
select SYS_FSL_SEC_LE
select DM
select SUPPORT_SPL
select IMX_SEC_INIT
config ARCH_MX23
bool "NXP i.MX23 family"
@ -642,6 +643,7 @@ config ARCH_MX7ULP
select SYS_FSL_SEC_LE
select ROM_UNIFIED_SECTIONS
imply MXC_GPIO
select IMX_SEC_INIT
config ARCH_MX7
bool "Freescale MX7"
@ -651,6 +653,7 @@ config ARCH_MX7
select SYS_FSL_SEC_LE
select BOARD_EARLY_INIT_F
select ARCH_MISC_INIT
select IMX_SEC_INIT
imply MXC_GPIO
config ARCH_MX6
@ -659,6 +662,7 @@ config ARCH_MX6
select SYS_FSL_HAS_SEC if SECURE_BOOT
select SYS_FSL_SEC_COMPAT_4
select SYS_FSL_SEC_LE
select IMX_SEC_INIT
select SYS_THUMB_BUILD if SPL
imply MXC_GPIO

View File

@ -18,6 +18,17 @@ config SYSCOUNTER_TIMER
config GPT_TIMER
bool
config FSL_CAAM_KB
bool
config IMX_SEC_INIT
bool
help
In most of i.MX board with CAAM this option is used
to init RNG from U-Boot
select FSL_CAAM_KB
select SPL_CRYPTO_SUPPORT if SPL
config IMX_RDC
bool "i.MX Resource domain controller driver"
depends on ARCH_MX6 || ARCH_MX7

View File

@ -1,5 +1,5 @@
/*
* Copyright 2017 NXP
* Copyright 2017-2018 NXP
*
* Peng Fan <peng.fan@nxp.com>
*
@ -21,6 +21,9 @@
#include <imx_sip.h>
#include <generated/version_autogenerated.h>
#include <asm/setup.h>
#ifdef CONFIG_IMX_SEC_INIT
#include <fsl_caam.h>
#endif
DECLARE_GLOBAL_DATA_PTR;
@ -190,6 +193,11 @@ int arch_cpu_init(void)
imx_set_wdog_powerdown(false);
}
#ifdef CONFIG_IMX_SEC_INIT
/* Secure init function such RNG */
imx_sec_init();
#endif
return 0;
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2013 Stefan Roese <sr@denx.de>
* Copyright 2018 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -9,6 +10,7 @@
#include <linux/errno.h>
#include <asm/io.h>
#include <asm/mach-imx/regs-common.h>
#include <fsl_caam.h>
/* 1 second delay should be plenty of time for block reset. */
#define RESET_MAX_TIMEOUT 1000000
@ -72,3 +74,11 @@ int mxs_reset_block(struct mxs_register_32 *reg)
return 0;
}
void imx_sec_init(void)
{
#if defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL)
caam_open();
#endif
}

View File

@ -25,6 +25,9 @@
#include <imx_thermal.h>
#include <mmc.h>
#include <asm/setup.h>
#ifdef CONFIG_IMX_SEC_INIT
#include <fsl_caam.h>
#endif
enum ldo_reg {
LDO_ARM,
@ -637,6 +640,11 @@ int arch_cpu_init(void)
if (is_mx6dqp())
writel(0x80000201, 0xbb0608);
#ifdef CONFIG_IMX_SEC_INIT
/* Secure init function such RNG */
imx_sec_init();
#endif
return 0;
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
* Copyright 2017-2018 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -21,6 +21,9 @@
#include <fsl_sec.h>
#include <fsl_wdog.h>
#include <asm/setup.h>
#ifdef CONFIG_IMX_SEC_INIT
#include <fsl_caam.h>
#endif
#if defined(CONFIG_IMX_THERMAL)
static const struct imx_thermal_plat imx7_thermal_plat = {
@ -213,6 +216,11 @@ int arch_cpu_init(void)
isolate_resource();
#endif
#ifdef CONFIG_IMX_SEC_INIT
/* Secure init function such RNG */
imx_sec_init();
#endif
return 0;
}

View File

@ -13,6 +13,9 @@
#include <asm/mach-imx/boot_mode.h>
#include <fdt_support.h>
#include <asm/setup.h>
#ifdef CONFIG_IMX_SEC_INIT
#include <fsl_caam.h>
#endif
static char *get_reset_cause(char *);
@ -98,6 +101,11 @@ int arch_cpu_init(void)
}
#endif
#ifdef CONFIG_IMX_SEC_INIT
/* Secure init function such RNG */
imx_sec_init();
#endif
return 0;
}

View File

@ -50,6 +50,7 @@
//!
////////////////////////////////////////////////////////////////////////////////
void caam_open(void);
void imx_sec_init(void);
////////////////////////////////////////////////////////////////////////////////
//! @brief Generate a blob of a secure key.